=== modified file 'lava-dispatch'
@@ -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'
@@ -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'
@@ -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: