Пример #1
0
    def run(cocoscats):
        Web.cocoscats = cocoscats
        Web.useHttps = Text.isTrue(Web.cocoscats.cfg["Web"]["UseHttps"])
        Web.useAuthentication = Text.isTrue(
            Web.cocoscats.cfg["Web"]["UseAuthentication"])
        sessionOptions = {
            "session.type": "memory",
            "session.cookie_expires": 300,
            "session.auto": True
        }

        if Text.isTrue(Web.cocoscats.cfg["Web"]["Debug"]):
            WebSecurity.getSubresourceIntegrityHashes(True)

        Web.setupPassword()
        Web.setupCertificate()

        if Web.useHttps:
            Web.scheme = "https"
            Web.url = "{0}://{1}:{2}/".format(Web.scheme,
                                              Web.cocoscats.cfg["Web"]["Host"],
                                              Web.cocoscats.cfg["Web"]["Port"])
            server = WebSecurity(host=Web.cocoscats.cfg["Web"]["Host"],
                                 port=Web.cocoscats.cfg["Web"]["Port"])

            threading.Thread(target=bottle.run,
                             kwargs=dict(
                                 app=SessionMiddleware(bottle.app(),
                                                       sessionOptions),
                                 debug=Text.toTrueOrFalse(
                                     Web.cocoscats.cfg["Web"]["Debug"]),
                                 reloader=Text.toTrueOrFalse(
                                     Web.cocoscats.cfg["Web"]["Reloader"]),
                                 server=server)).start()
        else:
            Web.scheme = "http"
            Web.url = "{0}://{1}:{2}/".format(Web.scheme,
                                              Web.cocoscats.cfg["Web"]["Host"],
                                              Web.cocoscats.cfg["Web"]["Port"])
            threading.Thread(
                target=bottle.run,
                kwargs=dict(
                    app=SessionMiddleware(bottle.app(), sessionOptions),
                    debug=Text.toTrueOrFalse(
                        Web.cocoscats.cfg["Web"]["Debug"]),
                    host=Web.cocoscats.cfg["Web"]["Host"],
                    port=Web.cocoscats.cfg["Web"]["Port"],
                    reloader=Text.toTrueOrFalse(
                        Web.cocoscats.cfg["Web"]["Reloader"]))).start()
        Msg.flush()
        for client in Web.cocoscats.cfg["Web"]["Browser"]:
            if Text.isNothing(client) or client.lower() == "default":
                if webbrowser.open(Web.url):
                    break
            else:
                if webbrowser.get(client).open(Web.url):
                    break
Пример #2
0
    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()
Пример #3
0
 def getPluginParamValueAsTrueOrFalse(self, name):
     return Text.toTrueOrFalse(self.getPluginParamValue(name))