mirror of https://github.com/jdcantrell/spice
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.0 KiB
42 lines
1.0 KiB
import sys
|
|
|
|
if len(sys.argv) > 1:
|
|
if sys.argv[1] == 'user':
|
|
from spice.models import User
|
|
from spice.database import db_session
|
|
name = input('User name: ')
|
|
password = input('Password: ')
|
|
|
|
user = User(name, password)
|
|
|
|
db_session.add(user)
|
|
db_session.commit()
|
|
|
|
print('User created: %r' % user.id)
|
|
|
|
if sys.argv[1] == 'init_db':
|
|
from spice import app
|
|
from spice.database import init_db
|
|
init_db()
|
|
|
|
print("Database init")
|
|
|
|
if sys.argv[1] == 'process':
|
|
from spice.models import File
|
|
from spice.database import db_session
|
|
from spice.handlers import get_handler_instance
|
|
files = db_session.query(File).order_by(File.id.desc()).all()
|
|
|
|
for record in files:
|
|
handler = get_handler_instance(record)
|
|
handler.process()
|
|
db_session.add(handler.record)
|
|
|
|
db_session.commit()
|
|
|
|
else:
|
|
from spice import app
|
|
app.run(debug=True, host='0.0.0.0', port=3000)
|
|
|
|
import spice.views
|