def step1(version_digest): lg.out(4, 'os_windows_update.step1') global _UpdatingInProgress global _CurrentVersionDigest global _NewVersionNotifyFunc global _UpdatingByUser _CurrentVersionDigest = str(version_digest).strip() local_checksum = bpio.ReadBinaryFile(settings.CheckSumFile()).strip() if local_checksum == _CurrentVersionDigest: lg.out( 6, 'os_windows_update.step1 no need to update, checksums are equal') _UpdatingInProgress = False if _NewVersionNotifyFunc is not None: _NewVersionNotifyFunc(_CurrentVersionDigest) return appList = bpio.find_process([ 'bpgui.', ]) if len(appList) > 0: if not _UpdatingByUser: lg.out( 6, 'os_windows_update.step1 bpgui is running, ask user to update.' ) _UpdatingInProgress = False if _NewVersionNotifyFunc is not None: _NewVersionNotifyFunc(_CurrentVersionDigest) return d = download_info() d.addCallback(step2, _CurrentVersionDigest) d.addErrback(fail)
def _success(x): global _CurrentVersionDigest global _NewVersionNotifyFunc _CurrentVersionDigest = str(x) local_version = bpio.ReadBinaryFile(settings.CheckSumFile()) lg.out(6, 'os_windows_update.check._success local=%s current=%s' % (local_version, _CurrentVersionDigest)) if _NewVersionNotifyFunc is not None: _NewVersionNotifyFunc(_CurrentVersionDigest) return x
def step4(version_digest): lg.out(4, 'os_windows_update.step4') global _UpdatingInProgress global _CurrentVersionDigest global _NewVersionNotifyFunc global _UpdatingByUser _CurrentVersionDigest = str(version_digest) local_version = bpio.ReadBinaryFile(settings.CheckSumFile()) if local_version == _CurrentVersionDigest: lg.out(6, 'os_windows_update.step4 no need to update') _UpdatingInProgress = False return lg.out( 6, 'os_windows_update.step4 local=%s current=%s ' % (local_version, _CurrentVersionDigest)) if settings.getUpdatesMode() == settings.getUpdatesModeValues( )[2] and not _UpdatingByUser: lg.out( 6, 'os_windows_update.step4 run scheduled, but mode is %s, skip now' % settings.getUpdatesMode()) return if _UpdatingByUser or settings.getUpdatesMode( ) == settings.getUpdatesModeValues()[0]: # info_file_path = os.path.join(bpio.getExecutableDir(), settings.FilesDigestsFilename()) info_file_path = settings.InfoFile() if os.path.isfile(info_file_path): try: os.remove(info_file_path) except: lg.out( 1, 'os_windows_update.step4 ERROR can no remove ' + info_file_path) lg.exc() param = '' if _UpdatingByUser: param = 'show' from main import shutdowner if param == 'show': shutdowner.A('stop', 'restartnshow') else: shutdowner.A('stop', 'restart') else: if _NewVersionNotifyFunc is not None: _NewVersionNotifyFunc(_CurrentVersionDigest)