| 360 | AppLog.debug('download {} end'.format(file)) |
| 361 | |
| 362 | def run(self): |
| 363 | for url_ver, url_zip in self.UpdateUrl: |
| 364 | try: |
| 365 | show = True |
| 366 | req = requests.get(url_ver) |
| 367 | AppLog.info(req.text) |
| 368 | if req.status_code != 200: |
| 369 | AppLog.info('update thread end') |
| 370 | UpgradeThread.quit() |
| 371 | return |
| 372 | content = req.json() |
| 373 | for version, text in content: |
| 374 | if Version.version < version: |
| 375 | if show: |
| 376 | Signals.updateDialogShowed.emit() |
| 377 | QThread.msleep(1000) |
| 378 | show = False |
| 379 | Signals.updateTextChanged.emit(str(Version.version), |
| 380 | str(version), text) |
| 381 | self.download(Constants.UpgradeFile.format(version), |
| 382 | url_zip.format(version)) |
| 383 | Signals.updateFinished.emit(self.tr('update completed')) |
| 384 | break |
| 385 | except Exception as e: |
| 386 | Signals.updateFinished.emit( |
| 387 | self.tr('update failed: {}').format(str(e))) |
| 388 | AppLog.exception(e) |
| 389 | |
| 390 | AppLog.info('update thread end') |
| 391 | UpgradeThread.quit() |