/
manage.py
executable file
·106 lines (83 loc) · 2.41 KB
/
manage.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from flask import current_app
from flask_script import Manager, prompt_bool
from seer import create_app
from seer.extensions import db
import watchdog
manager = Manager(create_app)
@manager.command
def create_all():
""" Creates database tables
"""
db.create_all()
@manager.command
def drop_all():
""" Drops all database tables
"""
if prompt_bool("Are you sure ? You will lose all your data !"):
db.drop_all()
@manager.command
def drop_all_immeditely():
""" Drops all database tables immeditely
"""
db.drop_all()
@manager.command
def version():
""" Output current version
"""
print watchdog.version()
@manager.command
def var_dir():
""" Output the directory path for current project in var
"""
print watchdog.var_dir()
@manager.command
def build_var():
""" Initialize var dir for deployment
"""
watchdog.build_var()
@manager.shell
def make_shell_context():
return dict(app=current_app)
@manager.option('-c', '--channel', help='Channel id')
def fetch_kandianshi(channel):
return watchdog.fetch_kandianshi(channel)
@manager.option('-c', '--channel', help='Channel id')
@manager.option('-n', '--datenum', help='Date number')
def fetch_tvmao(channel, datenum):
return watchdog.fetch_tvmao(channel, datenum)
@manager.command
def fetch_all():
return watchdog.fetch_all()
@manager.command
def init_db():
return watchdog.init_db()
@manager.option('-n', '--datenum', help='Date number')
@manager.option('-d', '--days', help='Days count', default=7, type=int)
def online(datenum, days):
return watchdog.do_online(datenum, days)
@manager.command
def mapping():
return watchdog.do_mapping()
@manager.command
def apply():
return watchdog.do_apply()
@manager.command
def douban_top():
return watchdog.do_douban_top()
@manager.command
def update_douban():
return watchdog.do_update_douban()
@manager.option('-n', '--datenum', help='Date number to package.')
@manager.option('-t', '--target', help='Target package path.')
@manager.option('-d', '--days', help='Days count from specifed datenum.',
default=1, type=int)
def package(target, datenum, days):
watchdog.do_package(target, datenum, days)
manager.add_option('-c', '--config',
dest="config",
required=False,
help="config file")
if __name__ == "__main__":
manager.run()