示例#1
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()
示例#2
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()
     """
示例#3
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)