def run(self): time.sleep(2) if self.win is None or self.args is None: ILog.getLogger().error("Parameters is none") return self.printMsgToUI({"info":"Loading upgrade files..."}) upgradeInfo = self.loadUpgradeInfoFile(self.args[1]) if upgradeInfo == None: self.printMsgToUI({"info":"Loading error, please try later"}) return self.printMsgToUI({"softName":upgradeInfo["softName"]}) iIndex = 0 iFilesLen = len(upgradeInfo["updateFilePath"]) for fileRelativePath in upgradeInfo["updateFilePath"]: iIndex+=1 url = deamon.IPyDeamonConstant.BASE_URL + fileRelativePath fileName = fileRelativePath[fileRelativePath.find("/", 1)+1:] progressInfo = "Update "+fileName val = int((iIndex*1.0/iFilesLen)*100) self.printMsgToUI({"info":progressInfo, "val":val}) HttpClient.downloadFile(url, self.basePath+fileName) for i in range(5, 0, -1): self.printMsgToUI({"info":"Upgrade finished, Automatic restart after " + str(i) + " seconds"}) time.sleep(1) self.printMsgToUI({"startup":upgradeInfo["startupName"], "basePath":self.basePath})
def printMsgToUI(self, msg): wx.PostEvent(self.win, ResultEvent(deamon.IPyDeamonConstant.MSGID_NOTIFY_PROGRESS, msg)) ILog.getLogger().error(msg) print msg