All of lore.kernel.org
 help / color / mirror / Atom feed
* [KVM-AUTOTEST PATCH] Make all programs on kvm test use /usr/bin/python - take 2
@ 2009-06-10  0:57 Lucas Meneghel Rodrigues
  2009-06-10 15:05 ` [Autotest] " Martin Bligh
  0 siblings, 1 reply; 2+ messages in thread
From: Lucas Meneghel Rodrigues @ 2009-06-10  0:57 UTC (permalink / raw)
  To: autotest; +Cc: kvm, 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.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
 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@redhat.com)
 """
 
-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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Autotest] [KVM-AUTOTEST PATCH] Make all programs on kvm test use /usr/bin/python - take 2
  2009-06-10  0:57 [KVM-AUTOTEST PATCH] Make all programs on kvm test use /usr/bin/python - take 2 Lucas Meneghel Rodrigues
@ 2009-06-10 15:05 ` Martin Bligh
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Bligh @ 2009-06-10 15:05 UTC (permalink / raw)
  To: Lucas Meneghel Rodrigues; +Cc: autotest, kvm

Looks good.

On Tue, Jun 9, 2009 at 5:57 PM, Lucas Meneghel Rodrigues<lmr@redhat.com> wrote:
> 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@redhat.com>
> ---
>  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@redhat.com)
>  """
>
> -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
>
> _______________________________________________
> Autotest mailing list
> Autotest@test.kernel.org
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-06-10 15:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-10  0:57 [KVM-AUTOTEST PATCH] Make all programs on kvm test use /usr/bin/python - take 2 Lucas Meneghel Rodrigues
2009-06-10 15:05 ` [Autotest] " Martin Bligh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.