MCPcopy Index your code
hub / github.com/PyQt5/PyQtClient / UpgradeThread

Class UpgradeThread

Utils/GitThread.py:279–391  ·  view source on GitHub ↗

自动更新

Source from the content-addressed store, hash-verified

277
278
279class UpgradeThread(QObject):
280 """自动更新
281 """
282
283 UpdateUrl = [
284 ('https://github.com/PyQt5/PyQtClient/raw/master/.Update/Upgrade.json',
285 'https://github.com/PyQt5/PyQtClient/raw/master/.Update/Upgrade.{}.zip'
286 ),
287 ('https://gitee.com/PyQt5/PyQtClient/raw/master/.Update/Upgrade.json',
288 'https://gitee.com/PyQt5/PyQtClient/raw/master/.Update/Upgrade.{}.zip'
289 ),
290 ('https://pyqt.site/PyQt5/PyQtClient/raw/master/.Update/Upgrade.json',
291 'https://pyqt.site/PyQt5/PyQtClient/raw/master/.Update/Upgrade.{}.zip'
292 ),
293 ('https://pyqt5.com/PyQt5/PyQtClient/raw/master/.Update/Upgrade.json',
294 'https://pyqt5.com/PyQt5/PyQtClient/raw/master/.Update/Upgrade.{}.zip')
295 ]
296
297 @classmethod
298 def quit(cls):
299 """退出线程
300 :param cls:
301 """
302 if hasattr(cls, '_thread'):
303 cls._thread.quit()
304 AppLog.info('upgrade thread quit')
305
306 @classmethod
307 def start(cls, parent=None):
308 """启动自动更新线程
309 :param cls:
310 """
311 cls._thread = QThread(parent)
312 cls._worker = UpgradeThread()
313 cls._worker.moveToThread(cls._thread)
314 cls._thread.started.connect(cls._worker.run)
315 cls._thread.finished.connect(cls._worker.deleteLater)
316 cls._thread.start()
317 AppLog.info('update thread started')
318
319 def unzip(self, file):
320 # 进行解压
321 zipfile = ZipFile(file)
322 path = os.path.abspath('.')
323 members = zipfile.namelist()
324 for zipinfo in members:
325 _name = zipinfo.lower()
326 if _name.endswith('.exe') or \
327 _name.endswith('.dll') or \
328 _name.endswith('.ttf') or \
329 _name.endswith('.so') or \
330 _name.endswith('.dylib'):
331 tpath = os.path.abspath(os.path.join(path, zipinfo))
332 # 需要重命名当前正在占用的文件
333 if os.path.isfile(tpath):
334 os.rename(tpath, tpath + str(time()) + '.old')
335 zipfile.extract(zipinfo, path)
336

Callers 1

startMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected