Example #1
0
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)
Example #2
0
def loop(first_start=False):
    global _ShedulerTask
    lg.out(4, 'os_windows_update.loop mode=' + str(settings.getUpdatesMode()))

    if settings.getUpdatesMode() == settings.getUpdatesModeValues()[2]:
        lg.out(4, 'os_windows_update.loop is finishing. updates is turned off')
        return

    shed = schedule.Schedule(from_dict=read_shedule_dict())
    nexttime = shed.next_time()
    #    nexttime = next(d)
    if first_start:
        nexttime = time.time()

    if nexttime is None:
        lg.out(1, 'os_windows_update.loop ERROR calculating shedule interval')
        return

    if nexttime < 0:
        lg.out(1, 'os_windows_update.loop nexttime=%s' % str(nexttime))
        return

    # DEBUG
    # nexttime = time.time() + 60.0

    delay = nexttime - time.time()
    if delay < 0:
        lg.warn('delay=%s %s' % (str(delay), shed))
        delay = 0

    lg.out(
        6,
        'os_windows_update.loop run_sheduled_update will start after %s seconds (%s hours)'
        % (str(delay), str(delay / 3600.0)))
    _ShedulerTask = reactor.callLater(delay, run_sheduled_update)
def loop(first_start=False):
    global _ShedulerTask
    lg.out(4, 'os_windows_update.loop mode=' + str(settings.getUpdatesMode()))

    if settings.getUpdatesMode() == settings.getUpdatesModeValues()[2]:
        lg.out(4, 'os_windows_update.loop is finishing. updates is turned off')
        return

    shed = schedule.Schedule(from_dict=read_shedule_dict())
    nexttime = shed.next_time()
#    nexttime = next(d)
    if first_start:
        nexttime = time.time()

    if nexttime is None:
        lg.out(1, 'os_windows_update.loop ERROR calculating shedule interval')
        return

    if nexttime < 0:
        lg.out(1, 'os_windows_update.loop nexttime=%s' % str(nexttime))
        return

    # DEBUG
    # nexttime = time.time() + 60.0

    delay = nexttime - time.time()
    if delay < 0:
        lg.warn('delay=%s %s' % (str(delay), shed))
        delay = 0

    lg.out(6, 'os_windows_update.loop run_sheduled_update will start after %s seconds (%s hours)' % (str(delay), str(delay / 3600.0)))
    _ShedulerTask = reactor.callLater(delay, run_sheduled_update)
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)
Example #5
0
def init():
    lg.out(4, 'os_windows_update.init')
    # update_shedule_file(settings.getUpdatesSheduleData())
    if not bpio.isFrozen() or not bpio.Windows():
        lg.out(6, 'os_windows_update.init finishing')
        return
    # if not os.path.isfile(settings.VersionFile()):
    #     bpio.WriteFile(settings.VersionFile(), '')
    SetLocalDir(bpio.getExecutableDir())
    if settings.getUpdatesMode() != settings.getUpdatesModeValues()[2]:
        lg.out(6, 'os_windows_update.init starting the loop')
        reactor.callLater(0, loop, True)
    else:
        lg.out(6, 'os_windows_update.init skip, update mode is: %s' % settings.getUpdatesMode())
def init():
    lg.out(4, 'os_windows_update.init')
    # update_shedule_file(settings.getUpdatesSheduleData())
    if not bpio.isFrozen() or not bpio.Windows():
        lg.out(6, 'os_windows_update.init finishing')
        return
    # if not os.path.isfile(settings.VersionFile()):
    #     bpio.WriteFile(settings.VersionFile(), '')
    SetLocalDir(bpio.getExecutableDir())
    if settings.getUpdatesMode() != settings.getUpdatesModeValues()[2]:
        lg.out(6, 'os_windows_update.init starting the loop')
        reactor.callLater(0, loop, True)
    else:
        lg.out(6, 'os_windows_update.init skip, update mode is: %s' % settings.getUpdatesMode())
Example #7
0
def run_sheduled_update():
    global _UpdatingByUser
    global _UpdatingInProgress
    lg.out(6, 'os_windows_update.run_sheduled_update')
    if _UpdatingInProgress:
        lg.out(6, '  update is in progress, finish.')
        return
    if settings.getUpdatesMode() == settings.getUpdatesModeValues()[2]:
        lg.out(6, '  update mode is %s, finish.' % settings.getUpdatesMode())
        return
    from storage import backup_control
    if backup_control.HasRunningBackup():
        lg.out(6, '  some backups are running at the moment, finish.')
        return

    _UpdatingByUser = False
    reactor.callLater(0, step0)

    # check or start the update
    d = read_shedule_dict()
    d['lasttime'] = str(time.time())
    write_shedule_dict(d)
    loop()
def run_sheduled_update():
    global _UpdatingByUser
    global _UpdatingInProgress
    lg.out(6, 'os_windows_update.run_sheduled_update')
    if _UpdatingInProgress:
        lg.out(6, '  update is in progress, finish.')
        return
    if settings.getUpdatesMode() == settings.getUpdatesModeValues()[2]:
        lg.out(6, '  update mode is %s, finish.' % settings.getUpdatesMode())
        return
    from storage import backup_control
    if backup_control.HasRunningBackup():
        lg.out(6, '  some backups are running at the moment, finish.')
        return

    _UpdatingByUser = False
    reactor.callLater(0, step0)

    # check or start the update
    d = read_shedule_dict()
    d['lasttime'] = str(time.time())
    write_shedule_dict(d)
    loop()