summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lorrycontroller/statedb.py29
1 files changed, 16 insertions, 13 deletions
diff --git a/lorrycontroller/statedb.py b/lorrycontroller/statedb.py
index b2bac7e..8659fc8 100644
--- a/lorrycontroller/statedb.py
+++ b/lorrycontroller/statedb.py
@@ -57,20 +57,20 @@ class StateDB(object):
self._transaction_started = None
self.initial_lorries_fields = [
- ('path', 'TEXT PRIMARY KEY'),
- ('text', 'TEXT'),
- ('from_trovehost', 'TEXT'),
- ('from_path', 'TEXT'),
- ('running_job', 'INT'),
- ('last_run', 'INT'),
- ('interval', 'INT'),
- ('lorry_timeout', 'INT'),
- ('disk_usage', 'INT'),
+ ('path', 'TEXT PRIMARY KEY', None),
+ ('text', 'TEXT', None),
+ ('from_trovehost', 'TEXT', None),
+ ('from_path', 'TEXT', None),
+ ('running_job', 'INT', None),
+ ('last_run', 'INT', None),
+ ('interval', 'INT', None),
+ ('lorry_timeout', 'INT', None),
+ ('disk_usage', 'INT', None),
]
self.lorries_fields = list(self.initial_lorries_fields)
self.lorries_fields.extend([
- ('last_run_exit', 'TEXT'),
- ('last_run_error', 'TEXT'),
+ ('last_run_exit', 'TEXT', None),
+ ('last_run_error', 'TEXT', None),
])
self.lorries_booleans = [
]
@@ -133,7 +133,8 @@ class StateDB(object):
# Table for all the known lorries (the "run queue").
fields_sql = ', '.join(
- '%s %s' % (name, info) for name, info in self.initial_lorries_fields
+ '%s %s' % (column, info)
+ for column, info, key in self.initial_lorries_fields
)
c.execute('CREATE TABLE lorries (%s)' % fields_sql)
@@ -320,7 +321,9 @@ class StateDB(object):
(ls_last_run, trovehost))
def make_lorry_info_from_row(self, row):
- result = dict((t[0], row[i]) for i, t in enumerate(self.lorries_fields))
+ result = dict(
+ (key or column, row[i])
+ for i, (column, info, key) in enumerate(self.lorries_fields))
for field in self.lorries_booleans:
result[field] = bool(result[field])
return result