Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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
     }
Exemplo n.º 3
0
    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()
Exemplo n.º 4
0
    def run(self):
        self.objInstaller.pushCheckoutStacks()
        self.semaphore.acquire()
        if (self.moduleName != 0):
            msg = str( ">> " + tr("Installing: ") + self.moduleName)
            self.objInstaller.finalReportAppend(msg)
            if (self.moduleName == ''):
                msg = str( ">> " + tr("Installing: ") + tr("Base and Standard"))
                self.objInstaller.finalReportAppend(msg)
            print (msg)
            functions.logging.debug(msg)
            self.objInstaller.setMsgBuffer(msg)
        functions.logging.debug(tr("Send to SVN: {}").format(self.construction))
        print(self.construction)

        if systemTools.isLinux():
            report = subprocess.call(self.construction, stdout=self.logFiles[0], stderr=self.logFiles[1], shell=True)
        else:
            report = subprocess.call(self.construction, stdout=self.logFiles[0], stderr=self.logFiles[1], startupinfo=self.subprocessInfo)

        functions.logging.debug(tr("SVN Response: {}").format(tr("Process finished, check svn out for info")))
        if (self.moduleName != 0):
            self.objInstaller.finalReportAppend(msg + " >> OK")
        self.semaphore.release()
    
        self.objInstaller.popCheckoutStacks() #pop Stack of threads (if is empty, all checkouts is over)
        if (self.objInstaller.getCheckoutStacks() == 0): #If all checkouts finished...
            self.objInstaller.createInitExtra() #...Make __init__.py in extra folder
            self.objInstaller.makeSetting() #...Make settings.xml
            self.objInstaller.makeShortcut() # make shortcut, windows only
Exemplo n.º 5
0
 def setInstallPath(self, path, companyName=""):
     if self.lastCompanyFolderSetted <> companyName:
         if self.lastCompanyFolderSetted:  # Clean last companyName from Path
             if systemTools.isLinux():
                 path = path.replace("/" + self.lastCompanyFolderSetted, "")
             else:
                 path = path.replace("\\" + self.lastCompanyFolderSetted,
                                     "")
     if self.pathThroughWidget:
         self.installPath = path
     else:
         if not self.disableLastFolderAsCompanyName and companyName:
             if systemTools.isLinux():
                 self.installPath = path + "/" + companyName
             else:
                 self.installPath = path + "\\" + companyName
             self.lastCompanyFolderSetted = companyName
         else:
             self.installPath = path
Exemplo n.º 6
0
 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")
Exemplo n.º 7
0
 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")
Exemplo n.º 8
0
    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
Exemplo n.º 9
0
 def checkSystemTools(self):
     if systemTools.isWindows():
         print "Is windows"
     if systemTools.isLinux():
         print "Is Linux"