-
Notifications
You must be signed in to change notification settings - Fork 16
/
manage.py
executable file
·66 lines (52 loc) · 1.73 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
#!/usr/bin/env python3
import os
import sqlalchemy
from flask.ext.migrate import Migrate, MigrateCommand
from flask.ext.script import Manager, Server
# from helpers import ShipHelper
from kcsrv import app
from db import db, Role
from offline import dbpopulate, kccheat
if not os.path.exists('./config.py'):
print("Your config file does not exist. "
"Create it by copying config.example.py to config.py and editing the required variables.")
exit(1)
manager = Manager(app)
manager.add_command('runserver', Server(host='0.0.0.0', use_reloader=True))
migrate = Migrate(app, db)
manager.add_command('db', MigrateCommand)
from commands.user import manager as user_manager
manager.add_command('user', user_manager)
@manager.command
def setup():
print("Installing default roles...")
db.session.add(Role(name="admin", description="Allowed to access the admin panel"))
db.session.add(Role(name="staff", description="Allowed to see restricted information"))
db.session.commit()
@manager.command
def cheat(where, id, admiral_id, action=None):
if where == "quest":
if action == "add":
kccheat.quest_add(admiral_id, id)
elif action == "complete":
kccheat.quest_complete(admiral_id, id)
elif where == "ship":
kccheat.ship_add(admiral_id, id)
elif where == "equip":
kccheat.equip_add(admiral_id, id)
else:
print("Unknown cheat")
@manager.command
def update_db():
"""Update all parts of the DB"""
dbpopulate.ships()
dbpopulate.equip()
dbpopulate.items()
dbpopulate.recipe_resources()
dbpopulate.expeditions()
try:
setup()
except sqlalchemy.exc.IntegrityError:
pass
if __name__ == '__main__':
manager.run()