コード例 #1
0
 def getCredentials(self):
     stack = inspect.stack()
     className = str(stack[1][0].f_locals["self"].__class__.__name__)
     path = "{0}/{1}.json".format(Framework.getVaultDir(), className)
     if not File.exists(path):
         self.raiseException(
             "Missing {0} credentials file".format(className))
     return File.getContent(path, asJson=True)
コード例 #2
0
ファイル: Web.py プロジェクト: johnlwhiteman/CoCoScatS
 def __runTranslator(action=None):
     WebApp.checkAuthentication()
     header = WebApp.getHeader("Translator")
     footer = WebApp.getFooter()
     pluginName = Web.cocoscats.cfg["Workflow"]["Translator"]["Plugin"]
     navigation = WebApp.getNavigation("Translator", 3, pluginName)
     path = Web.cocoscats.frameworkParams["translatorPath"]
     if not action is None and action == "Save":
         File.setContent(path, bottle.request.forms.Content)
         WebApp.translatorTainted = True
         WebApp.outputTainted = False
         return "Successfully saved to '" + path + "'"
     content = None
     if WebApp.translatorTainted:
         content = File.getContent(path)
     else:
         content = Web.cocoscats.runTranslator()
     editor = WebApp.getEditor(content)
     body = """{0}{1}""".format(navigation, editor)
     return "{0}{1}{2}".format(header, body, footer)
コード例 #3
0
ファイル: TextFile.py プロジェクト: johnlwhiteman/CoCoScatS
 def runInput(self):
     content = File.getContent(self.getWorkflowSource())
     self.setInputContent(content)
     return content
コード例 #4
0
ファイル: Cocoscats.py プロジェクト: johnlwhiteman/CoCoScatS
    def updateDatabase(self):
        #Database.connect()
        #projects = Database.getProject("MyProjectID")
        #print(projects)
        #Database.disconnect()
        #sys.exit()
        if not Text.isTrue(self.cfg["Database"]["Enable"]):
            Msg.showWarning("Database is NOT enabled in {0}".format(
                self.cfgPath))
            return
        Database.connect()
        Database.setDebug(Text.toTrueOrFalse(self.cfg["Database"]["Debug"]))
        with Database.ORM.db_session:
            records = Database.Table.Project.get(ID=self.getProjectID())
            if records is not None:
                records.delete()
                Database.commit()

            projectTable = Database.Table.Project(
                ID=self.getProjectID(),
                Title=Database.sanitize(self.cfg["Title"]),
                Description=Database.sanitize(self.cfg["Description"]),
                DateTime=self.frameworkParams["dateTime"],
                Workflow=self.cfg["Workflow"])

            inputTable = Database.Table.Input(
                ProjectID=projectTable,
                Content=Database.sanitize(
                    File.getContent(self.frameworkParams["inputPath"])),
                Source=Database.sanitize(
                    self.cfg["Workflow"]["Input"]["Source"]),
                PluginName=Database.sanitize(
                    self.cfg["Workflow"]["Input"]["Plugin"]),
                PluginMethod=Database.sanitize(
                    self.cfg["Workflow"]["Input"]["Method"]),
                Plugin=self.cfg["Workflow"]["Input"])

            analyzerTable = Database.Table.Analyzer(
                ProjectID=projectTable,
                Content=Database.sanitize(
                    File.getContent(self.frameworkParams["analyzerPath"])),
                PluginName=Database.sanitize(
                    self.cfg["Workflow"]["Analyzer"]["Plugin"]),
                PluginMethod=Database.sanitize(
                    self.cfg["Workflow"]["Analyzer"]["Method"]),
                Plugin=self.cfg["Workflow"]["Analyzer"])

            content = Database.sanitize(
                File.getContent(self.frameworkParams["translatorPath"]))
            translatorTable = Database.Table.Translator(
                ProjectID=projectTable,
                Content=content,
                ContentParsed=Result.parseTranslatorContent(content),
                PluginName=Database.sanitize(
                    self.cfg["Workflow"]["Translator"]["Plugin"]),
                PluginMethod=Database.sanitize(
                    self.cfg["Workflow"]["Translator"]["Method"]),
                Plugin=self.cfg["Workflow"]["Translator"])

            outputTable = Database.Table.Output(
                ProjectID=projectTable,
                Content=Database.sanitize(
                    File.getContent(self.frameworkParams["outputPath"])),
                Target=Database.sanitize(
                    self.cfg["Workflow"]["Output"]["Target"]),
                PluginName=Database.sanitize(
                    self.cfg["Workflow"]["Output"]["Plugin"]),
                PluginMethod=Database.sanitize(
                    self.cfg["Workflow"]["Output"]["Method"]),
                Plugin=self.cfg["Workflow"]["Output"])

        Database.disconnect()
コード例 #5
0
ファイル: Cocoscats.py プロジェクト: johnlwhiteman/CoCoScatS
 def runAnalyzer(self):
     content = self.__callPluginMethod("Analyzer",
                                       self.getWorkflowPlugin("Analyzer"),
                                       self.frameworkParams)
     return File.getContent(self.frameworkParams["analyzerPath"])
コード例 #6
0
 def runOutputUsingLocalFile(self):
     rawContent = File.getContent(self.getWorkflowSource())
     content = self.__parseContentForOutputSRT(rawContent)
     self.setOutputContent(content)
     return content
コード例 #7
0
 def runInputUsingLocalFile(self):
     target = self.getWorkflowSource()
     rawContent = File.getContent(target)
     return self.__parseContentForInputSRT(rawContent)
コード例 #8
0
 def getDownloadedCaptions(self):
     return File.getContent(self.__DOWNLOADED_PATH)
コード例 #9
0
 def verifyPasswordByFile(password, path):
     return Security.verifyPassword(
         password,
         File.getContent(path, asJson=True)["Password"])
コード例 #10
0
 def getSubresourceIntegrityHash(path):
     content = File.getContent(path)
     hash = hashlib.sha512(content.encode("utf-8")).digest()
     return "sha512-{}".format(base64.b64encode(hash).decode())
コード例 #11
0
 def getVaultContent(self, name, asJson=False):
     path = "{0}/{1}".format(Framework.getVaultDir(), name)
     return File.getContent(path, asJson)
コード例 #12
0
 def __getContent(self, inputType):
     return File.getContent(self.__frameworkParams[inputType])