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 makeShortcut(self): if systemTools.isWindows() and self.createShortcut: try: if self.openConsole: console = "--console" else: console = "" target = self.installPath + "\\OpenOrange.exe" #NEW Method, because winshell throws an error. desktop = shell.SHGetFolderPath( 0, (shellcon.CSIDL_DESKTOP, shellcon.CSIDL_COMMON_DESKTOPDIRECTORY)[0], None, 0) pythoncom.CoInitialize() windowsScript = Dispatch("wscript.shell") shortcut = windowsScript.CreateShortcut(desktop + '\\OpenOrange.lnk') shortcut.TargetPath = target shortcut.Arguments = console shortcut.Save() functions.logging.debug(tr('Shortcut was Created')) print(tr('Shortcut was Created')) self.finalReportAppend(tr('Shortcut was Created')) except: functions.logging.debug(tr('Cannot Create Shortcut')) print(tr('Cannot Create Shortcut')) self.finalReportAppend(tr('Cannot Create Shortcut'))
def loadConfig(self): if systemTools.isWindows(): svnclientPath = "svnclient\svn.exe" installRoute = "." osCondition = False currentOS = "/OIWindows" if systemTools.isLinux(): svnclientPath = "svn" installRoute = "." osCondition = True currentOS = "/OILinux" #is it Ubuntu try: if systemTools.osName().index('SUSE'): currentOS = "/OISuse" except: pass svnPath = 'oitest' svnRemoteClient = 'svn://svn.openorange.com/' svnUser = '******' svnPwd = 'oi' return { 'svnPath': svnPath, 'svnRemoteClient': svnRemoteClient, 'svnUser': svnUser, 'svnPwd': svnPwd, 'svnclientPath': svnclientPath, 'installRoute': installRoute, 'osCondition': osCondition, 'currentOS': currentOS }
def checkout(self, moduleNamePath, revision, svnPath, installRoute, objInstaller): self.setSvnCLientPath() if (moduleNamePath): if (systemTools.isWindows()): moduleNamePath = moduleNamePath.replace("/", "\\") installRoute += '\\' + moduleNamePath #installRoute.replace("\\", "/") if (systemTools.isLinux()): installRoute += '/' + moduleNamePath print(tr("Route of install: ") + "{}".format(installRoute)) logFiles = (self.logSVNFileOut, self.logSVNFileErr) #CleanUp construction = (self.svnclientPath + ' --no-auth-cache --non-interactive cleanup ' + '"' + installRoute + '"') thread = installThread.installThread(construction, logFiles, self.semaphore, 0, objInstaller) thread.start() if (revision == 0 or revision == '0' or revision == None or revision == '' or revision == 'NULL'): revision = 'HEAD' #Check revision and go to Head if is null, zero, None or empty construction = (self.svnclientPath + ' checkout' + ' --no-auth-cache --force' + ' -r ' + revision + ' --username ' + self.svnUserName + ' --password ' + self.svnPassword + ' ' + self.svnRemoteClient + svnPath + ' ' + '"' + installRoute + '"') thread = installThread.installThread(construction, logFiles, self.semaphore, moduleNamePath, objInstaller) thread.start()
def changeInstallDirectory(self, widget): if systemTools.isWindows(): newPath = self.folderChooser.get_uri().split('file:///') else: newPath = self.folderChooser.get_uri().split('file://') newPath = newPath[1] #Discard first split newPath = newPath.replace("%20", " ") #Fix spaces self.installation.pathThroughWidget = True self.installation.setInstallPath(newPath) self.installation.pathThroughWidget = False self.installPathLabel.set_text( tr("Install Path: ") + self.installation.getInstallPath())
def test_checkSystemTools(self): check = False if systemTools.isWindows() == True: check = True self.assertEqual( sys.platform.startswith("win"), True, "OI.SystemTool for check OS is different to sys method") if systemTools.isLinux() == True: check = True self.assertEqual( sys.platform.startswith("linux"), True, "OI.SystemTool for check OS is different to sys method")
def createInitExtra(self): self.msgBuffer = tr("Making __init__.py") if (systemTools.isWindows()): extraDirPath = self.installPath + '\\extra' if ( path.isdir(extraDirPath) ): #Create __init__.py if exist extra folder and the file is not there if (not path.exists(extraDirPath + '\\__init__.py')): open(extraDirPath + '\\__init__.py', 'w') if (systemTools.isLinux()): if ( path.isdir(self.installPath + '/extra') ): #Create __init__.py if exist extra folder and the file is not there if (not path.exists(self.installPath + '/extra/__init__.py')): open(self.installPath + '/extra/__init__.py', 'w') self.finalReportAppend("Make __init__.py for extra")
def checkCredentials(self): import shlex #Set testing self.setSvnCLientPath() folderCheck = 'checkSVNCred' revision = '0' svnPath = 'repo' installRoute = folderCheck if systemTools.isWindows(): osCondition = False if systemTools.isLinux(): osCondition = True #End Set construction = (self.svnclientPath + ' --no-auth-cache --non-interactive cleanup ' + '"' + installRoute + '"') subprocess.Popen(construction, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=osCondition) construction = (self.svnclientPath + ' checkout' + ' --no-auth-cache --force' + ' -r ' + revision + ' --username ' + self.svnUserName + ' --password ' + self.svnPassword + ' ' + self.svnRemoteClient + svnPath + ' ' + '"' + installRoute + '"') testingCheckout = subprocess.Popen(construction, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=osCondition) timeout = 0 outs, errs = '', '' exit = False while timeout < 10 and exit == False: print construction if testingCheckout.poll() == None: time.sleep(0.5) timeout += 1 print(tr("Process haven't finished yet...")) else: exit = True try: if systemTools.isWindows(): outs, errs = testingCheckout.communicate() testingCheckout.terminate() if systemTools.isLinux(): outs, errs = testingCheckout.communicate() testingCheckout.terminate() except: functions.logging.debug( tr("OrangeInstaller cannot validate SVN Username and Password") ) print outs, errs if errs: functions.logging.debug(functions.processSVNout(errs)) return functions.processSVNout(errs) else: return True
def checkSystemTools(self): if systemTools.isWindows(): print "Is windows" if systemTools.isLinux(): print "Is Linux"