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