-
Notifications
You must be signed in to change notification settings - Fork 114
/
manage.py
45 lines (34 loc) · 980 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
from gevent import monkey
monkey.patch_all()
import os
import redis
from cyoa import app, redis_db, socketio, db
from cyoa.models import Wizard
from flask.ext.script import Manager, Shell
manager = Manager(app)
def make_shell_context():
return dict(app=app, redis_db=redis_db, db=db, Wizard=Wizard)
manager.add_command("shell", Shell(make_context=make_shell_context))
@manager.command
def syncdb():
db.create_all()
@manager.command
def runserver():
socketio.run(app, "0.0.0.0", port=5001)
@manager.command
def create_wizard(name, password):
try:
db.session.add(Wizard(name, password))
db.session.commit()
except:
# user already created. swallow
pass
@manager.command
def clear_redis():
redis_cli = redis.StrictRedis(host='localhost', port='6379', db='0')
redis_cli.delete('done')
redis_cli.delete('more')
redis_cli.delete('yes')
redis_cli.delete('no')
if __name__ == '__main__':
manager.run()