Beispiel #1
0
    def __runDemo():
        if not Cli.cocoscats.isWorkflowDemoEnabled() or \
            Cli.cocoscats.getWorkflowDemoPluginCount() < 1:
            return
        Msg.show("Execute: Demo Stage")
        choices = Cli.cocoscats.getWorkflowDemoPluginChoices()
        menu = """-----------------------------------------------
Please make a selection to run demo or 'x' to exit.\n"""
        i = 1
        for choice in choices:
            menu = """{0}
[{1}]: {2}::{3}()""".format(menu, i, choice["Name"], choice["Method"])
            i += 1
        menu = """{0}
[x]: Exit
""".format(menu)
        errMsg = "Error: Valid options are: [1-{0}]".format(i - 1)
        while True:
            Msg.showRaw(menu)
            response = input()
            if response == "x" or response == "X":
                break
            if not Text.isInt(response):
                Msg.showRaw(errMsg)
                continue
            response = int(response)
            if response < 1 or response >= i:
                Msg.showRaw(errMsg)
                continue
            j = response - 1
            ret = Cli.cocoscats.runDemo(choices[j]["Name"],
                                        choices[j]["Method"])
            if ret:
                Msg.showWarning("Demo returned an error")
Beispiel #2
0
 def show(self):
     if self.cfg is None or self.cfgPath is None:
         Msg.showWarning(
             "No information found for cfg file. Did you load it?")
         return
     pprint(self.cfg)
     Msg.flush()
Beispiel #3
0
 def showPluginFiles(pluginDirName):
     print("\n[{0}]".format(pluginDirName))
     plugins = Framework.getPluginFiles(pluginDirName)
     if plugins is None:
         Msg.showWarning("Can't find an plugins")
         return
     for plugin in plugins:
         print("  {0}".format(plugin["Name"]))
Beispiel #4
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()