diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 458: use linaro-dashboard-bundle classes to ensure the submitted bundle is both valid and in the lates...

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

Commit Message

Michael-Doyle Hudson Nov. 19, 2012, 8:55 p.m. UTC
Merge authors:
  Michael Hudson-Doyle (mwhudson)
Related merge proposals:
  https://code.launchpad.net/~mwhudson/lava-dispatcher/evolve-bundles-before-merging/+merge/135001
  proposed by: Michael Hudson-Doyle (mwhudson)
  review: Approve - Andy Doan (doanac)
------------------------------------------------------------
revno: 458 [merge]
committer: Michael Hudson-Doyle <michael.hudson@linaro.org>
branch nick: trunk
timestamp: Tue 2012-11-20 09:54:31 +1300
message:
  use linaro-dashboard-bundle classes to ensure the submitted bundle is both valid and in the latest format
modified:
  lava_dispatcher/actions/launch_control.py
  setup.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/actions/launch_control.py'
--- lava_dispatcher/actions/launch_control.py	2012-11-08 23:35:16 +0000
+++ lava_dispatcher/actions/launch_control.py	2012-11-19 20:32:14 +0000
@@ -19,20 +19,21 @@ 
 # 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 json
 import os
 import logging
 import tempfile
 import urlparse
 import xmlrpclib
 
-import lava_dispatcher.utils as utils
-
 from lava_tool.authtoken import AuthenticatingServerProxy, MemoryAuthBackend
 
+from linaro_dashboard_bundle.io import DocumentIO
+from linaro_dashboard_bundle.evolution import DocumentEvolution
+
 from lava_dispatcher.actions import BaseAction
 from lava_dispatcher.client.base import OperationFailed
 from lava_dispatcher.test_data import create_attachment
+import lava_dispatcher.utils as utils
 
 
 class GatherResultsError(Exception):
@@ -108,8 +109,9 @@ 
             content = None
             try:
                 with open(fname, 'r') as f:
-                    content = f.read()
-                    bundles.append(json.loads(content))
+                    doc = DocumentIO.load(f)[1]
+                DocumentEvolution.evolve_document(doc)
+                bundles.append(doc)
             except ValueError:
                 msg = 'Error adding result bundle %s' % fname
                 errors.append(msg)
@@ -153,10 +155,10 @@ 
                 bundle = "%s/%s" % (self.context.host_result_dir, bundle_name)
                 content = None
                 try:
-                    f = open(bundle)
-                    content = f.read()
-                    f.close()
-                    bundles.append(json.loads(content))
+                    with open(bundle) as f:
+                        doc = DocumentIO.load(f)[1]
+                    DocumentEvolution.evolve_document(doc)
+                    bundles.append(doc)
                 except ValueError:
                     msg = 'Error adding host result bundle %s' % bundle
                     errors.append(msg)
@@ -229,7 +231,7 @@ 
 
     def submit_bundle(self, main_bundle, server, stream, token):
         dashboard = _get_dashboard(server, token)
-        json_bundle = json.dumps(main_bundle)
+        json_bundle = DocumentIO.dumps(main_bundle)
         job_name = self.context.job_data.get('job_name', "LAVA Results")
         try:
             result = dashboard.put_ex(json_bundle, job_name, stream)

=== modified file 'setup.py'
--- setup.py	2012-11-19 20:04:52 +0000
+++ setup.py	2012-11-19 20:21:20 +0000
@@ -41,6 +41,7 @@ 
         "json-schema-validator >= 2.3",
         "lava-tool >= 0.4",
         "lava-utils-interface",
+        "linaro-dashboard-bundle",
         "pexpect >= 2.3",
         "configglue",
         "PyYAML",