diff options
author | Pedro Alvarez Piedehierro <palvarez89@gmail.com> | 2017-07-07 01:04:18 +0100 |
---|---|---|
committer | Pedro Alvarez Piedehierro <palvarez89@gmail.com> | 2017-07-13 19:20:24 +0100 |
commit | 7ca915a812db8662362bfec4b335ba781531ae88 (patch) | |
tree | a951de744c83404b23e2e0581b4db3e487d4c712 | |
parent | d2cbc43175eeb4a770f7dae2e984df3f994dcfb8 (diff) | |
download | lorry-controller-7ca915a812db8662362bfec4b335ba781531ae88.tar.gz |
jobupdate: Store job information in lorry if job failed
-rw-r--r-- | lorrycontroller/jobupdate.py | 7 | ||||
-rw-r--r-- | lorrycontroller/statedb.py | 10 |
2 files changed, 16 insertions, 1 deletions
diff --git a/lorrycontroller/jobupdate.py b/lorrycontroller/jobupdate.py index efc9ce1..ec7e533 100644 --- a/lorrycontroller/jobupdate.py +++ b/lorrycontroller/jobupdate.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Codethink Limited +# Copyright (C) 2014-2017 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -51,6 +51,11 @@ class JobUpdate(lorrycontroller.LorryControllerRoute): lorry_info = statedb.get_lorry_info(path) if exit is not None and exit != 'no': + if exit != '0': + job_output = statedb.get_job_output(job_id) + else: + job_output = '' + statedb.set_lorry_last_run_exit_and_output(path, exit, job_output) statedb.set_lorry_last_run(path, int(now)) statedb.set_running_job(path, None) statedb.set_job_exit(job_id, exit, int(now), disk_usage) diff --git a/lorrycontroller/statedb.py b/lorrycontroller/statedb.py index 8c62a31..99ea7fc 100644 --- a/lorrycontroller/statedb.py +++ b/lorrycontroller/statedb.py @@ -440,6 +440,16 @@ class StateDB(object): 'UPDATE lorries SET last_run=? WHERE path=?', (last_run, path)) + def set_lorry_last_run_exit_and_output(self, path, exit, output): + logging.debug( + 'StateDB.set_lorry_last_run_exit_and_output(%r, %r, %r) called', + path, exit, output) + assert self.in_transaction + c = self.get_cursor() + c.execute( + 'UPDATE lorries SET last_run_exit=?, last_run_error=? WHERE path=?', + (exit, output, path)) + def set_lorry_disk_usage(self, path, disk_usage): logging.debug( 'StateDB.set_lorry_disk_usage(%r, %r) called', path, disk_usage) |