示例#1
0
 def __getOSImageByLocation(self, imageLocation):
     self.logger.debug("Get image from " + imageLocation)
     if imageLocation==None or imageLocation=="":
         return
     elif imageLocation.startswith('ftp://'):
         from FTPTask import childTask
         task = childTask('task')
         if re.match('.*@.*', imageLocation):
             host = re.sub(r'^.*@([^/]*)/.*', r'\1', imageLocation)
             task.addPara('Host', host)
             username = re.sub(r'^ftp://(.*):.*@([^/]*)/.*', r'\1', imageLocation)
             password = re.sub(r'^.*:(.*)@([^/]*)/.*', r'\1', imageLocation)
             task.addPara('User', username)
             task.addPara('Passwd', password)
         else:
             host = re.sub(r'^ftp://([^/]*)/.*', r'\1', imageLocation)
             task.addPara('Host', host)
             task.addPara('User', self._commonDomain + '\\' + self._commonUser)
             task.addPara('Passwd', self._commonPassword)
         
         imageLocation = re.sub(r'^[^/]*(/.*)', r'\1', imageLocation[6:])
         if re.match('.*/$', imageLocation):
             #Delete ftp://                
             task.addPara('FolderPath', imageLocation)
         else:
             task.addPara('FilePath', imageLocation)
             
         task.addPara('Repository', self.imageRepository) 
         task.run()
         self.__downloadedFileList = task.getDownloadList()
     elif imageLocation.startswith('file://') or imageLocation.startswith('file:\\'):            
         fullPath = imageLocation[7:]
         if os.path.exists(fullPath) and os.path.isdir(fullPath):
             self.__downloadedFileList = self._getFileList(fullPath)
         elif os.path.exists(fullPath) and os.path.isfile(fullPath):
             self.__downloadedFileList = [fullPath]
         else:
             self.__getOSImageByLocation(fullPath)
     else:
         from SambaTask import childTask
         task = childTask('task')
         if not 'sambaDomain' in self.parameter or \
             not 'sambaUser' in self.parameter or \
             not 'sambaPsw' in self.parameter:
             task.addPara('sambaDomain', self._commonDomain)
             task.addPara('sambaUser', self._commonUser)
             task.addPara('sambaPsw', self._commonPassword)
         else:
             task.addPara('sambaDomain', self.parameter['sambaDomain'])
             task.addPara('sambaUser', self.parameter['sambaUser'])
             task.addPara('sambaPsw', self.parameter['sambaPsw'])
             
         OSImagelocationForSamba = re.sub(r'^/*(.*)', r'\1', imageLocation.replace("\\", "/"))
             
         task.addPara('FolderPath', OSImagelocationForSamba)
         task.targetFolder = self.imageRepository 
         task.run()
         self.__downloadedFileList = task.getDownloadList()
         return
    def __getAppPackage(self):
        self.logger.debug('get Package')
        #Attention: For OSImage, here must be FolderPath other than FilePath
        
        #task.addPara('FolderPath', self.parameter['APPPacklocation'])
        #FIXME
        if self.parameter['installerType'] == 'RAW':
            appLocation = self.parameter['APPPacklocation']
            self.downloadFolder = os.path.join(self.downloadFolder, 'BridgeRawBuild')
            self.logger.debug('download raw build from: %s', appLocation)
        elif 'APPPacklocation' in self.parameter:
            appLocation = self.parameter['APPPacklocation']
            self.downloadFolder = os.path.join(self.downloadFolder, 'Build')
            self.logger.debug('download raw build from: %s', appLocation)
        else:
            latestBuild = self._dbutil.getLatestBuild(
                                self.parameter['appName'],
                                self.parameter['appVer'],
                                self.platform,
                                self.parameter['appLang'],
                                self.parameter['appCertLevel'])
            if latestBuild==None:
                return None
            
            latestBuildLocation = latestBuild[1]                        
            
            appLocation = re.sub(r'^/*(.*)', r'\1', latestBuildLocation.replace("\\", "/"))
            self.downloadFolder = os.path.join(self.downloadFolder, self.parameter['appName']+self.parameter['appVer'])
            
        #set build folder path
        self.logger.debug('Build Location is %s', appLocation)
        
        if re.match('^ftp:', appLocation.lower()):
            from FTPTask import childTask
            task = childTask('task')
            host = re.sub(r'^ftp://([^/]*)/.*', r'\1', appLocation)
            task.addPara('Host', host)
            task.addPara('User', self._commonDomain + '\\' + self._commonUser)
            task.addPara('Passwd', self._commonPassword)
            
            appLocation = re.sub(r'^[^/]*(/.*)', r'\1', appLocation[6:])
            if re.match('.*/$', appLocation):
                #Delete ftp://                
                task.addPara('FolderPath', appLocation)
            else:
                task.addPara('FilePath', appLocation)
        else:
            from SambaTask import childTask
            task = childTask('task')
            task.addPara('sambaDomain', self._commonDomain)
            task.addPara('sambaUser', self._commonUser)
            task.addPara('sambaPsw', self._commonPassword)

            if 'appLang' in self.parameter:
                task.addPara('appLang', self.parameter['appLang'])
            task.addPara('FolderPath', appLocation)
        
        #Change downloadFolder to avoid collision with other Product

        task.addPara('Repository', self.downloadFolder)

        task.run()
        return task.getDownloadList()
                try: 
                    self.logger.info('try to access x32 adobe install path info in registy')
                    key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Wow6432Node\Adobe\Photoshop\12.0\ApplicationPath', 0, _winreg.KEY_READ)            
                except Exception, e:            
                        self.logger.error(' adobe photoshop cs5 was not installed in this machine, please check')
                        key = None
                        return
                
            installPath, typeId = _winreg.QueryValueEx(key,'InstallPath')        
            _winreg.CloseKey(key)
        return installPath
        
        
##################This section is mainly for debug -- Begin #############################
if __name__ == '__main__':    
#    o=childTask('PhotoshopAppInstall', 1)
    o=childTask('PhotoshopAppInstall', 800)
    o.run()
#    filePath = o._searchFile("C:\Program Files\Adobe\Adobe Bridge CS4", "application.xml")
    '''
    if 'nt' in os.name:
        o.runWin()        
    elif 'mac' in os.name: 
        o.runMac()
    else:
        print("don't support this os")
   '''


##################This section is mainly for debug -- End #############################
示例#4
0
 def __getLabPETool(self):
     '''
     This Function is for Windows Only
     Hardcode temporarily
     '''
     LabPEToolName = self._dbutil.getAppInfo('labpe_tool_name').strip()
     if LabPEToolName==None:
         LabPEToolName = "LabPE_4.2_Ramdisk.exe"
         
     self.__LabPEToolPath = os.path.join(self.getToolsDir(), LabPEToolName)
     if os.path.exists(self.__LabPEToolPath):
         return
     
     if globalProperty.isMachineOutOfChina():
         labPEToolLocation = self._dbutil.getAppInfo('labpe_us').strip()
     else:
         labPEToolLocation = self._dbutil.getAppInfo('labpe_cn').strip()
     if labPEToolLocation==None or labPEToolLocation=="":
         raise "Donwload LabPE Tool Failed"
     elif labPEToolLocation.startswith('ftp://'):
         labPEToolLocation += '/' + LabPEToolName
         fullPath = labPEToolLocation[6:]
         parts = fullPath.split('/', 1)
         
         (host, location) = parts
         from FTPTask import childTask
         task = childTask('task')
         
         #FIXME: Modified by Jacky
         task.addPara('Host', host)
         task.addPara('User', self._commonDomain + "\\" + self._commonUser)
         task.addPara('Passwd', self._commonPassword)
         
         if not location.startswith('/'):
             location = '/' + location
     
         #Attention: For OSImage, here must be FolderPath other than FilePath
         task.addPara('Repository', self.getToolsDir()) 
         task.addPara('FilePath', location)
         task.addPara('OneFile', 'True')
         task.run()
     else:
         labPEToolLocation += '/' + LabPEToolName
         from SambaTask import childTask
         task = childTask('task')
         if not 'sambaDomain' in self.parameter or \
             not 'sambaUser' in self.parameter or \
             not 'sambaPsw' in self.parameter:
             task.addPara('sambaDomain', self._commonDomain)
             task.addPara('sambaUser', self._commonUser)
             task.addPara('sambaPsw', self._commonPassword)
         else:
             task.addPara('sambaDomain', self.parameter['sambaDomain'])
             task.addPara('sambaUser', self.parameter['sambaUser'])
             task.addPara('sambaPsw', self.parameter['sambaPsw'])
             
         locationForSamba = re.sub(r'^/*(.*)', r'\1', labPEToolLocation.replace("\\", "/"))
             
         task.addPara('FilePath', locationForSamba)
         task.targetFolder = self.getToolsDir() 
         task.run()
示例#5
0
            if dev:
                return (diskId, partition)
            time.sleep(2)
            
    def getTaskNote(self): 
        if "OSType" in self.parameter:
            self.note = "OS:" + self.parameter['OSType']
        if "OSEdition" in self.parameter:
            self.note += ",OSEdition:" + self.parameter['OSEdition']
        if "InstalledSoftware" in self.parameter:
            self.note += ",InstalledSoftware:" + self.parameter['InstalledSoftware']
        return self.note

##################This section is mainly for debug -- Begin #############################
if __name__ == '__main__':    
#    ro=childTask('RestoreOS', 1)
#    ro.addPara("OSType", "Leopard")
#    ro.addPara("OSEdition", "10.5.6_Fre")
#    ro.addPara("targetPartition1", "Main")
#    ro.addPara("targetPartition2", "Daily")
#    ro.addPara("OSModel", "imac")
#    ro.run()
    ro=childTask('RestoreOS', 1)
    ro.addPara("OSEdition", "")
    ro.addPara("OSImagelocation", "file:\\\\d:\\test.gho")
    ro.addPara("OSType", "")
    ro.addPara("sourceOS", "windows")
    ro.run()
    #ro.getLabPETool()
##################This section is mainly for debug -- End #############################