summaryrefslogtreecommitdiff
path: root/lorrycontroller/movetopbottom.py
diff options
context:
space:
mode:
Diffstat (limited to 'lorrycontroller/movetopbottom.py')
-rw-r--r--lorrycontroller/movetopbottom.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/lorrycontroller/movetopbottom.py b/lorrycontroller/movetopbottom.py
index 7c1664a..2aeff98 100644
--- a/lorrycontroller/movetopbottom.py
+++ b/lorrycontroller/movetopbottom.py
@@ -26,13 +26,25 @@ class MoveBase(object):
def run(self, **kwargs):
logging.info('%s %s called', self.http_method, self.path)
path = bottle.request.forms.path
+ if not path:
+ return 'Form field path was not given'
statedb = self.open_statedb()
with statedb:
+ if not self.lorry_exists(statedb, path):
+ return 'Lorry %s does not exist' % path
lorry_infos = statedb.get_all_lorries_info()
timestamp = self.get_new_timestamp(lorry_infos)
statedb.set_lorry_last_run(path, timestamp)
return self.msg % path
+ def lorry_exists(self, statedb, path):
+ try:
+ statedb.get_lorry_info(path)
+ except lorrycontroller.LorryNotFoundError:
+ return False
+ else:
+ return True
+
class MoveToTop(MoveBase, lorrycontroller.LorryControllerRoute):