[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 92: print out the URL of the bundle submitted on a specific fd (default: stderr)

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

Commit Message

Michael-Doyle Hudson Aug. 22, 2011, 9:17 p.m.
Merge authors:
  Michael Hudson-Doyle (mwhudson)
Related merge proposals:
  https://code.launchpad.net/~mwhudson/lava-dispatcher/output-result-sha1/+merge/71640
  proposed by: Michael Hudson-Doyle (mwhudson)
  review: Approve - Zygmunt Krynicki (zkrynicki)
  review: Needs Fixing - Spring Zhang (qzhang)
------------------------------------------------------------
revno: 92 [merge]
committer: Michael-Doyle Hudson <michael.hudson@linaro.org>
branch nick: trunk
timestamp: Tue 2011-08-23 09:15:01 +1200
message:
  print out the URL of the bundle submitted on a specific fd (default: stderr)
modified:
  lava-dispatch
  lava_dispatcher/__init__.py
  lava_dispatcher/actions/launch_control.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

Patch

=== modified file 'lava-dispatch'
--- lava-dispatch	2011-06-27 04:55:08 +0000
+++ lava-dispatch	2011-08-17 00:52:46 +0000
@@ -19,24 +19,31 @@ 
 # You should have received a copy of the GNU General Public License along
 # with this program; if not, see <http://www.gnu.org/licenses>.
 
+import optparse
+import os
 import sys
 
 from lava_dispatcher import LavaTestJob
 
 
-def usage(status):
-    print >> sys.stderr, "Usage:\n    lava-dispatch <json job file>"
-    sys.exit(status)
-
-if len(sys.argv) != 2:
-    usage(1)
-
-if sys.argv[1] == "--help":
-    usage(0)
-
-with open(sys.argv[1]) as fd:
+parser = optparse.OptionParser('%prog: lava-dispatch <json job file>')
+parser.add_option(
+    "--oob-fd", default=None, type=int, help="Write OOB data to this fd.")
+
+(options, args) = parser.parse_args()
+
+if len(args) != 1:
+    parser.print_help()
+    sys.exit(1)
+
+if options.oob_fd:
+    oob_file = os.fdopen(options.oob_fd, 'w')
+else:
+    oob_file = sys.stderr
+
+with open(args[0]) as fd:
     jobdata = fd.read()
 
-job = LavaTestJob(jobdata)
+job = LavaTestJob(jobdata, oob_file)
 #FIXME Return status
 job.run()

=== modified file 'lava_dispatcher/__init__.py'
--- lava_dispatcher/__init__.py	2011-08-20 02:17:57 +0000
+++ lava_dispatcher/__init__.py	2011-08-22 21:13:22 +0000
@@ -33,10 +33,10 @@ 
 __version__ = "0.2.0"
 
 class LavaTestJob(object):
-    def __init__(self, job_json):
+    def __init__(self, job_json, oob_file):
         self.job_status = 'pass'
         self.load_job_data(job_json)
-        self.context = LavaContext(self.target, self.image_type)
+        self.context = LavaContext(self.target, self.image_type, oob_file)
 
     def load_job_data(self, job_json):
         self.job_data = json.loads(job_json)
@@ -104,12 +104,13 @@ 
 
 
 class LavaContext(object):
-    def __init__(self, target, image_type):
+    def __init__(self, target, image_type, oob_file):
         if image_type != "android":
             self._client = LavaClient(target)
         else:
             self._client = LavaAndroidClient(target)
         self.test_data = LavaTestData()
+        self.oob_file = oob_file
 
     @property
     def client(self):

=== modified file 'lava_dispatcher/actions/launch_control.py'
--- lava_dispatcher/actions/launch_control.py	2011-08-16 00:15:08 +0000
+++ lava_dispatcher/actions/launch_control.py	2011-08-17 10:36:29 +0000
@@ -47,7 +47,8 @@ 
             content = f.read()
             f.close()
             try:
-                srv.put(content, bundle, stream)
+                print >> self.context.oob_file, 'dashboard-put-result:', \
+                      srv.put_ex(content, bundle, stream)
             except xmlrpclib.Fault, err:
                 print "xmlrpclib.Fault occurred"
                 print "Fault code: %d" % err.faultCode
@@ -131,7 +132,8 @@ 
             attributes.update(self.context.test_data.get_metadata())
             test_run['attributes'] = attributes
         json_bundle = json.dumps(main_bundle)
-        srv.put(json_bundle, 'lava-dispatcher.bundle', stream)
+        print >> self.context.oob_file, 'dashboard-put-result:', \
+              srv.put_ex(json_bundle, 'lava-dispatcher.bundle', stream)
 
     def combine_bundles(self):
         if not self.all_bundles: