Esempio n. 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)
Esempio n. 2
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)
Esempio n. 3
0
 def create(forceDeleteIfExists=False):
     if Database.exists():
         if forceDeleteIfExists:
             Database.drop()
         else:
             return
     Directory.make(Database.directory)
     try:
         Database.ODB.bind("sqlite", Database.path, create_db=True)
     except TypeError:
         pass
     else:
         Database.ODB.generate_mapping(create_tables=True)
         Database.ODB.disconnect()
Esempio n. 4
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)
Esempio n. 5
0
 def __initializeFramework(self):
     self.frameworkParams["projectID"] = self.getProjectID()
     self.frameworkParams["dataDir"] = "{0}/Data/{1}".format(
         self.installDir, self.getProjectID())
     Directory.make(self.frameworkParams["dataDir"])
     self.frameworkParams["originalPath"] = "{0}/original.txt".format(
         self.frameworkParams["dataDir"])
     self.frameworkParams["inputPath"] = "{0}/input.txt".format(
         self.frameworkParams["dataDir"])
     self.frameworkParams["analyzerPath"] = "{0}/analyzer.txt".format(
         self.frameworkParams["dataDir"])
     self.frameworkParams["translatorPath"] = "{0}/translator.txt".format(
         self.frameworkParams["dataDir"])
     self.frameworkParams["outputPath"] = "{0}/output.txt".format(
         self.frameworkParams["dataDir"])
     self.frameworkParams["dateTime"] = datetime.datetime.now().isoformat()
Esempio n. 6
0
 def getSubresourceIntegrityHashes(displayValues=False):
     sriHashes = {}
     webDir = Framework.getWebDir()
     for subDir in ["Css", "Js"]:
         for path in Directory.getFiles("{0}/{1}".format(webDir, subDir)):
             sriHashes[path] = Security.getSubresourceIntegrityHash(path)
             if displayValues:
                 print("\n{0}\n{1}\n".format(path, sriHashes[path]))
Esempio n. 7
0
 def getInstallDir():
     return Directory.getCanonicalPath(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))