Browse Source

going home

cjs3
Stephen Lorenz 3 years ago
parent
commit
e2584420cc
  1. BIN
      cjsd/.app/database/debugger/database.db
  2. 3
      cjsd/cjsd.py
  3. 39
      cjsd/resources/database.py

BIN
cjsd/.app/database/debugger/database.db

3
cjsd/cjsd.py

@ -28,7 +28,8 @@ ROUTES = {
'/database/clone': database.CloneResource,
'/database/clear': database.ClearResource,
'/database/upload': database.UploadResource,
'/database/status': database.StatusResource
'/database/status': database.StatusResource,
'/database/stage': database.StageResource
}
def create_api():

39
cjsd/resources/database.py

@ -74,6 +74,13 @@ def get_database_context(req, resp, Resource, params):
except KeyError:
raise falcon.HTTPMissingParam('database')
def get_batch_context(req, resp, Resource, params):
try:
req.context['batch'] = req.media['batch']
# TODO: add database does not exist check
except KeyError:
raise falcon.HTTPMissingParam('batch')
def validate_data_type(req, resp, Resource, params):
ALLOWED_TYPES = ['evidence', 'comparison', 'result']
try:
@ -297,23 +304,23 @@ class StatusResource:
raise falcon.HTTPInternalServerError()
class StageResource:
@falcon.before(get_batch_context)
@falcon.before(get_database_context)
def on_post(self, req, resp):
if click.confirm("Warning: There are still jobs currently pending.\nLoad the Job table?"):
try:
location = database_location(database_name)
create_dir('%s/output/%s' % (location, batch_name))
_database_add(database_name, [BatchTable(batch_name)])
batch = _database_select(database_name,
BatchTable,
BatchTable.name == batch_name)
batch = batch[0] # _database_select returns a list, but this is a single value
tests = _database_select(database_name, TestTable)
_database_add(database_name, [JobTable(t.id_, batch.id_) for t in tests])
except Exception as e:
raise
else:
click.echo('No changes were made.')
database_name = req.context['database']
batch_name = req.context['batch']
try:
database_path = database_location(database_name)
create_dir('%s/output/%s' % (database_path, batch_name))
database_add(database_name, [BatchTable(batch_name)])
batch = database_select(database_name,
BatchTable,
BatchTable.name == batch_name)
batch = batch[0] # _database_select returns a list, but this is a single value
tests = database_select(database_name, TestTable)
database_add(database_name, [JobTable(t.id_, batch.id_) for t in tests])
except Exception as e:
raise
# END command-line interface
Loading…
Cancel
Save