-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanage.py
48 lines (33 loc) · 1021 Bytes
/
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
import os
import unittest
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
from app import blueprint
from app.main import create_app, db
from app.main.service.game_scraper import collect_games_details
from app.main.service.game_service import save_game_data
app = create_app(os.getenv('FLASK_ENV') or 'development')
app.register_blueprint(blueprint)
app.app_context().push()
manager = Manager(app)
migrate = Migrate(app, db)
manager.add_command('db', MigrateCommand)
@manager.command
def run():
app.run()
@manager.command
def new_games():
if os.path.exists('match_details.json'):
os.remove('match_details.json')
collect_games_details()
save_game_data()
@manager.command
def test():
"""Run the tests"""
tests = unittest.TestLoader().discover('app/test', pattern='test*.py')
result = unittest.TextTestRunner(verbosity=2).run(tests)
if result.wasSuccessful():
return 0
return 1
if __name__ == '__main__':
manager.run()