Пример #1
0
def index():
    if not api.get_credentials():
        url = utils.get_url('auth_callback', '/authcallback', True)
        return f.redirect(api.get_login_url(url))
    root = db.get()
    root._p_jar.sync()
    config = root.get('config', {})
    configured = configurator.valid(config)
    action = root.get('action', {})
    what = action.get('what')
    when = action.get('when')
    current = root.get('current_file')
    return f.render_template(
        'index.html', configured=configured, what=what,
        when=when, current_file=dict(current),
        errored=root.get('errored', [])[-20:], **config)
Пример #2
0
def index():
    if not api.get_credentials():
        url = utils.get_url('auth_callback', '/authcallback', True)
        return f.redirect(api.get_login_url(url))
    root = db.get()
    root._p_jar.sync()
    config = root.get('config', {})
    configured = configurator.valid(config)
    action = root.get('action', {})
    what = action.get('what')
    when = action.get('when')
    current = root.get('current_file')
    return f.render_template('index.html',
                             configured=configured,
                             what=what,
                             when=when,
                             current_file=dict(current),
                             errored=root.get('errored', [])[-20:],
                             **config)
Пример #3
0
def _run(argv=sys.argv):
    root = db.get()
    while not api.get_credentials():
        stats.record_action(root, 'Application not authorized')
        time.sleep(5)

    if 'index' not in root:
        initialize_db()

    while True:
        while 'config' not in root:
            time.sleep(5)
            root = db.get()

        if 'metadata' not in root:
            metadata = root['metadata'] = OOBTree()
        else:
            metadata = root['metadata']
        if (time.time() - metadata.get('endpoint_last_retrieved', 0)) > (
                60 * 60 * 24 * 3):
            api.store_endpoint()

        # reset errors
        root['errored'] = []
        transaction.commit()

        stats.record_action(root, 'Syncing files')
        stats.record_stats(root, sync())

        stats.record_action(root, 'Cleaning files')
        clean()

        stats.record_action(root, 'Packing database')
        storage = db.get_storage()
        storage.pack(time.time(), wait=True)

        stats.record_action(root, 'Taking a break for 10 minutes...')
        time.sleep(60 * 10)
Пример #4
0
def _run(argv=sys.argv):
    root = db.get()
    while not api.get_credentials():
        stats.record_action(root, 'Application not authorized')
        time.sleep(5)

    if 'index' not in root:
        initialize_db()

    while True:
        while 'config' not in root:
            time.sleep(5)
            root = db.get()

        if 'metadata' not in root:
            metadata = root['metadata'] = OOBTree()
        else:
            metadata = root['metadata']
        if (time.time() - metadata.get('endpoint_last_retrieved', 0)) > (60 * 60 * 24 * 3):
            api.store_endpoint()

        # reset errors
        root['errored'] = []
        transaction.commit()

        stats.record_action(root, 'Syncing files')
        stats.record_stats(root, sync())

        stats.record_action(root, 'Cleaning files')
        clean()

        stats.record_action(root, 'Packing database')
        storage = db.get_storage()
        storage.pack(time.time(), wait=True)

        stats.record_action(root, 'Taking a break for 10 minutes...')
        time.sleep(60 * 10)