def __run(api, *args): WebApi.checkAuthentication() Database.connect() argCnt = len(args) if argCnt < 1: result = api() elif argCnt == 1: result = api(args[0]) Database.disconnect() bottle.response.content_type = "application/json" return json.dumps(result)
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()
def __exists(projectID): WebApi.checkAuthentication() Database.connect() result = Database.checkProjectExists(projectID) Database.disconnect() return result