Browse Source

fixed progress issue

cjs3
Stephen Lorenz 3 years ago
parent
commit
d2b5f1b470
  1. 1
      .gitignore
  2. 8
      cjs/cjs/automate.py
  3. 1
      cjs/cjs/core/batch.py
  4. 6
      cjsd/cjsd/core/database.py
  5. 3
      cjsd/cjsd/resources/automate.py

1
.gitignore

@ -1,5 +1,6 @@
# cjs
cjs-data/
run_cjs
# cjsd
cjsd/cjsd/.app

8
cjs/cjs/automate.py

@ -191,7 +191,7 @@ def efm_qualitative(state, job):
# write settings file to tmp
write_json(test_file, test_settings)
click.echo('Worker: Starting %s and %s (%s)' % (
click.echo(' Worker: Starting %s and %s (%s)' % (
evidence_data['name'],
comparison_data['name'],
ethnicity
@ -210,10 +210,16 @@ def efm_qualitative(state, job):
elapsed = end_time-start_time
except subprocess.CalledProcessError as e:
# initalize status to be sent to the foreman
print(' Worker: Job failed (%s, %s)' % (evidence_data['name'], comparison_data['name']))
status['event'] = 4
break
except Exception as e:
print(' Worker: An unexpected error has occured (%s, %s)' % (evidence_data['name'], comparison_data['name']))
status['event'] = 4
state.output_queue.put(status)
raise
# signal the foreman of the status
print(' Worker: End of job (%s, %s)' % (evidence_data['name'], comparison_data['name']))
state.output_queue.put(status)

1
cjs/cjs/core/batch.py

@ -155,6 +155,7 @@ def spawn_foreman(state, interface, database, scan_dir):
try:
while True:
status = state.output_queue.get(block=False)
print('Foreman: Updating status for %s and %s to %d' % (status['evidence'], status['comparison'], status['event']))
interface.update_job(
database,
status['evidence'],

6
cjsd/cjsd/core/database.py

@ -481,10 +481,8 @@ def find_job(database_name, evidence_name, comparison_name):
EvidenceTable.name == evidence_name)
comparison_table = db.first_record(ComparisonTable,
ComparisonTable.name == comparison_name)
test_table = db.first_record(
TestTable,
((TestTable.comparison_id == comparison_table.id_) and (TestTable.evidence_id == comparison_table.id_))
)
test_table = sess.query(TestTable).filter(TestTable.comparison_id == comparison_table.id_).filter(TestTable.evidence_id == evidence_table.id_).first()
job_table = db.first_record(JobTable, JobTable.test_id == test_table.id_)
return job_table

3
cjsd/cjsd/resources/automate.py

@ -58,11 +58,14 @@ class UpdateJobResource:
event_id = req.context['event']
job = find_job(database_name, evidence_name, comparison_name)
print(job)
set_job_status(database_name, job.id_, event_id)
except IntegrityError:
print('Unable to find %s and %s' % (evidence_name, comparison_name))
raise falcon.HTTPBadRequest('No jobs',
'Unable to get next job.')
except Exception as e:
print('Unable to find %s and %s' % (evidence_name, comparison_name))
raise falcon.HTTPInternalServerError()
class CurrentBatchResource:

Loading…
Cancel
Save