def setSvnCLientPath(self): if (systemTools.isWindows()): self.svnclientPath = os.path.abspath("svnclient/svn.exe") self.svnclientPath.replace("\\", "/") if (systemTools.isLinux()): self.svnclientPath = 'svn' if (not systemTools.isWindows() and not systemTools.isLinux()): functions.logging.debug( 'Error: System not recognized >> {}'.format(currentSystem)) functions.exitProgram(1) #End with Err
def getDataSearch(self, table, field, key, columns): try: self.stablishConnection() columnsBuild = '' for a in range(len(columns)): columnsBuild += columns[a] sql = "SELECT {} FROM {}.{} WHERE {} LIKE '%{}%'".format( columnsBuild, self.basename, table, field, key) cursor = self.connector.cursor() cursor.execute(sql) data = [] for a in cursor.fetchall(): data.append(a) return data except: functions.logging.debug("Query ERROR") functions.exitProgram(1)
def getData(self, table, id, columns): try: self.stablishConnection() columnsBuild = '' for a in range(len(columns)): columnsBuild += columns[a] sql = "SELECT {} FROM {}.{} WHERE idcompany = {}".format( columnsBuild, self.basename, table, id) cursor = self.connector.cursor() cursor.execute(sql) data = [] for a in cursor.fetchall(): data.append(a) return data except Exception, e: functions.logging.debug("Query ERROR %s" % e) functions.exitProgram(1)
def userFinished(self, widget): functions.exitProgram(0) #Installation Finished sys.exit()
def userExit(self, widget): functions.exitProgram(2) #End by user sys.exit()
def consoleApplication(): functions.createInstallationLog() functions.logging.debug(tr("Program started")) msg = tr("OrangeInstaller for OpenOrange Software.\n") msg += tr("Type 'exit' to cancel") print(msg) dataConnect = dataConnection.dataConnection() installation = Installer.Installer() dataConnect.testConnection() invalidCode = False validCode = False while not validCode: imputTest = raw_input(tr("Company Code: ")) if (imputTest == tr('exit')): print(tr("CANCEL INSTALLATION BY USER")) functions.logging.debug(tr("CANCEL INSTALLATION BY USER")) functions.exitProgram(2) else: if len(imputTest) == 8: codeToSearch = dataConnect.getDataSearch( 'OnlyValidCodes', 'companykey', imputTest, "*") if codeToSearch: validCode = True break else: invalidCode = True else: invalidCode = True if invalidCode: print tr("Invalid company code, try again.") else: break selection = None while codeToSearch[0][0] == "0pen0r4n": imputTest = raw_input(tr("Search Company: ")) if (imputTest == tr('exit')): print(tr("CANCEL INSTALLATION BY USER")) functions.logging.debug(tr("CANCEL INSTALLATION BY USER")) functions.exitProgram(2) resultOfSearch = dataConnect.getDataSearch('company', 'name', imputTest, "*") if (len(resultOfSearch) == 0): print(tr("Company not Found, try again")) if (len(resultOfSearch) > 1): print(tr("Too many results, choose one from this list:")) for i in range(len(resultOfSearch)): if (i > 9): print( tr("Some result not shown in screen." + tr(" Type '999' to search again"))) break print('{}: {}'.format(i, resultOfSearch[i][1])) rta = int(raw_input(tr("Please, select one: "))) if (rta != 999): selection = resultOfSearch[rta] break if (len(resultOfSearch) == 1): selection = resultOfSearch[0] break if not selection: installation.setSvnControlLogon(codeToSearch[0][1], codeToSearch[0][2]) selection = dataConnect.getDataSearch('company', 'idcompany', codeToSearch[0][3], "*")[0] installation.initialization( selection[0]) #'selection[0]' is value companyId from table 'Company'\ if selection[1]: installation.setInstallPath(installation.getInstallPath(), selection[1]) print( tr("Default directory for installation: ") + "{}\t".format(installation.getInstallPath()) + tr("[If you wish write route of installation type: 0]")) print(tr("Ready to install OpenOrange for ") + "{}".format(selection[1])) rta = raw_input( tr("Are you sure? (Enter to continue, type 'exit' to cancel): ")) if (rta == 0 or rta == '0'): print( tr("\t***\tATTENTION: You should write path well or the installation may not work\t***" )) newPath = raw_input( tr("Write new path, for examples type 'help' or type 'cancel' for back to default directory:\n " )) if (newPath == tr("help")): msg = 'OS not recognized, help is not available' if (installation.getCurrentSystem() == 'Linux'): msg = tr( "Examples for Linux\n\tThe installation has to be over home/user, for example: home/user/ExampleFolder/Company" ) else: msg = tr( "Examples for Windows\n\tFull path: C:\ExampleFolder\Orange Installer\Company" ) print(msg) newPath = raw_input( tr("Write new path, or type 'cancel' for back to default directory: " )) if (newPath != tr("cancel")): installation.setInstallPath(newPath) else: print( tr("Default directory for installation: ") + "{}".format(installation.getInstallPath())) if (rta == tr("exit")): print(tr("CANCEL INSTALLATION BY USER")) functions.logging.debug(tr("CANCEL INSTALLATION BY USER")) functions.exitProgram(2) else: functions.logging.debug( tr("Ready to install OpenOrange for ") + "{}".format(selection[1])) installation.useDaemon = False installation.startInstall()
def userInterface(): functions.createInstallationLog() functions.logging.debug(tr("Program started")) window.userWindow() Gtk.main() functions.exitProgram(2)