diff mbox

[Branch,~linaro-validation/lava-test/trunk] Rev 125: Make lava-test usable inside a virtualenv.

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

Commit Message

Zygmunt Krynicki March 6, 2012, 9:58 p.m. UTC
Merge authors:
  Zygmunt Krynicki (zkrynicki)
Related merge proposals:
  https://code.launchpad.net/~zkrynicki/lava-test/fix-annoyances/+merge/96199
  proposed by: Zygmunt Krynicki (zkrynicki)
  review: Approve - Paul Larson (pwlars)
  review: Approve - Michael Hudson-Doyle (mwhudson)
------------------------------------------------------------
revno: 125 [merge]
committer: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
branch nick: trunk
timestamp: Tue 2012-03-06 22:55:31 +0100
message:
  Make lava-test usable inside a virtualenv.
modified:
  doc/changes.rst
  lava_test/commands.py
  lava_test/core/swprofile.py


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

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

Patch

=== modified file 'doc/changes.rst'
--- doc/changes.rst	2012-03-06 12:59:07 +0000
+++ doc/changes.rst	2012-03-06 17:54:26 +0000
@@ -9,6 +9,8 @@ 
  * Allow users to override ``analyzer_assigned_uuid`` by passing
    ``--analyzer-assigned-uuid`` to the run command. This change fixes
    https://bugs.launchpad.net/lava-dispatcher/+bug/934164
+ * Improved error output when running inside virtualenv where the apt and
+   lsb_release modules are not visible to python.
 
 .. _version_0_4:
 

=== modified file 'lava_test/commands.py'
--- lava_test/commands.py	2012-03-06 12:59:07 +0000
+++ lava_test/commands.py	2012-03-06 17:54:26 +0000
@@ -260,11 +260,23 @@ 
         except RuntimeError as ex:
             raise LavaCommandError(str(ex))
         self.say("run complete, result_id is {0!r}", artifacts.result_id)
-        artifacts.create_initial_bundle(
-            self.args.skip_software_context,
-            self.args.skip_hardware_context,
-            self.args.trusted_time,
-            self.args.analyzer_assigned_uuid)
+        try:
+            artifacts.create_initial_bundle(
+                self.args.skip_software_context,
+                self.args.skip_hardware_context,
+                self.args.trusted_time,
+                self.args.analyzer_assigned_uuid)
+        except ImportError as exc:
+            msg_template = (
+                "Unable to probe for software context. Install the '%s'"
+                " package or invoke lava-test run with"
+                " '--skip-software-context'")
+            if exc.message == "No module named apt":
+                raise LavaCommandError(msg_template % "python-apt")
+            elif exc.message == "No module named lsb_release":
+                raise LavaCommandError(msg_template % "lsb-release")
+            else:
+                raise
         artifacts.save_bundle()
         if self.args.output:
             parse_results = test.parse(artifacts)

=== modified file 'lava_test/core/swprofile.py'
--- lava_test/core/swprofile.py	2011-09-12 09:19:10 +0000
+++ lava_test/core/swprofile.py	2012-03-06 17:49:19 +0000
@@ -13,8 +13,6 @@ 
 # 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 apt
-
 from lava_test.utils import read_file
 
 
@@ -23,6 +21,7 @@ 
 
     apt_cache - if not provided, this will be read from the system
     """
+    import apt
     if apt_cache == None:
         apt_cache = apt.Cache()
     packages = []