aboutsummaryrefslogtreecommitdiff
blob: 8df47ee303c111a3997b4ea78ac5819f30ffde22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask_script import Manager, Shell

from backend import app, db
from backend.lib import sync

# TODO: Replace this with flask 0.11 "flask" CLI and the extra commands support via click therein - http://flask.pocoo.org/docs/0.11/cli/
# TODO: This would then allow FLASK_DEBUG=1 automatically reloading the server on code changes when launched with "flask run"

manager = Manager(app)

def shell_context():
    return dict(app=manager.app, db=db)

manager.add_command('shell', Shell(make_context=shell_context))

@manager.command
def init():
    """Initialize empty database with tables"""
    db.create_all()

@manager.command
def sync_gentoo():
    """Synchronize Gentoo data"""
    sync.sync_projects()
    sync.sync_categories()
    sync.sync_packages()
    #sync_versions()

@manager.command
def sync_projects():
    """Synchronize only Gentoo projects.xml data"""
    sync.sync_projects()

@manager.command
def sync_categories():
    """Synchronize only Gentoo categories data"""
    sync.sync_categories()

@manager.command
def sync_packages():
    """Synchronize only Gentoo packages base data (without details)"""
    sync.sync_packages()

@manager.command
def sync_versions():
    """Synchronize only Gentoo package details"""
    sync.sync_versions()

if __name__ == '__main__':
    manager.run()