示例#1
0
 def copy(src, tgt, mkdirs=False):
     try:
         if mkdirs:
             Directory.make(File.getDirectory(tgt))
         copyfile(src, tgt)
     except IOError as e:
         Error.handleException(e, True, True)
示例#2
0
 def __getPluginMethodInstance(self, pluginInstance, pluginMethod):
     method = None
     try:
         method = getattr(pluginInstance, pluginMethod)
     except Exception as e:
         Error.handleException(
             "Something bad happened: {0}/{1}\n{2}".format(
                 pluginInstance.__class__, pluginMethod, str(e)), True,
             True)
     return method
示例#3
0
def deleteSafe():
    try:
        for path in [
                "./", "./Core", "./Plugin", "./Plugin/Analyzer",
                "./Plugin/Demo", "./Plugin/IO", "./Plugin/Test",
                "./Plugin/Translator"
        ]:
            Directory.delete("{0}/__pycache__".format(path))
            for path in glob.glob("./Test/Tmp/*"):
                File.delete(File.getCanonicalPath(path))
    except Exception as e:
        Error.handleException(e, True)
示例#4
0
 def getContent(path, asJson=False):
     content = None
     try:
         if asJson:
             with open(path, "r", encoding="utf-8") as fd:
                 content = json.load(fd)
         else:
             with open(path, "r", encoding="utf-8") as fd:
                 content = fd.read()
     except IOError as e:
         Error.handleException(e, True, True)
     return content
示例#5
0
def deleteProtected(cfgPath):
    try:
        cfg = Cfg(cfgPath)
        cfg.load()
        for path in [
                "./Database/{0}.db".format(cfg.cfg["Database"]["Name"]),
                "./Database/CocoscatsTest.db", "./Vault/Certificate.pem",
                "./Vault/Password.json", "./Vault/PrivateKey.pem",
                "./Vault/PublicKey.pem"
        ]:
            File.delete(path)
    except Exception as e:
        Error.handleException(e, True)
示例#6
0
 def setContent(path, content, asJson=False, asBytes=False, mkdirs=False):
     try:
         if mkdirs:
             Directory.make(File.getDirectory(path))
         if asJson:
             with open(path, "w", encoding="utf-8") as fd:
                 json.dump(content, fd)
         elif asBytes:
             with open(path, "wb") as fd:
                 fd.write(content)
         else:
             with open(path, "w", encoding="utf-8") as fd:
                 fd.write(content)
     except IOError as e:
         Error.handleException(e, True, True)
示例#7
0
 def handleException(msg, showStackTraceFlag=True, abortFlag=True):
     Error.handleException(msg, showStackTraceFlag, abortFlag)