[KVM-AUTOTEST PATCH] Make all programs on kvm test use /usr/bin/python - take 2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



All kvm modules that can be used as stand alone programs were
updated to use #!/usr/bin/python instead of #!/usr/bin/env python,
complying with the rest of the autotest code base. As suggested
by Martin, common.py was added. With this, the stand alone
programs will be able to use the autotest library namespace and
choose the best python interpreter available in the system.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx>
---
 client/tests/kvm/common.py           |    8 ++++++++
 client/tests/kvm/fix_cdkeys.py       |    3 ++-
 client/tests/kvm/kvm_config.py       |    4 +++-
 client/tests/kvm/make_html_report.py |    5 +++--
 client/tests/kvm/stepeditor.py       |    4 ++--
 client/tests/kvm/stepmaker.py        |    4 +++-
 6 files changed, 21 insertions(+), 7 deletions(-)
 create mode 100644 client/tests/kvm/common.py

diff --git a/client/tests/kvm/common.py b/client/tests/kvm/common.py
new file mode 100644
index 0000000..ce78b85
--- /dev/null
+++ b/client/tests/kvm/common.py
@@ -0,0 +1,8 @@
+import os, sys
+dirname = os.path.dirname(sys.modules[__name__].__file__)
+client_dir = os.path.abspath(os.path.join(dirname, "..", ".."))
+sys.path.insert(0, client_dir)
+import setup_modules
+sys.path.pop(0)
+setup_modules.setup(base_path=client_dir,
+                    root_module_name="autotest_lib.client")
diff --git a/client/tests/kvm/fix_cdkeys.py b/client/tests/kvm/fix_cdkeys.py
index 4f7a824..7a821fa 100755
--- a/client/tests/kvm/fix_cdkeys.py
+++ b/client/tests/kvm/fix_cdkeys.py
@@ -1,5 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/python
 import shutil, os, sys
+import common
 
 """
 Program that replaces the CD keys present on a KVM autotest configuration file.
diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py
index 40f16f1..13fdac2 100755
--- a/client/tests/kvm/kvm_config.py
+++ b/client/tests/kvm/kvm_config.py
@@ -1,4 +1,6 @@
+#!/usr/bin/python
 import re, os, sys, StringIO
+import common
 from autotest_lib.client.common_lib import error
 
 """
@@ -356,7 +358,7 @@ class config:
                 # (inside an exception or inside subvariants)
                 if restricted:
                     e_msg = "Using variants in this context is not allowed"
-                    raise error.AutotestError()
+                    raise error.AutotestError(e_msg)
                 if self.debug and not restricted:
                     self.__debug_print(indented_line,
                                      "Entering variants block (%d dicts in"
diff --git a/client/tests/kvm/make_html_report.py b/client/tests/kvm/make_html_report.py
index 6aed39e..e69367b 100755
--- a/client/tests/kvm/make_html_report.py
+++ b/client/tests/kvm/make_html_report.py
@@ -1,4 +1,7 @@
 #!/usr/bin/python
+import os, sys, re, getopt, time, datetime, commands
+import common
+
 """
 Script used to parse the test results and generate an HTML report.
 
@@ -7,8 +10,6 @@ Script used to parse the test results and generate an HTML report.
 @author: Dror Russo (drusso@xxxxxxxxxx)
 """
 
-import os, sys, re, getopt, time, datetime, commands
-
 
 format_css="""
 html,body {
diff --git a/client/tests/kvm/stepeditor.py b/client/tests/kvm/stepeditor.py
index 9669200..e7794ac 100755
--- a/client/tests/kvm/stepeditor.py
+++ b/client/tests/kvm/stepeditor.py
@@ -1,6 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/python
 import pygtk, gtk, os, glob, shutil, sys, logging
-import ppm_utils
+import common, ppm_utils
 pygtk.require('2.0')
 
 """
diff --git a/client/tests/kvm/stepmaker.py b/client/tests/kvm/stepmaker.py
index 2b7fd54..8f16ffd 100644
--- a/client/tests/kvm/stepmaker.py
+++ b/client/tests/kvm/stepmaker.py
@@ -1,8 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/python
 import pygtk, gtk, gobject, time, os, commands
+import common
 from autotest_lib.client.common_lib import error
 import kvm_utils, logging, ppm_utils, stepeditor
 pygtk.require('2.0')
+
 """
 Step file creator/editor.
 
-- 
1.6.2.2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux