2015-02-04 02:02:21 +01:00
|
|
|
from application import app
|
2015-04-10 13:08:45 -03:00
|
|
|
from application import post_item
|
2015-02-04 02:02:21 +01:00
|
|
|
from flask.ext.script import Manager
|
|
|
|
|
|
|
|
manager = Manager(app)
|
2015-04-07 14:31:41 +02:00
|
|
|
|
2015-04-01 10:10:26 -03:00
|
|
|
@manager.command
|
|
|
|
def runserver():
|
|
|
|
try:
|
2015-04-01 10:42:27 -03:00
|
|
|
import config
|
|
|
|
PORT = config.Development.PORT
|
|
|
|
HOST = config.Development.HOST
|
|
|
|
DEBUG = config.Development.DEBUG
|
2015-04-01 10:10:26 -03:00
|
|
|
except ImportError:
|
2015-04-07 14:31:41 +02:00
|
|
|
PORT = 5000
|
2015-04-01 10:10:26 -03:00
|
|
|
HOST = '0.0.0.0'
|
|
|
|
DEBUG = True
|
|
|
|
|
|
|
|
app.run(
|
|
|
|
port=PORT,
|
|
|
|
host=HOST,
|
|
|
|
debug=DEBUG)
|
|
|
|
|
2015-04-07 14:40:39 +02:00
|
|
|
|
2015-04-08 18:09:04 +02:00
|
|
|
@manager.command
|
|
|
|
def clear_db():
|
|
|
|
"""Wipes the database
|
|
|
|
"""
|
|
|
|
from pymongo import MongoClient
|
|
|
|
|
|
|
|
client = MongoClient()
|
|
|
|
db = client.eve
|
|
|
|
db.drop_collection('nodes')
|
|
|
|
db.drop_collection('node_types')
|
|
|
|
db.drop_collection('tokens')
|
|
|
|
db.drop_collection('users')
|
|
|
|
|
|
|
|
|
2015-04-07 14:40:39 +02:00
|
|
|
@manager.command
|
|
|
|
def populate_db_test():
|
|
|
|
"""Populate the db with sample data
|
|
|
|
"""
|
|
|
|
|
|
|
|
shot_node_type = {
|
|
|
|
"name": "shot",
|
|
|
|
"description": "Shot Node Type, for shots",
|
|
|
|
"dyn_schema": {
|
|
|
|
"url": {
|
|
|
|
"type": "string",
|
|
|
|
},
|
|
|
|
"cut_in": {
|
|
|
|
"type": "integer"
|
|
|
|
},
|
|
|
|
"cut_out": {
|
|
|
|
"type": "integer"
|
|
|
|
},
|
|
|
|
"status": {
|
|
|
|
"type": "string",
|
|
|
|
"allowed": ["on_hold",
|
|
|
|
"todo",
|
|
|
|
"in_progress",
|
|
|
|
"review_required",
|
|
|
|
"final"],
|
|
|
|
},
|
|
|
|
"notes": {
|
|
|
|
"type": "string",
|
|
|
|
"maxlength": 256,
|
|
|
|
},
|
|
|
|
"order": {
|
|
|
|
"type": "integer",
|
|
|
|
},
|
|
|
|
"shot_group": {
|
|
|
|
"type": "string",
|
|
|
|
#"data_relation": {
|
|
|
|
# "resource": "nodes",
|
|
|
|
# "field": "_id",
|
|
|
|
#},
|
|
|
|
}
|
|
|
|
},
|
2015-04-10 13:08:45 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
task_node_type = {
|
|
|
|
"name": "task",
|
|
|
|
"description": "Task Node Type, for tasks",
|
|
|
|
"dyn_schema": {
|
|
|
|
"status": {
|
|
|
|
"type": "string",
|
|
|
|
"allowed": [
|
|
|
|
"todo",
|
|
|
|
"in-progress",
|
|
|
|
"done",
|
|
|
|
"cbb",
|
|
|
|
"final1",
|
|
|
|
"final2",
|
|
|
|
"review"
|
|
|
|
],
|
|
|
|
"required": True,
|
|
|
|
},
|
|
|
|
"owners": {
|
|
|
|
"type": "dict",
|
|
|
|
"schema": {
|
|
|
|
"users": {
|
|
|
|
"type": "list",
|
|
|
|
},
|
|
|
|
"groups": {
|
|
|
|
"type": "list",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"time": {
|
|
|
|
"type": "dict",
|
|
|
|
"schema": {
|
|
|
|
"start": {
|
|
|
|
"type": "datetime"
|
|
|
|
},
|
|
|
|
"duration": {
|
|
|
|
"type": "integer"
|
|
|
|
},
|
|
|
|
"chunks": {
|
|
|
|
"type": "list",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
2015-04-07 14:40:39 +02:00
|
|
|
|
|
|
|
shot = {
|
|
|
|
"name": "01",
|
|
|
|
"description": "A sheep tries to hang itself, but fails",
|
2015-04-13 01:21:57 +02:00
|
|
|
"picture": "",
|
2015-04-07 14:40:39 +02:00
|
|
|
"order": 0,
|
|
|
|
"parent": None,
|
|
|
|
"node_type": "55016a52135d32466fc800be",
|
|
|
|
"properties": {
|
|
|
|
"url": "shot01",
|
|
|
|
"cut_in": 100,
|
|
|
|
"cut_out": 900,
|
|
|
|
"status": "todo",
|
|
|
|
"notes": "I think the sheep should scream a bit more",
|
|
|
|
"order": 1,
|
|
|
|
"shot_group": "",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-10 13:08:45 -03:00
|
|
|
post_item('node_types', shot_node_type)
|
|
|
|
post_item('node_types', task_node_type)
|
2015-04-07 14:40:39 +02:00
|
|
|
|
|
|
|
|
2015-03-12 15:05:10 +01:00
|
|
|
if __name__ == '__main__':
|
|
|
|
manager.run()
|