MCPcopy
hub / github.com/pyload/pyload / check_file

Method check_file

pyLoadCore.py:546–581  ·  view source on GitHub ↗

check wether needed files exists

(self, check_names, description="", folder=False, empty=True, essential=False, quiet=False)

Source from the content-addressed store, hash-verified

544 return False
545
546 def check_file(self, check_names, description="", folder=False, empty=True, essential=False, quiet=False):
547 """check wether needed files exists"""
548 tmp_names = []
549 if not type(check_names) == list:
550 tmp_names.append(check_names)
551 else:
552 tmp_names.extend(check_names)
553 file_created = True
554 file_exists = True
555 for tmp_name in tmp_names:
556 if not exists(tmp_name):
557 file_exists = False
558 if empty:
559 try:
560 if folder:
561 tmp_name = tmp_name.replace("/", sep)
562 makedirs(tmp_name)
563 else:
564 open(tmp_name, "w")
565 except:
566 file_created = False
567 else:
568 file_created = False
569
570 if not file_exists and not quiet:
571 if file_created:
572 #self.log.info( _("%s created") % description )
573 pass
574 else:
575 if not empty:
576 self.log.warning(
577 _("could not find %(desc)s: %(name)s") % {"desc": description, "name": tmp_name})
578 else:
579 print _("could not create %(desc)s: %(name)s") % {"desc": description, "name": tmp_name}
580 if essential:
581 exit()
582
583 def isClientConnected(self):
584 return (self.lastClientConnected + 30) > time()

Callers 1

startMethod · 0.95

Calls 5

existsFunction · 0.85
extendMethod · 0.80
_Function · 0.50
appendMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected