Skip to contentSkip to conversation

Make all programs on kvm test use /usr/bin/python - take 2

PATCH In review Lucas Meneghel Rodrigues 2 participants 2 messages Jun 10, 2009 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make all programs on kvm test use /usr/bin/python - take 2

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.

---
 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
client/tests/kvm/common.py new file +8 -0
new file mode 100644
index 0000000..ce78b85
@@ -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")
client/tests/kvm/fix_cdkeys.py +2 -1
index 4f7a824..7a821fa 100755
@@ -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.
client/tests/kvm/kvm_config.py +3 -1
index 40f16f1..13fdac2 100755
@@ -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"
client/tests/kvm/make_html_report.py +3 -2
index 6aed39e..e69367b 100755
@@ -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 ([email protected])
 """
 
-import os, sys, re, getopt, time, datetime, commands
-
 
 format_css="""
 html,body {
client/tests/kvm/stepeditor.py +2 -2
index 9669200..e7794ac 100755
@@ -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')
 
 """
client/tests/kvm/stepmaker.py +3 -1
index 2b7fd54..8f16ffd 100644
@@ -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.
 
Signature · 1 line
1.6.2.2
#1 lore raw

Looks good.

Quoted 122 lines · Lucas Meneghel Rodrigues

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.

---
 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

client/tests/kvm/common.py new file +8 -0
new file mode 100644
index 0000000..ce78b85
@@ -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")
client/tests/kvm/fix_cdkeys.py +1 -1
index 4f7a824..7a821fa 100755
@@ -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.

client/tests/kvm/kvm_config.py +1 -0
index 40f16f1..13fdac2 100755
@@ -1,4 +1,6 @@
+#!/usr/bin/python

 import re, os, sys, StringIO
+import common
 from autotest_lib.client.common_lib import error

 """

client/tests/kvm/kvm_config.py +0 -0
@@ -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"

client/tests/kvm/make_html_report.py +3 -0
index 6aed39e..e69367b 100755
@@ -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.

client/tests/kvm/make_html_report.py +0 -0
@@ -7,8 +10,6 @@ Script used to parse the test results and generate an HTML report.
  @author: Dror Russo ([email protected])

 """

client/tests/kvm/make_html_report.py +0 -2
-import os, sys, re, getopt, time, datetime, commands
-

 format_css="""
 html,body {

client/tests/kvm/stepeditor.py +1 -1
index 9669200..e7794ac 100755
@@ -1,6 +1,6 @@
-#!/usr/bin/env python
+#!/usr/bin/python

 import pygtk, gtk, os, glob, shutil, sys, logging

client/tests/kvm/stepeditor.py +1 -1
-import ppm_utils
+import common, ppm_utils

 pygtk.require('2.0')

 """

client/tests/kvm/stepmaker.py +1 -1
index 2b7fd54..8f16ffd 100644
@@ -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

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest