Esempio n. 1
0
def updateRunning():
    update = getConfig('update_running', 'false')
    if update != 'false':
        starttime = strp(update, '%Y-%m-%d %H:%M')
        if (starttime + timedelta(hours=6)) <= datetime.today():
            writeConfig('update_running', 'false')
            Log('DB Cancel update - duration > 6 hours')
        else:
            Log('DB Update already running', xbmc.LOGDEBUG)
            return True
    return False
Esempio n. 2
0
def strp(value, form):
    from time import strptime
    from datetime import datetime
    def_value = datetime.utcfromtimestamp(0)
    try:
        return datetime.strptime(value, form)
    except TypeError:
        try:
            return datetime(*(strptime(value, form)[0:6]))
        except ValueError as e:
            Log('time.strp error: {}'.format(e), xbmc.LOGERROR)
            return def_value
    except Exception as e:
        Log('datetime.strp error: {}'.format(e), xbmc.LOGERROR)
        return def_value
Esempio n. 3
0
def strp(value, form):
    def_value = datetime.utcfromtimestamp(0)
    try:
        return datetime.strptime(value, form)
    except TypeError:
        try:
            return datetime(*(time.strptime(value, form)[0:6]))
        except ValueError, e:
            Log('time.strp error: %s' % e, xbmc.LOGERROR)
            return def_value
Esempio n. 4
0
    update = getConfig('update_running', 'false')
    if update != 'false':
        starttime = strp(update, '%Y-%m-%d %H:%M')
        if (starttime + timedelta(hours=6)) <= datetime.today():
            writeConfig('update_running', 'false')
            Log('DB Cancel update - duration > 6 hours')
        else:
            Log('DB Update already running', xbmc.LOGDEBUG)
            return True
    return False


if __name__ == '__main__':
    addon = xbmcaddon.Addon()
    monitor = xbmc.Monitor()
    Log('AmazonDB: Service Start')
    writeConfig('update_running', 'false')
    writeConfig('login')
    freq = int('0' + var.addon.getSetting('auto_update'))
    checkfreq = 60
    idleupdate = 300
    startidle = 0

    if freq:
        while not monitor.abortRequested():
            from datetime import datetime, timedelta
            today = datetime.today()
            freq = var.addon.getSetting('auto_update')
            time = var.addon.getSetting('update_time')
            time = '00:00' if time == '' else time
            last = getConfig('last_update', '1970-01-01')
Esempio n. 5
0

def strp(value, form):
    from time import strptime
    from datetime import datetime
    def_value = datetime.utcfromtimestamp(0)
    try:
        return datetime.strptime(value, form)
    except TypeError:
        try:
            return datetime(*(strptime(value, form)[0:6]))
        except ValueError, e:
            Log('time.strp error: %s' % e, xbmc.LOGERROR)
            return def_value
    except Exception, e:
        Log('datetime.strp error: %s' % e, xbmc.LOGERROR)
        return def_value


def updateRunning():
    from datetime import datetime, timedelta
    update = getConfig('update_running', 'false')
    if update != 'false':
        starttime = strp(update, '%Y-%m-%d %H:%M')
        if (starttime + timedelta(hours=6)) <= datetime.today():
            writeConfig('update_running', 'false')
            Log('DB Cancel update - duration > 6 hours')
        else:
            Log('DB Update already running', xbmc.LOGDEBUG)
            return True
    return False
Esempio n. 6
0
            Log('DB Cancel update - duration > 6 hours')
        else:
            Log('DB Update already running', xbmc.LOGDEBUG)
            return True
    return False


while True:
    try:
        from datetime import datetime, timedelta
        datetime.today()
        strp('1970-01-01 00:00', '%Y-%m-%d %H:%M')
        timedelta()
        break
    except ImportError(datetime), e:
        Log('Importerror: %s' % e, xbmc.LOGERROR)
        if monitor.waitForAbort(1):
            exit()

if __name__ == '__main__':
    Log('AmazonDB: Service Start')
    addon = xbmcaddon.Addon()
    writeConfig('update_running', 'false')
    freq = int('0' + addon.getSetting('auto_update'))
    addonid = addon.getAddonInfo('id')
    checkfreq = 60
    idleupdate = 300
    startidle = 0

    if freq:
        while not monitor.abortRequested():