started the status queue development #4
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,4 +4,5 @@
|
||||
config.ini
|
||||
storage
|
||||
queue
|
||||
error
|
||||
venv/*
|
||||
|
@ -19,6 +19,7 @@ def create_app():
|
||||
config.read(os.path.join(app.root_path, 'config.ini'))
|
||||
|
||||
queuedir = os.path.join(app.root_path, 'queue')
|
||||
errordir = os.path.join(app.root_path,'error')
|
||||
storagedir = os.path.join(app.root_path, 'storage')
|
||||
app.logger.setLevel(config['api'].get('log_level', 'ERROR'))
|
||||
authenticator = Authenticator(config, app.logger)
|
||||
@ -118,6 +119,35 @@ def create_app():
|
||||
running = True
|
||||
return Response(response=json.dumps({'running': running}),
|
||||
content_type='application/json')
|
||||
|
||||
@app.route('/status/queue', methods=['GET'])
|
||||
def status_queue():
|
||||
os_queue_list = os.listdir(queuedir)
|
||||
queue_list = []
|
||||
|
||||
for item in os_queue_list:
|
||||
path = os.path.join(queuedir,item)
|
||||
with open(path, 'r') as f:
|
||||
data = json.load(f)
|
||||
mydata = {'type': data['type'],
|
||||
'id': item,
|
||||
'title': data['data']['title'],
|
||||
'description': data['data']['description'],
|
||||
'courses': data['data']['courses'],
|
||||
'presenters': data['data']['presenters'],
|
||||
'tags': data['data']['tags'],
|
||||
'created': data['data']['created'],
|
||||
'uploaded': os.path.getctime(path)}
|
||||
|
||||
any_errors = os.listdir(errordir)
|
||||
if item in any_errors:
|
||||
with open(os.path.join(errordir, item), 'r') as e:
|
||||
error_item = json.load(e)
|
||||
mydata['error'] = error_item['error']
|
||||
queue_list.append(mydata)
|
||||
|
||||
return Response(response=json.dumps(queue_list),
|
||||
content_type='application/json')
|
||||
|
||||
def _enqueue(package):
|
||||
with open(os.path.join(queuedir, _get_uuid()), 'x') as f:
|
||||
|
Loading…
x
Reference in New Issue
Block a user