diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 518: Better handling of target devices on command line

Message ID 20130104191111.27286.35841.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Antonio Terceiro Jan. 4, 2013, 7:11 p.m. UTC
------------------------------------------------------------
revno: 518
committer: Antonio Terceiro <antonio.terceiro@linaro.org>
branch nick: better-target-cmdline-handling
timestamp: Fri 2013-01-04 11:35:51 -0300
message:
  Better handling of target devices on command line
  
  If the job file does not specify a target device and no target was specified on
  the command line, print an error message instead of crashing with KeyError.
modified:
  lava/dispatcher/commands.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava/dispatcher/commands.py'
--- lava/dispatcher/commands.py	2012-12-20 16:59:51 +0000
+++ lava/dispatcher/commands.py	2013-01-04 14:35:51 +0000
@@ -102,8 +102,13 @@ 
         # Load the scenario file
         with open(self.args.job_file) as stream:
             jobdata = stream.read()
-        if self.args.target is not None:
             json_jobdata = json.loads(jobdata)
+
+        if self.args.target is None:
+            if 'target' not in json_jobdata:
+                logging.error("The job file does not specify a target device. You must inform one using the --target option.")
+                exit(1)
+        else:
             json_jobdata['target'] = self.args.target
             jobdata = json.dumps(json_jobdata)
         job = LavaTestJob(jobdata, oob_file, config)