Exemplo n.º 1
0
 def getQMSGate(self):
     seedLocation = None
     if globalProperty.isMachineOutOfChina():
         seedLocation = self._dbutil.getAppInfo('seed_us')
     else:
         seedLocation = self._dbutil.getAppInfo('seed_cn')
     if seedLocation==None:
         raise "Get Seed Location failure"
     task = SambaTask.childTask('getQMSGate', 1)
     task.addPara('sambaDomain', unicode(self._commonDomain, 'utf-8'))
     task.addPara('sambaUser', unicode(self._commonUser, 'utf-8'))
     task.addPara('sambaPsw', unicode(self._commonPassword, 'utf-8'))
     #task.targetFolder = dest
     task.addPara('Repository', self.QMSGateParent) 
 
     task.addPara('FolderPath', unicode(seedLocation + "/" + self.QMSGateName, 'utf-8'))
     task.run()
     
     if not os.path.exists(self.QMSGateLocation):
         raise "Get QMSGate File fail"
     
     if os.name == 'posix':
         cmd = "sudo chmod +x %s" %self.QMSGateLocation;
         self.logger.debug(cmd)
         os.system(cmd)        
Exemplo n.º 2
0
 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:
         buildNum = "unknown"
         from CodexTask import childTask
         task = childTask('codexTask')
         latestBuild = task.getBuild(
                                self.parameter["appName"],
                                self.parameter["appVer"],
                                self.compileTarget, #CompileTarget
                                self.platform,
                                self.parameter["appLang"],
                                self.parameter['appCertLevel'],
                                self.parameter['appSubProduct'])
         if latestBuild==None:
             return None
                 
         latestBuildLocation = latestBuild._location['protocol'] + "://" + \
                               latestBuild._location['server'] + \
                               latestBuild._location['path']
         buildNum = latestBuild._build
         if not globalProperty.isMachineOutOfChina():
             #Support the machine out of China, will download directly                
             localLatestBuild = self._dbutil.getLatestBuild(
                                self.parameter['appName'],
                                self.parameter['appVer'],
                                self.platform,
                                self.parameter['appLang'],
                                self.parameter['appCertLevel'],
                                self.parameter['appSubProduct'])
                 
             if localLatestBuild==None:
                 return None
                 
             localLatestBuildLocation = localLatestBuild[1]
             localBuildNum = localLatestBuild[0]
                 
             if localBuildNum==buildNum:
                 latestBuildLocation = localLatestBuildLocation
             
         appLocation = re.sub(r'^/*(.*)', r'\1', latestBuildLocation.replace("\\", "/"))
         self.note += self.parameter["appName"] + ":" + self.parameter['appVer'] + "(" + buildNum + ")" 
         self.buildNum = buildNum
             
     #set build folder path
     self.logger.debug('Build Location is %s', appLocation)
     return self._downloadAppPackage(appLocation)
Exemplo n.º 3
0
    def _sendReport(self):
        # Generate Report
        from PsPSFReporter import childTask

        psfReporter = childTask("PSFReporter", self.priority + 1)
        psfReporter.addPara("PSFHome", self.psfHome)
        if self.parameter.has_key("FeatureOwner"):
            psfReporter.addPara("FeatureOwner", self.parameter["FeatureOwner"])
        else:
            psfReporter.addPara("FeatureOwner", "Unknown")
        psfReporter.addPara("ProductVersion", self.productVersion)
        psfReporter.run()
        reportFile = psfReporter.getHtmlReport()

        # Send Report
        from HtmlEmailUtil import childTask

        htmlEmailUtil = childTask("HtmlEmailUtil", self.priority + 2)

        if self.parameter.has_key("From"):
            htmlEmailUtil.addPara("From", self.parameter["From"])
        else:
            htmlEmailUtil.addPara("From", "*****@*****.**")

        user = globalProperty.getUser()
        if user == None:
            defaultTo = "*****@*****.**"
        else:
            defaultTo = "*****@*****.**" % user

        if self.parameter.has_key("To"):
            htmlEmailUtil.addPara("To", self.parameter["To"])
        else:
            htmlEmailUtil.addPara("To", defaultTo)

        if globalProperty.isMachineOutOfChina():
            htmlEmailUtil.addPara("SMTPServer", self._dbutil.getAppInfo("email_server_us"))
        else:
            htmlEmailUtil.addPara("SMTPServer", self._dbutil.getAppInfo("email_server_cn"))
        if self.parameter.has_key("Subject"):
            subject = self.parameter["Subject"]
        elif self.parameter.has_key("SuiteSelected"):
            subject = "PSF Report: Photoshop 12.0 Results"
        else:
            subject = "PSF Report: Photoshop 12.0 Results"
        subject = " [%s][%s][%s][%s]%s[%s](%s)" % (
            self.productVersion,
            psfReporter.getPassRate(),
            globalProperty.getSysInfo().locale,
            globalProperty.getSysInfo().os,
            subject,
            self.buildNum,
            psfReporter.getMachine(),
        )
        htmlEmailUtil.addPara("Subject", subject)
        htmlEmailUtil.addPara("ReportFile", reportFile)
        htmlEmailUtil.run()
Exemplo n.º 4
0
    def getQMSGate(self):
        seedLocation = None
        if globalProperty.isMachineOutOfChina():
            seedLocation = self._dbutil.getAppInfo("seed_us")
        else:
            seedLocation = self._dbutil.getAppInfo("seed_cn")
        if seedLocation == None:
            raise "Get Seed Location failure"

        if re.match("^ftp:", seedLocation.lower()):
            task = FTPTask.childTask("task")
            if re.match(".*@.*", seedLocation):
                host = re.sub(r"^.*@([^/]*)/.*", r"\1", seedLocation)
                task.addPara("Host", host)
                username = re.sub(r"^ftp://(.*):.*@([^/]*)/.*", r"\1", seedLocation)
                password = re.sub(r"^.*:(.*)@([^/]*)/.*", r"\1", seedLocation)
                task.addPara("User", username)
                task.addPara("Passwd", password)
            else:
                host = re.sub(r"^ftp://([^/]*)/.*", r"\1", seedLocation)
                task.addPara("Host", host)
                task.addPara("User", self._commonDomain + "\\" + self._commonUser)
                task.addPara("Passwd", self._commonPassword)

            seedLocation = re.sub(r"^[^/]*(/.*)", r"\1", seedLocation[6:])
            if re.match(".*/$", seedLocation):
                # Delete ftp://
                task.addPara("FilePath", seedLocation + self.QMSGateName)
            else:
                task.addPara("FilePath", seedLocation + "/" + self.QMSGateName)
        else:
            task = SambaTask.childTask("getQMSGate", 1)
            task.addPara("sambaDomain", unicode(self._commonDomain, "utf-8"))
            task.addPara("sambaUser", unicode(self._commonUser, "utf-8"))
            task.addPara("sambaPsw", unicode(self._commonPassword, "utf-8"))
            # task.targetFolder = dest

            task.addPara("FolderPath", unicode(seedLocation + "/" + self.QMSGateName, "utf-8"))

        task.addPara("Repository", self.QMSGateParent)
        task.run()

        if not os.path.exists(self.QMSGateLocation):
            raise "Get QMSGate File fail"

        if os.name == "posix":
            cmd = "sudo chmod +x %s" % self.QMSGateLocation
            self.logger.debug(cmd)
            os.system(cmd)
Exemplo n.º 5
0
    def download(self):
        self.logger.info("Start update")
        path = None
        if globalProperty.isMachineOutOfChina():
            path = self._dbutil.getAppInfo("pkg_path_us_staging")
        else:
            path = self._dbutil.getAppInfo("pkg_path_cn_staging")
        dest = os.path.join(os.getcwd(), "..")
        if re.match("^ftp:", path.lower()):
            task = FTPTask.childTask("task")
            if re.match(".*@.*", path):
                host = re.sub(r"^.*@([^/]*)/.*", r"\1", path)
                task.addPara("Host", host)
                username = re.sub(r"^ftp://(.*):.*@([^/]*)/.*", r"\1", path)
                password = re.sub(r"^.*:(.*)@([^/]*)/.*", r"\1", path)
                task.addPara("User", username)
                task.addPara("Passwd", password)
            else:
                host = re.sub(r"^ftp://([^/]*)/.*", r"\1", path)
                task.addPara("Host", host)
                task.addPara("User", self._commonDomain + "\\" + self._commonUser)
                task.addPara("Passwd", self._commonPassword)

            path = re.sub(r"^[^/]*(/.*)", r"\1", path[6:])
            if re.match(".*/$", path):
                # Delete ftp://
                task.addPara("FolderPath", path)
            else:
                task.addPara("FilePath", path)
                task.addPara("pattern", ".*%s.*" % os.path.basename(path))
                task.addPara("FolderPattern", re.sub(r".*/(.*)", r"\1", path))
        else:
            task = SambaTask.childTask("getUpdate", 1)
            task.addPara("sambaDomain", unicode(self._commonDomain, "utf-8"))
            task.addPara("sambaUser", unicode(self._commonUser, "utf-8"))
            task.addPara("sambaPsw", unicode(self._commonPassword, "utf-8"))
            # task.targetFolder = dest

            task.addPara("FolderPath", unicode(path, "utf-8"))

        task.addPara("Repository", dest)
        task.run()
        self.when = datetime.datetime.now()
        self.when += datetime.timedelta(seconds=120)

        globalProperty.updateVersion()
        self._dbutil.finishTask(self.exeId, self, "succeed", "", self.getTaskNote())
        self.reload()
Exemplo n.º 6
0
 def run(self):
     self.logger.info('Start email monitor')
         
     send_from = '*****@*****.**'
     if self.parameter.has_key('From'):
         send_from = self.parameter['From']
     
     user = globalProperty.getUser()
     if user==None:
         defaultTo = '*****@*****.**'
     else:
         defaultTo = '*****@*****.**' % user
         
     """
     if self.parameter.has_key('To'):
         send_to = self.parameter['To'].replace(';', ',').split(',')
     else:
         send_to = defaultTo.split(',')
     """
     send_to = self.parameter['To'] if self.parameter.has_key('To') else defaultTo
     
     if self.exeId==None:
         self.logger.info('No Result could be sent out for monitoring')
         return
     
     reportFile = self.getHtmlReport()
     if reportFile==None or not os.path.exists(reportFile):
         return
     
     #Send Report
     from HtmlEmailUtil import childTask
     htmlEmailUtil = childTask('HtmlEmailUtil', self.priority + 2)
     
     htmlEmailUtil.addPara('From', send_from)
     htmlEmailUtil.addPara('To', send_to)
     
     if globalProperty.isMachineOutOfChina():
         htmlEmailUtil.addPara('SMTPServer', self._dbutil.getAppInfo('email_server_us'))
     else:
         htmlEmailUtil.addPara('SMTPServer', self._dbutil.getAppInfo('email_server_cn'))
     if self.parameter.has_key('Subject'):
         subject = self.parameter['Subject']
     else:
         subject = 'Email Monitor from %s -- %s' % (socket.gethostname(), self._getCurrentTime())
     htmlEmailUtil.addPara('Subject', subject)
     htmlEmailUtil.addPara('ReportFile', reportFile)
     htmlEmailUtil.run()
     """
Exemplo n.º 7
0
    def __init__(self, type, priority):
        super(childTask, self).__init__(type, priority)

        if globalProperty.isMachineOutOfChina():
            self.PSFLocation = self._dbutil.getAppInfo("psf_path_us")
            self.testFilesLocation = self._dbutil.getAppInfo("psf_test_file_us")
        else:
            self.PSFLocation = self._dbutil.getAppInfo("psf_path")
            self.testFilesLocation = self._dbutil.getAppInfo("psf_test_file")

        self.PSFRepository = os.path.join(os.getcwd(), "PSFLocal")

        cwd = os.getcwd()
        if os.name == "posix":
            self.PSFLocalHome = cwd.split("QMSClient")[0]
        elif os.name == "nt":
            self.PSFLocalHome = cwd[0:3]

        self.PSFLogBackUpDir = os.path.join(os.getcwd(), "PSFLogBak")

        self.PSFConfig = "psConfig.js"

        self.launcherFileName = "MyPsfLauncher"

        self.launcherFilePath = None

        self.buildNum = ""

        self.localTestFileLocation = ""

        self.localConfigFileLocation = ""

        self.downloadFileFlag = "1"

        self.setupFileFlag = "Yes"

        self.userHome = globalProperty.getUserHome()

        if os.name == "posix":
            self.platform = "osx10"

            # Need to add this to enable access for assistive devices
            self.runCommand("sudo touch /private/var/db/.AccessibilityAPIEnabled")
        if os.name == "nt":
            self.platform = "win32"

        return
Exemplo n.º 8
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()
Exemplo n.º 9
0
    def __prepareLauncher(self):
        if "buildNum" in self.parameter and self.parameter["buildNum"] != None:
            self.buildNum = self.parameter["buildNum"]
        else:
            from AppInstall import childTask

            task = childTask("appInstall")
            task.addPara("appName", "Photoshop")
            task.addPara("appVer", self.parameter["ProductVersion"])
            task.addPara("appSubProduct", "Application")
            self.buildNum = task._getInstalledBuildNum()

        if self.buildNum != "" and self.buildNum != None:
            pass
        elif "molecule" in self.parameter:
            moleculeReStr = "\d{8}\." + self.parameter["molecule"] + "\.\d{1,}"
            from CodexTask import childTask

            task = childTask("codexTask")
            self.buildNum = "unknown"
            builds = task.getBuilds(
                "Photoshop",
                self.parameter["ProductVersion"],
                "Molecule",
                "Release",  # CompileTarget
                self.platform,
                globalProperty.getSysInfo().locale,
                "Build Failed",
            )
            if builds == None:
                return None

            latestBuildLocation = None
            for build in builds:
                if re.match(moleculeReStr, build._build):
                    latestBuildLocation = (
                        build._location["protocol"] + "://" + build._location["server"] + build._location["path"]
                    )

                    self.buildNum = build._build
                    break
        else:
            if globalProperty.isMachineOutOfChina():
                # Support the machine out of China, will download directly
                from CodexTask import childTask

                task = childTask("codexTask")
                latestBuild = task.getBuild(
                    "Photoshop",
                    self.parameter["ProductVersion"],
                    "Release",  # CompileTarget
                    self.platform,
                    globalProperty.getSysInfo().locale,
                    "Build Failed",
                )
                if latestBuild == None:
                    return None

                self.buildNum = latestBuild._build
            else:
                self.buildNum = globalProperty.getLatestBuildNum(
                    "Photoshop",
                    self.parameter["ProductVersion"],
                    self.platform,
                    globalProperty.getSysInfo().locale,
                    "Build Failed",
                    "Application",
                )
        if "sendReport" in self.parameter and self.parameter["sendReport"] != None:
            self.sendReport = self.parameter["sendReport"]
        else:
            self.sendReport = "No"

        user = globalProperty.getUser()
        if user == None:
            defaultTo = "*****@*****.**"
        else:
            defaultTo = "*****@*****.**" % user

        if "sendReportTo" in self.parameter and self.parameter["sendReportTo"] != None:
            self.sendReportTo = self.parameter["sendReportTo"]
        else:
            self.sendReportTo = defaultTo

        if "specifyLocation" in self.parameter and self.parameter["specifyLocation"] != None:
            self.specifyLocation = self.parameter["specifyLocation"]
        else:
            self.specifyLocation = ""

        import platform

        self.hostname_psf = platform.node()

        # Due to PSF bug, the version 12.0 must be set as 12.0.0, so add a workaround here
        productVersionTmp = self.parameter["ProductVersion"]
        if re.match("^\d{1,2}\.\d{1,3}$", productVersionTmp.lower()):
            productVersionTmp += ".0"

        if os.name == "posix":
            if not (os.path.exists(os.path.join(self.userHome, "Desktop"))):
                os.makedirs(os.path.join(self.userHome, "Desktop"))
            self.launcherFileName += ".sh"
            self.launcherFilePath = os.path.join(self.userHome, "Desktop", self.launcherFileName)
            inputStr = "#!/bin/sh\n"
            inputStr += "chmod +x %s/psf_launcher\n" % self.psfHome
            inputStr += "chmod +x %s/config/utils/TestFilesDownloader\n" % self.psfHome
            inputStr += (
                '%s/psf_launcher "%s" "%s" "%s" "%s" "%s" "%s" "%s" "1" "%s" "1" "" "%s" "" "" "" "" "%s" "%s" "%s" "%s" "%s" "%s"\n'
                % (
                    self.psfHome,
                    self.parameter["ProductTested"],
                    self.parameter["BuildConfig"],
                    self.buildNum,
                    globalProperty.getSysInfo().locale,
                    globalProperty.getSysInfo().locale,
                    self.parameter["SuiteSelected"],
                    self.parameter["SendResult"],
                    self.hostname_psf,
                    productVersionTmp,
                    self.parameter["PSFController"],
                    self.parameter["LDAPUser"],
                    self.downloadFileFlag,
                    self.specifyLocation,
                    self.sendReport,
                    self.sendReportTo,
                )
            )

            self.creatFile(self.launcherFilePath, inputStr)

            # Add execution

            self.runCommand("chmod +x %s" % self.launcherFilePath)

        elif os.name == "nt":
            if not (os.path.exists(os.path.join(self.userHome, "Desktop"))):
                os.makedirs(os.path.join(self.userHome, "Desktop"))
            self.launcherFileName += ".cmd"
            self.launcherFilePath = os.path.join(self.userHome, "Desktop", self.launcherFileName)
            inputStr = "cd /d %s\n" % self.psfHome
            buildConfig = self.parameter["BuildConfig"]
            if re.match(".*_32bt_.*", buildConfig):
                inputStr += "Call psf_launcher32.exe "
            else:
                inputStr += "Call psf_launcher.exe "
            inputStr += (
                '"%s" "%s" "%s" "%s" "%s" "%s" "%s" "1" "%s" "1" "" "%s" "" "" "" "" "%s" "%s" "%s" "%s" "%s" "%s"\n'
                % (
                    self.parameter["ProductTested"],
                    self.parameter["BuildConfig"],
                    self.buildNum,
                    globalProperty.getSysInfo().locale,
                    globalProperty.getSysInfo().locale,
                    self.parameter["SuiteSelected"],
                    self.parameter["SendResult"],
                    self.hostname_psf,
                    productVersionTmp,
                    self.parameter["PSFController"],
                    self.parameter["LDAPUser"],
                    self.downloadFileFlag,
                    self.specifyLocation,
                    self.sendReport,
                    self.sendReportTo,
                )
            )
            # Following statement should not be called
            # inputStr += "Call cmd"
            self.creatFile(self.launcherFilePath, inputStr)
Exemplo n.º 10
0
 def __getLatestBuildNumber(self):
     if 'buildNum' in self.parameter and self.parameter['buildNum'] != None:
         self.buildNum = self.parameter['buildNum']
     else:
         import AppInstall
         task = AppInstall.childTask('appInstall')
         task.addPara('appName', 'Photoshop')
         task.addPara('appVer', self.parameter['ProductVersion'])
         task.addPara('appSubProduct', 'Application')
         self.buildNum = task._getInstalledBuildNum()
         
     if self.buildNum!="" and self.buildNum!=None:
         pass
     elif 'molecule' in self.parameter:
         moleculeReStr = "\d{8}\." + self.parameter['molecule'] + "\.\d{1,}"
         from CodexTask import childTask
         task = childTask('codexTask')
         self.buildNum = "unknown"
         builds = task.getBuilds(
                                 'Photoshop',
                                 self.parameter['ProductVersion'],
                                 "Molecule",
                                 "Release", #CompileTarget
                                 self.platform,
                                 globalProperty.getSysInfo().locale,
                                 'Build Failed')
         if builds==None:
             return None
             
         latestBuildLocation = None
         for build in builds:
             if re.match(moleculeReStr, build._build):
                 latestBuildLocation = build._location['protocol'] + "://" + \
                                       build._location['server'] + \
                                       build._location['path']
             
                 self.buildNum = build._build
                 break
     else:
         if globalProperty.isMachineOutOfChina():
             #Support the machine out of China, will download directly
             import CodexTask
             task = CodexTask.childTask('codexTask')
             latestBuild = task.getBuild(
                                   'Photoshop',
                                   self.parameter['ProductVersion'],
                                   "Release", #CompileTarget
                                   self.platform,
                                   globalProperty.getSysInfo().locale,
                                   'Build Failed')
             if latestBuild==None:
                 return None
             
             self.buildNum = latestBuild._build
         else:
             self.buildNum = globalProperty.getLatestBuildNum('Photoshop',
                                                              self.parameter['ProductVersion'],
                                                              self.platform,
                                                              globalProperty.getSysInfo().locale,
                                                              'Build Failed',
                                                              'Application')