public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [KVM-AUTOTEST PATCH 1/4] Make all programs on kvm test use /usr/bin/python
@ 2009-06-09 16:33 Lucas Meneghel Rodrigues
  2009-06-09 16:33 ` [KVM-AUTOTEST PATCH 2/4] Make kvm_config.py to use internal/standard exeptions Lucas Meneghel Rodrigues
  2009-06-09 17:00 ` [Autotest] [KVM-AUTOTEST PATCH 1/4] Make all programs on kvm test use /usr/bin/python Martin Bligh
  0 siblings, 2 replies; 14+ messages in thread
From: Lucas Meneghel Rodrigues @ 2009-06-09 16:33 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.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
 client/tests/kvm/fix_cdkeys.py   |    2 +-
 client/tests/kvm/kvm_config.py   |    1 +
 client/tests/kvm/scan_results.py |    2 +-
 client/tests/kvm/stepeditor.py   |    2 +-
 client/tests/kvm/stepmaker.py    |    2 +-
 5 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/client/tests/kvm/fix_cdkeys.py b/client/tests/kvm/fix_cdkeys.py
index 4f7a824..7f52c44 100755
--- a/client/tests/kvm/fix_cdkeys.py
+++ b/client/tests/kvm/fix_cdkeys.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python
 import shutil, os, sys
 
 """
diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py
index 40f16f1..a3467a0 100755
--- a/client/tests/kvm/kvm_config.py
+++ b/client/tests/kvm/kvm_config.py
@@ -1,3 +1,4 @@
+#!/usr/bin/python
 import re, os, sys, StringIO
 from autotest_lib.client.common_lib import error
 
diff --git a/client/tests/kvm/scan_results.py b/client/tests/kvm/scan_results.py
index 156b7d4..a92c867 100755
--- a/client/tests/kvm/scan_results.py
+++ b/client/tests/kvm/scan_results.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python
 """
 Program that parses the autotest results and return a nicely printed final test
 result.
diff --git a/client/tests/kvm/stepeditor.py b/client/tests/kvm/stepeditor.py
index 9669200..6fb371b 100755
--- a/client/tests/kvm/stepeditor.py
+++ b/client/tests/kvm/stepeditor.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python
 import pygtk, gtk, os, glob, shutil, sys, logging
 import ppm_utils
 pygtk.require('2.0')
diff --git a/client/tests/kvm/stepmaker.py b/client/tests/kvm/stepmaker.py
index 2b7fd54..a9ddf25 100644
--- a/client/tests/kvm/stepmaker.py
+++ b/client/tests/kvm/stepmaker.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python
 import pygtk, gtk, gobject, time, os, commands
 from autotest_lib.client.common_lib import error
 import kvm_utils, logging, ppm_utils, stepeditor
-- 
1.6.2.2


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

* [KVM-AUTOTEST PATCH 2/4] Make kvm_config.py to use internal/standard exeptions
  2009-06-09 16:33 [KVM-AUTOTEST PATCH 1/4] Make all programs on kvm test use /usr/bin/python Lucas Meneghel Rodrigues
@ 2009-06-09 16:33 ` Lucas Meneghel Rodrigues
  2009-06-09 16:33   ` [KVM-AUTOTEST PATCH 3/4] Fix bad line breaks Lucas Meneghel Rodrigues
  2009-06-10 12:21   ` [Autotest] [KVM-AUTOTEST PATCH 2/4] Make kvm_config.py to use internal/standard exeptions Michael Goldish
  2009-06-09 17:00 ` [Autotest] [KVM-AUTOTEST PATCH 1/4] Make all programs on kvm test use /usr/bin/python Martin Bligh
  1 sibling, 2 replies; 14+ messages in thread
From: Lucas Meneghel Rodrigues @ 2009-06-09 16:33 UTC (permalink / raw)
  To: autotest; +Cc: kvm, Lucas Meneghel Rodrigues

Instead of resorting to internal autotest exception types, use
either python standard exceptions or an internally defined
ConfigError exception.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
 client/tests/kvm/kvm_config.py |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py
index a3467a0..cce931a 100755
--- a/client/tests/kvm/kvm_config.py
+++ b/client/tests/kvm/kvm_config.py
@@ -8,6 +8,11 @@ KVM configuration file utility functions.
 @copyright: Red Hat 2008-2009
 """
 
+
+class ConfigError(Exception):
+    pass
+
+
 class config:
     """
     Parse an input file or string that follows the KVM Test Config File format
@@ -47,7 +52,7 @@ class config:
             @param filename: Path of the configuration file.
         """
         if not os.path.exists(filename):
-            raise Exception, "File %s not found" % filename
+            raise IOError("File %s not found" % filename)
         self.filename = filename
         file = open(filename, "r")
         self.list = self.parse(file, self.list)
@@ -357,7 +362,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 ConfigError(e_msg)
                 if self.debug and not restricted:
                     self.__debug_print(indented_line,
                                      "Entering variants block (%d dicts in"
@@ -402,7 +407,7 @@ class config:
                                             words[1])
                     if not os.path.exists(filename):
                         e_msg = "Cannot include %s -- file not found" % filename
-                        raise error.AutotestError(e_msg)
+                        raise ConfigError(e_msg)
                     new_file = open(filename, "r")
                     list = self.parse(new_file, list, restricted)
                     new_file.close()
@@ -410,7 +415,7 @@ class config:
                         self.__debug_print("", "Leaving file %s" % words[1])
                 else:
                     e_msg = "Cannot include anything because no file is open"
-                    raise error.AutotestError(e_msg)
+                    raise ConfigError(e_msg)
 
             # Parse multi-line exceptions
             # (the block is parsed for each dict separately)
-- 
1.6.2.2


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

* [KVM-AUTOTEST PATCH 3/4] Fix bad line breaks
  2009-06-09 16:33 ` [KVM-AUTOTEST PATCH 2/4] Make kvm_config.py to use internal/standard exeptions Lucas Meneghel Rodrigues
@ 2009-06-09 16:33   ` Lucas Meneghel Rodrigues
  2009-06-09 16:33     ` [KVM-AUTOTEST PATCH 4/4] Fix bad logging calls Lucas Meneghel Rodrigues
  2009-06-10 12:32     ` [KVM-AUTOTEST PATCH 3/4] Fix bad line breaks Michael Goldish
  2009-06-10 12:21   ` [Autotest] [KVM-AUTOTEST PATCH 2/4] Make kvm_config.py to use internal/standard exeptions Michael Goldish
  1 sibling, 2 replies; 14+ messages in thread
From: Lucas Meneghel Rodrigues @ 2009-06-09 16:33 UTC (permalink / raw)
  To: autotest; +Cc: kvm, Lucas Meneghel Rodrigues

During the conversion of the kvm_runtest_2 to the kvm test, some
bad line breaks were introduced. Started using parenthesis
implicit line continuation instead of backslash continuation in
assignments that were using it.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
 client/tests/kvm/kvm_guest_wizard.py |    8 ++++----
 client/tests/kvm/kvm_tests.py        |    4 ++--
 client/tests/kvm/kvm_utils.py        |   12 ++++++------
 client/tests/kvm/kvm_vm.py           |    4 ++--
 client/tests/kvm/make_html_report.py |    6 ++----
 5 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/client/tests/kvm/kvm_guest_wizard.py b/client/tests/kvm/kvm_guest_wizard.py
index 01aeb97..2dd9be5 100644
--- a/client/tests/kvm/kvm_guest_wizard.py
+++ b/client/tests/kvm/kvm_guest_wizard.py
@@ -105,8 +105,8 @@ def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history,
         time.sleep(sleep_duration)
 
     # Failure
-    message = "Barrier failed at step %s after %.2f seconds (%s)" % \
-            (current_step_num, time.time() - start_time, failure_message)
+    message = ("Barrier failed at step %s after %.2f seconds (%s)" %
+               (current_step_num, time.time() - start_time, failure_message))
 
     # What should we do with this failure?
     if words[-1] == "optional":
@@ -201,9 +201,9 @@ def run_steps(test, params, env):
                 logging.error("Variable not defined: %s" % words[1])
         elif words[0] == "barrier_2":
             if current_screendump:
-                scrdump_filename = \
+                scrdump_filename = (
                 os.path.join(ppm_utils.get_data_dir(steps_filename),
-                             current_screendump)
+                             current_screendump))
             else:
                 scrdump_filename = None
             if not barrier_2(vm, words, fail_if_stuck_for,
diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
index cccc48e..54d2a7a 100644
--- a/client/tests/kvm/kvm_tests.py
+++ b/client/tests/kvm/kvm_tests.py
@@ -321,8 +321,8 @@ def run_autotest(test, params, env):
     status_fail = False
     if result_list == []:
         status_fail = True
-        message_fail = "Test '%s' did not produce any recognizable"
-        " results" % test_name
+        message_fail = ("Test '%s' did not produce any recognizable "
+                        "results" % test_name)
     for result in result_list:
         logging.info(str(result))
         if result[1] == "FAIL":
diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index 434190d..0f4c770 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -644,8 +644,8 @@ def scp_to_remote(host, port, username, password, local_path, remote_path,
 
     @return: True on success and False on failure.
     """
-    command = "scp -o UserKnownHostsFile=/dev/null -r -P %s %s %s@%s:%s" % \
-        (port, local_path, username, host, remote_path)
+    command = ("scp -o UserKnownHostsFile=/dev/null -r -P %s %s %s@%s:%s" %
+               (port, local_path, username, host, remote_path))
     return remote_scp(command, password, timeout)
 
 
@@ -664,8 +664,8 @@ def scp_from_remote(host, port, username, password, remote_path, local_path,
 
     @return: True on success and False on failure.
     """
-    command = "scp -o UserKnownHostsFile=/dev/null -r -P %s %s@%s:%s %s" % \
-        (port, username, host, remote_path, local_path)
+    command = ("scp -o UserKnownHostsFile=/dev/null -r -P %s %s@%s:%s %s" %
+               (port, username, host, remote_path, local_path))
     return remote_scp(command, password, timeout)
 
 
@@ -681,8 +681,8 @@ def ssh(host, port, username, password, prompt, timeout=10):
 
     @return: kvm_spawn object on success and None on failure.
     """
-    command = "ssh -o UserKnownHostsFile=/dev/null -p %s %s@%s" % \
-        (port, username, host)
+    command = ("ssh -o UserKnownHostsFile=/dev/null -p %s %s@%s" %
+               (port, username, host))
     return remote_login(command, password, prompt, "\n", timeout)
 
 
diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index eb9717b..de21b2f 100644
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -118,8 +118,8 @@ class VM:
         # Find available monitor filename
         while True:
             # The monitor filename should be unique
-            self.instance = time.strftime("%Y%m%d-%H%M%S-") + \
-            kvm_utils.generate_random_string(4)
+            self.instance = (time.strftime("%Y%m%d-%H%M%S-") +
+                             kvm_utils.generate_random_string(4))
             self.monitor_file_name = os.path.join("/tmp",
                                                   "monitor-" + self.instance)
             if not os.path.exists(self.monitor_file_name):
diff --git a/client/tests/kvm/make_html_report.py b/client/tests/kvm/make_html_report.py
index 6aed39e..7fb54e5 100755
--- a/client/tests/kvm/make_html_report.py
+++ b/client/tests/kvm/make_html_report.py
@@ -1442,10 +1442,8 @@ return true;
     stat_str = 'No test cases executed'
     if total_executed>0:
         failed_perct = int(float(total_failed)/float(total_executed)*100)
-        stat_str = 'From %d tests executed, '
-        '%d have passed (%d%s)' % (total_executed, total_passed,failed_perct,
-                                   '% failures')
-
+        stat_str = ('From %d tests executed, %d have passed (%d%% failures)' %
+                    (total_executed, total_passed, failed_perct))
 
     kvm_ver_str = metadata['kvmver']
 
-- 
1.6.2.2


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

* [KVM-AUTOTEST PATCH 4/4] Fix bad logging calls
  2009-06-09 16:33   ` [KVM-AUTOTEST PATCH 3/4] Fix bad line breaks Lucas Meneghel Rodrigues
@ 2009-06-09 16:33     ` Lucas Meneghel Rodrigues
  2009-06-10 12:32     ` [KVM-AUTOTEST PATCH 3/4] Fix bad line breaks Michael Goldish
  1 sibling, 0 replies; 14+ messages in thread
From: Lucas Meneghel Rodrigues @ 2009-06-09 16:33 UTC (permalink / raw)
  To: autotest; +Cc: kvm, Lucas Meneghel Rodrigues

During the conversion of kvm autotest to upstream coding standards,
some bad logging calls were left behind. This patch fixes them.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
 client/tests/kvm/kvm_utils.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index 0f4c770..70a49c9 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -304,7 +304,7 @@ class kvm_spawn:
 
         # Print some debugging info
         if match == None and self.poll() != 0:
-            logging.debug("Timeout elapsed or process terminated. Output:",
+            logging.debug("Timeout elapsed or process terminated. Output:%s",
                           format_str_for_message(data.strip()))
 
         return (match, data)
@@ -465,8 +465,8 @@ class kvm_spawn:
 
         # Print some debugging info
         if status != 0:
-            logging.debug("Command failed; status: %d, output:" % status \
-                    + format_str_for_message(output.strip()))
+            logging.debug("Command failed; status: %d, output:%s", status,
+                          format_str_for_message(output.strip()))
 
         return (status, output)
 
-- 
1.6.2.2


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

* Re: [Autotest] [KVM-AUTOTEST PATCH 1/4] Make all programs on kvm test use /usr/bin/python
  2009-06-09 16:33 [KVM-AUTOTEST PATCH 1/4] Make all programs on kvm test use /usr/bin/python Lucas Meneghel Rodrigues
  2009-06-09 16:33 ` [KVM-AUTOTEST PATCH 2/4] Make kvm_config.py to use internal/standard exeptions Lucas Meneghel Rodrigues
@ 2009-06-09 17:00 ` Martin Bligh
  2009-06-10  0:59   ` Lucas Meneghel Rodrigues
  1 sibling, 1 reply; 14+ messages in thread
From: Martin Bligh @ 2009-06-09 17:00 UTC (permalink / raw)
  To: Lucas Meneghel Rodrigues; +Cc: autotest, kvm

I'd suggest you use the same mechanism as the other entry points,
and override the python version where necessary - some distros
have ancient or bleeding edge default Python versions.

see common.py -> setup_modules.py -> check_version.check_python_version

On Tue, Jun 9, 2009 at 9:33 AM, 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.
>
> Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
> ---
>  client/tests/kvm/fix_cdkeys.py   |    2 +-
>  client/tests/kvm/kvm_config.py   |    1 +
>  client/tests/kvm/scan_results.py |    2 +-
>  client/tests/kvm/stepeditor.py   |    2 +-
>  client/tests/kvm/stepmaker.py    |    2 +-
>  5 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/client/tests/kvm/fix_cdkeys.py b/client/tests/kvm/fix_cdkeys.py
> index 4f7a824..7f52c44 100755
> --- a/client/tests/kvm/fix_cdkeys.py
> +++ b/client/tests/kvm/fix_cdkeys.py
> @@ -1,4 +1,4 @@
> -#!/usr/bin/env python
> +#!/usr/bin/python
>  import shutil, os, sys
>
>  """
> diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py
> index 40f16f1..a3467a0 100755
> --- a/client/tests/kvm/kvm_config.py
> +++ b/client/tests/kvm/kvm_config.py
> @@ -1,3 +1,4 @@
> +#!/usr/bin/python
>  import re, os, sys, StringIO
>  from autotest_lib.client.common_lib import error
>
> diff --git a/client/tests/kvm/scan_results.py b/client/tests/kvm/scan_results.py
> index 156b7d4..a92c867 100755
> --- a/client/tests/kvm/scan_results.py
> +++ b/client/tests/kvm/scan_results.py
> @@ -1,4 +1,4 @@
> -#!/usr/bin/env python
> +#!/usr/bin/python
>  """
>  Program that parses the autotest results and return a nicely printed final test
>  result.
> diff --git a/client/tests/kvm/stepeditor.py b/client/tests/kvm/stepeditor.py
> index 9669200..6fb371b 100755
> --- a/client/tests/kvm/stepeditor.py
> +++ b/client/tests/kvm/stepeditor.py
> @@ -1,4 +1,4 @@
> -#!/usr/bin/env python
> +#!/usr/bin/python
>  import pygtk, gtk, os, glob, shutil, sys, logging
>  import ppm_utils
>  pygtk.require('2.0')
> diff --git a/client/tests/kvm/stepmaker.py b/client/tests/kvm/stepmaker.py
> index 2b7fd54..a9ddf25 100644
> --- a/client/tests/kvm/stepmaker.py
> +++ b/client/tests/kvm/stepmaker.py
> @@ -1,4 +1,4 @@
> -#!/usr/bin/env python
> +#!/usr/bin/python
>  import pygtk, gtk, gobject, time, os, commands
>  from autotest_lib.client.common_lib import error
>  import kvm_utils, logging, ppm_utils, stepeditor
> --
> 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] 14+ messages in thread

* Re: [Autotest] [KVM-AUTOTEST PATCH 1/4] Make all programs on kvm test  use /usr/bin/python
  2009-06-09 17:00 ` [Autotest] [KVM-AUTOTEST PATCH 1/4] Make all programs on kvm test use /usr/bin/python Martin Bligh
@ 2009-06-10  0:59   ` Lucas Meneghel Rodrigues
  2009-06-10 11:01     ` Alexey Eromenko
  0 siblings, 1 reply; 14+ messages in thread
From: Lucas Meneghel Rodrigues @ 2009-06-10  0:59 UTC (permalink / raw)
  To: Martin Bligh; +Cc: autotest, kvm

On Tue, 2009-06-09 at 10:00 -0700, Martin Bligh wrote:
> I'd suggest you use the same mechanism as the other entry points,
> and override the python version where necessary - some distros
> have ancient or bleeding edge default Python versions.
> 
> see common.py -> setup_modules.py -> check_version.check_python_version

Done. Re-sent the patch of the stand alone programs. Thanks!

> On Tue, Jun 9, 2009 at 9:33 AM, 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.
> >
> > Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
> > ---
> >  client/tests/kvm/fix_cdkeys.py   |    2 +-
> >  client/tests/kvm/kvm_config.py   |    1 +
> >  client/tests/kvm/scan_results.py |    2 +-
> >  client/tests/kvm/stepeditor.py   |    2 +-
> >  client/tests/kvm/stepmaker.py    |    2 +-
> >  5 files changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/client/tests/kvm/fix_cdkeys.py b/client/tests/kvm/fix_cdkeys.py
> > index 4f7a824..7f52c44 100755
> > --- a/client/tests/kvm/fix_cdkeys.py
> > +++ b/client/tests/kvm/fix_cdkeys.py
> > @@ -1,4 +1,4 @@
> > -#!/usr/bin/env python
> > +#!/usr/bin/python
> >  import shutil, os, sys
> >
> >  """
> > diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py
> > index 40f16f1..a3467a0 100755
> > --- a/client/tests/kvm/kvm_config.py
> > +++ b/client/tests/kvm/kvm_config.py
> > @@ -1,3 +1,4 @@
> > +#!/usr/bin/python
> >  import re, os, sys, StringIO
> >  from autotest_lib.client.common_lib import error
> >
> > diff --git a/client/tests/kvm/scan_results.py b/client/tests/kvm/scan_results.py
> > index 156b7d4..a92c867 100755
> > --- a/client/tests/kvm/scan_results.py
> > +++ b/client/tests/kvm/scan_results.py
> > @@ -1,4 +1,4 @@
> > -#!/usr/bin/env python
> > +#!/usr/bin/python
> >  """
> >  Program that parses the autotest results and return a nicely printed final test
> >  result.
> > diff --git a/client/tests/kvm/stepeditor.py b/client/tests/kvm/stepeditor.py
> > index 9669200..6fb371b 100755
> > --- a/client/tests/kvm/stepeditor.py
> > +++ b/client/tests/kvm/stepeditor.py
> > @@ -1,4 +1,4 @@
> > -#!/usr/bin/env python
> > +#!/usr/bin/python
> >  import pygtk, gtk, os, glob, shutil, sys, logging
> >  import ppm_utils
> >  pygtk.require('2.0')
> > diff --git a/client/tests/kvm/stepmaker.py b/client/tests/kvm/stepmaker.py
> > index 2b7fd54..a9ddf25 100644
> > --- a/client/tests/kvm/stepmaker.py
> > +++ b/client/tests/kvm/stepmaker.py
> > @@ -1,4 +1,4 @@
> > -#!/usr/bin/env python
> > +#!/usr/bin/python
> >  import pygtk, gtk, gobject, time, os, commands
> >  from autotest_lib.client.common_lib import error
> >  import kvm_utils, logging, ppm_utils, stepeditor
> > --
> > 1.6.2.2
> >
> > _______________________________________________
> > Autotest mailing list
> > Autotest@test.kernel.org
> > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
> >
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Lucas Meneghel Rodrigues
Software Engineer (QE)
Red Hat - Emerging Technologies


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

* Re: [Autotest] [KVM-AUTOTEST PATCH 1/4] Make all programs on kvm test  use /usr/bin/python
  2009-06-10  0:59   ` Lucas Meneghel Rodrigues
@ 2009-06-10 11:01     ` Alexey Eromenko
  2009-06-10 14:19       ` Martin Bligh
  0 siblings, 1 reply; 14+ messages in thread
From: Alexey Eromenko @ 2009-06-10 11:01 UTC (permalink / raw)
  To: Lucas Meneghel Rodrigues; +Cc: autotest, kvm, Martin Bligh


Even better would be to use "/usr/bin/python2".

This is because future distros will include python3, which is incompatible with python2 code.

"python" will be symlink of "python3".

-Alexey

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

* Re: [Autotest] [KVM-AUTOTEST PATCH 2/4] Make kvm_config.py to use internal/standard exeptions
  2009-06-09 16:33 ` [KVM-AUTOTEST PATCH 2/4] Make kvm_config.py to use internal/standard exeptions Lucas Meneghel Rodrigues
  2009-06-09 16:33   ` [KVM-AUTOTEST PATCH 3/4] Fix bad line breaks Lucas Meneghel Rodrigues
@ 2009-06-10 12:21   ` Michael Goldish
  2009-06-10 12:36     ` Michael Goldish
  1 sibling, 1 reply; 14+ messages in thread
From: Michael Goldish @ 2009-06-10 12:21 UTC (permalink / raw)
  To: Lucas Meneghel Rodrigues; +Cc: kvm, autotest

Looks fine to me.

BTW, I think debug_print() should be prefixed by a single underscore, not two.
A double underscore should be used only when name mangling is required -- at least that's what I understood from PEP 8.
Let me know what you think.

Thanks,
Michael

----- Original Message -----
From: "Lucas Meneghel Rodrigues" <lmr@redhat.com>
To: autotest@test.kernel.org
Cc: kvm@vger.kernel.org
Sent: Tuesday, June 9, 2009 7:33:27 PM (GMT+0200) Auto-Detected
Subject: [Autotest] [KVM-AUTOTEST PATCH 2/4] Make kvm_config.py to use internal/standard exeptions

Instead of resorting to internal autotest exception types, use
either python standard exceptions or an internally defined
ConfigError exception.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
 client/tests/kvm/kvm_config.py |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py
index a3467a0..cce931a 100755
--- a/client/tests/kvm/kvm_config.py
+++ b/client/tests/kvm/kvm_config.py
@@ -8,6 +8,11 @@ KVM configuration file utility functions.
 @copyright: Red Hat 2008-2009
 """
 
+
+class ConfigError(Exception):
+    pass
+
+
 class config:
     """
     Parse an input file or string that follows the KVM Test Config File format
@@ -47,7 +52,7 @@ class config:
             @param filename: Path of the configuration file.
         """
         if not os.path.exists(filename):
-            raise Exception, "File %s not found" % filename
+            raise IOError("File %s not found" % filename)
         self.filename = filename
         file = open(filename, "r")
         self.list = self.parse(file, self.list)
@@ -357,7 +362,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 ConfigError(e_msg)
                 if self.debug and not restricted:
                     self.__debug_print(indented_line,
                                      "Entering variants block (%d dicts in"
@@ -402,7 +407,7 @@ class config:
                                             words[1])
                     if not os.path.exists(filename):
                         e_msg = "Cannot include %s -- file not found" % filename
-                        raise error.AutotestError(e_msg)
+                        raise ConfigError(e_msg)
                     new_file = open(filename, "r")
                     list = self.parse(new_file, list, restricted)
                     new_file.close()
@@ -410,7 +415,7 @@ class config:
                         self.__debug_print("", "Leaving file %s" % words[1])
                 else:
                     e_msg = "Cannot include anything because no file is open"
-                    raise error.AutotestError(e_msg)
+                    raise ConfigError(e_msg)
 
             # Parse multi-line exceptions
             # (the block is parsed for each dict separately)
-- 
1.6.2.2

_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

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

* Re: [KVM-AUTOTEST PATCH 3/4] Fix bad line breaks
  2009-06-09 16:33   ` [KVM-AUTOTEST PATCH 3/4] Fix bad line breaks Lucas Meneghel Rodrigues
  2009-06-09 16:33     ` [KVM-AUTOTEST PATCH 4/4] Fix bad logging calls Lucas Meneghel Rodrigues
@ 2009-06-10 12:32     ` Michael Goldish
  1 sibling, 0 replies; 14+ messages in thread
From: Michael Goldish @ 2009-06-10 12:32 UTC (permalink / raw)
  To: Lucas Meneghel Rodrigues; +Cc: kvm, autotest

Looks fine to me.

----- Original Message -----
From: "Lucas Meneghel Rodrigues" <lmr@redhat.com>
To: autotest@test.kernel.org
Cc: kvm@vger.kernel.org, "Lucas Meneghel Rodrigues" <lmr@redhat.com>
Sent: Tuesday, June 9, 2009 7:33:28 PM (GMT+0200) Auto-Detected
Subject: [KVM-AUTOTEST PATCH 3/4] Fix bad line breaks

During the conversion of the kvm_runtest_2 to the kvm test, some
bad line breaks were introduced. Started using parenthesis
implicit line continuation instead of backslash continuation in
assignments that were using it.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
 client/tests/kvm/kvm_guest_wizard.py |    8 ++++----
 client/tests/kvm/kvm_tests.py        |    4 ++--
 client/tests/kvm/kvm_utils.py        |   12 ++++++------
 client/tests/kvm/kvm_vm.py           |    4 ++--
 client/tests/kvm/make_html_report.py |    6 ++----
 5 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/client/tests/kvm/kvm_guest_wizard.py b/client/tests/kvm/kvm_guest_wizard.py
index 01aeb97..2dd9be5 100644
--- a/client/tests/kvm/kvm_guest_wizard.py
+++ b/client/tests/kvm/kvm_guest_wizard.py
@@ -105,8 +105,8 @@ def barrier_2(vm, words, fail_if_stuck_for, stuck_detection_history,
         time.sleep(sleep_duration)
 
     # Failure
-    message = "Barrier failed at step %s after %.2f seconds (%s)" % \
-            (current_step_num, time.time() - start_time, failure_message)
+    message = ("Barrier failed at step %s after %.2f seconds (%s)" %
+               (current_step_num, time.time() - start_time, failure_message))
 
     # What should we do with this failure?
     if words[-1] == "optional":
@@ -201,9 +201,9 @@ def run_steps(test, params, env):
                 logging.error("Variable not defined: %s" % words[1])
         elif words[0] == "barrier_2":
             if current_screendump:
-                scrdump_filename = \
+                scrdump_filename = (
                 os.path.join(ppm_utils.get_data_dir(steps_filename),
-                             current_screendump)
+                             current_screendump))
             else:
                 scrdump_filename = None
             if not barrier_2(vm, words, fail_if_stuck_for,
diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
index cccc48e..54d2a7a 100644
--- a/client/tests/kvm/kvm_tests.py
+++ b/client/tests/kvm/kvm_tests.py
@@ -321,8 +321,8 @@ def run_autotest(test, params, env):
     status_fail = False
     if result_list == []:
         status_fail = True
-        message_fail = "Test '%s' did not produce any recognizable"
-        " results" % test_name
+        message_fail = ("Test '%s' did not produce any recognizable "
+                        "results" % test_name)
     for result in result_list:
         logging.info(str(result))
         if result[1] == "FAIL":
diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index 434190d..0f4c770 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -644,8 +644,8 @@ def scp_to_remote(host, port, username, password, local_path, remote_path,
 
     @return: True on success and False on failure.
     """
-    command = "scp -o UserKnownHostsFile=/dev/null -r -P %s %s %s@%s:%s" % \
-        (port, local_path, username, host, remote_path)
+    command = ("scp -o UserKnownHostsFile=/dev/null -r -P %s %s %s@%s:%s" %
+               (port, local_path, username, host, remote_path))
     return remote_scp(command, password, timeout)
 
 
@@ -664,8 +664,8 @@ def scp_from_remote(host, port, username, password, remote_path, local_path,
 
     @return: True on success and False on failure.
     """
-    command = "scp -o UserKnownHostsFile=/dev/null -r -P %s %s@%s:%s %s" % \
-        (port, username, host, remote_path, local_path)
+    command = ("scp -o UserKnownHostsFile=/dev/null -r -P %s %s@%s:%s %s" %
+               (port, username, host, remote_path, local_path))
     return remote_scp(command, password, timeout)
 
 
@@ -681,8 +681,8 @@ def ssh(host, port, username, password, prompt, timeout=10):
 
     @return: kvm_spawn object on success and None on failure.
     """
-    command = "ssh -o UserKnownHostsFile=/dev/null -p %s %s@%s" % \
-        (port, username, host)
+    command = ("ssh -o UserKnownHostsFile=/dev/null -p %s %s@%s" %
+               (port, username, host))
     return remote_login(command, password, prompt, "\n", timeout)
 
 
diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index eb9717b..de21b2f 100644
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -118,8 +118,8 @@ class VM:
         # Find available monitor filename
         while True:
             # The monitor filename should be unique
-            self.instance = time.strftime("%Y%m%d-%H%M%S-") + \
-            kvm_utils.generate_random_string(4)
+            self.instance = (time.strftime("%Y%m%d-%H%M%S-") +
+                             kvm_utils.generate_random_string(4))
             self.monitor_file_name = os.path.join("/tmp",
                                                   "monitor-" + self.instance)
             if not os.path.exists(self.monitor_file_name):
diff --git a/client/tests/kvm/make_html_report.py b/client/tests/kvm/make_html_report.py
index 6aed39e..7fb54e5 100755
--- a/client/tests/kvm/make_html_report.py
+++ b/client/tests/kvm/make_html_report.py
@@ -1442,10 +1442,8 @@ return true;
     stat_str = 'No test cases executed'
     if total_executed>0:
         failed_perct = int(float(total_failed)/float(total_executed)*100)
-        stat_str = 'From %d tests executed, '
-        '%d have passed (%d%s)' % (total_executed, total_passed,failed_perct,
-                                   '% failures')
-
+        stat_str = ('From %d tests executed, %d have passed (%d%% failures)' %
+                    (total_executed, total_passed, failed_perct))
 
     kvm_ver_str = metadata['kvmver']
 
-- 
1.6.2.2

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

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

* Re: [Autotest] [KVM-AUTOTEST PATCH 2/4] Make kvm_config.py to use internal/standard exeptions
  2009-06-10 12:21   ` [Autotest] [KVM-AUTOTEST PATCH 2/4] Make kvm_config.py to use internal/standard exeptions Michael Goldish
@ 2009-06-10 12:36     ` Michael Goldish
  0 siblings, 0 replies; 14+ messages in thread
From: Michael Goldish @ 2009-06-10 12:36 UTC (permalink / raw)
  To: Lucas Meneghel Rodrigues; +Cc: kvm, autotest

One more thing: maybe we shouldn't test if the file exists and raise IOError ourselves --
python does this automatically anyway when we call open() for a file that doesn't exist.

----- Original Message -----
From: "Michael Goldish" <mgoldish@redhat.com>
To: "Lucas Meneghel Rodrigues" <lmr@redhat.com>
Cc: kvm@vger.kernel.org, autotest@test.kernel.org
Sent: Wednesday, June 10, 2009 3:21:20 PM (GMT+0200) Auto-Detected
Subject: Re: [Autotest] [KVM-AUTOTEST PATCH 2/4] Make kvm_config.py to use internal/standard exeptions

Looks fine to me.

BTW, I think debug_print() should be prefixed by a single underscore, not two.
A double underscore should be used only when name mangling is required -- at least that's what I understood from PEP 8.
Let me know what you think.

Thanks,
Michael

----- Original Message -----
From: "Lucas Meneghel Rodrigues" <lmr@redhat.com>
To: autotest@test.kernel.org
Cc: kvm@vger.kernel.org
Sent: Tuesday, June 9, 2009 7:33:27 PM (GMT+0200) Auto-Detected
Subject: [Autotest] [KVM-AUTOTEST PATCH 2/4] Make kvm_config.py to use internal/standard exeptions

Instead of resorting to internal autotest exception types, use
either python standard exceptions or an internally defined
ConfigError exception.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
 client/tests/kvm/kvm_config.py |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py
index a3467a0..cce931a 100755
--- a/client/tests/kvm/kvm_config.py
+++ b/client/tests/kvm/kvm_config.py
@@ -8,6 +8,11 @@ KVM configuration file utility functions.
 @copyright: Red Hat 2008-2009
 """
 
+
+class ConfigError(Exception):
+    pass
+
+
 class config:
     """
     Parse an input file or string that follows the KVM Test Config File format
@@ -47,7 +52,7 @@ class config:
             @param filename: Path of the configuration file.
         """
         if not os.path.exists(filename):
-            raise Exception, "File %s not found" % filename
+            raise IOError("File %s not found" % filename)
         self.filename = filename
         file = open(filename, "r")
         self.list = self.parse(file, self.list)
@@ -357,7 +362,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 ConfigError(e_msg)
                 if self.debug and not restricted:
                     self.__debug_print(indented_line,
                                      "Entering variants block (%d dicts in"
@@ -402,7 +407,7 @@ class config:
                                             words[1])
                     if not os.path.exists(filename):
                         e_msg = "Cannot include %s -- file not found" % filename
-                        raise error.AutotestError(e_msg)
+                        raise ConfigError(e_msg)
                     new_file = open(filename, "r")
                     list = self.parse(new_file, list, restricted)
                     new_file.close()
@@ -410,7 +415,7 @@ class config:
                         self.__debug_print("", "Leaving file %s" % words[1])
                 else:
                     e_msg = "Cannot include anything because no file is open"
-                    raise error.AutotestError(e_msg)
+                    raise ConfigError(e_msg)
 
             # Parse multi-line exceptions
             # (the block is parsed for each dict separately)
-- 
1.6.2.2

_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

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

* Re: [Autotest] [KVM-AUTOTEST PATCH 1/4] Make all programs on kvm test use /usr/bin/python
  2009-06-10 11:01     ` Alexey Eromenko
@ 2009-06-10 14:19       ` Martin Bligh
  2009-06-15 13:35         ` Alexey Eromenko
  0 siblings, 1 reply; 14+ messages in thread
From: Martin Bligh @ 2009-06-10 14:19 UTC (permalink / raw)
  To: Alexey Eromenko; +Cc: Lucas Meneghel Rodrigues, autotest, kvm

On Wed, Jun 10, 2009 at 4:01 AM, Alexey Eromenko<aeromenk@redhat.com> wrote:
>
> Even better would be to use "/usr/bin/python2".

That doesn't seem to exist, on Ubuntu at least.

> This is because future distros will include python3, which is incompatible with python2 code.
>
> "python" will be symlink of "python3".
>
> -Alexey
>

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

* Re: [Autotest] [KVM-AUTOTEST PATCH 1/4] Make all programs on kvm test  use /usr/bin/python
  2009-06-10 14:19       ` Martin Bligh
@ 2009-06-15 13:35         ` Alexey Eromenko
  2009-06-15 14:41           ` Lucas Meneghel Rodrigues
  2009-06-15 15:58           ` Martin Bligh
  0 siblings, 2 replies; 14+ messages in thread
From: Alexey Eromenko @ 2009-06-15 13:35 UTC (permalink / raw)
  To: Martin Bligh; +Cc: Lucas Meneghel Rodrigues, autotest, kvm


----- "Martin Bligh" <mbligh@google.com> wrote:

> On Wed, Jun 10, 2009 at 4:01 AM, Alexey Eromenko<aeromenk@redhat.com>
> wrote:
> >
> > Even better would be to use "/usr/bin/python2".
> 
> That doesn't seem to exist, on Ubuntu at least.
> 

Red Hat systems have it. "/usr/bin/python2" is a symlink to "/usr/bin/python" (which is python2 executable)

Is there any Ubuntu-compatible way of achieving this?

-Alexey

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

* Re: [Autotest] [KVM-AUTOTEST PATCH 1/4] Make all programs on kvm test  use /usr/bin/python
  2009-06-15 13:35         ` Alexey Eromenko
@ 2009-06-15 14:41           ` Lucas Meneghel Rodrigues
  2009-06-15 15:58           ` Martin Bligh
  1 sibling, 0 replies; 14+ messages in thread
From: Lucas Meneghel Rodrigues @ 2009-06-15 14:41 UTC (permalink / raw)
  To: Alexey Eromenko; +Cc: Martin Bligh, autotest, kvm

On Mon, 2009-06-15 at 09:35 -0400, Alexey Eromenko wrote:
> ----- "Martin Bligh" <mbligh@google.com> wrote:
> 
> > On Wed, Jun 10, 2009 at 4:01 AM, Alexey Eromenko<aeromenk@redhat.com>
> > wrote:
> > >
> > > Even better would be to use "/usr/bin/python2".
> > 
> > That doesn't seem to exist, on Ubuntu at least.
> > 
> 
> Red Hat systems have it. "/usr/bin/python2" is a symlink to "/usr/bin/python" (which is python2 executable)
> 
> Is there any Ubuntu-compatible way of achieving this?
> 
> -Alexey

The patch I had already applied uses autotest code to figure the best
python interpreter anyway, so it won't use python 3 if it's installed,
it will prefer the 2.4 - 2.6 series...

> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Lucas Meneghel Rodrigues
Software Engineer (QE)
Red Hat - Emerging Technologies


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

* Re: [Autotest] [KVM-AUTOTEST PATCH 1/4] Make all programs on kvm test use /usr/bin/python
  2009-06-15 13:35         ` Alexey Eromenko
  2009-06-15 14:41           ` Lucas Meneghel Rodrigues
@ 2009-06-15 15:58           ` Martin Bligh
  1 sibling, 0 replies; 14+ messages in thread
From: Martin Bligh @ 2009-06-15 15:58 UTC (permalink / raw)
  To: Alexey Eromenko; +Cc: Lucas Meneghel Rodrigues, autotest, kvm

On Mon, Jun 15, 2009 at 6:35 AM, Alexey Eromenko<aeromenk@redhat.com> wrote:
>
> ----- "Martin Bligh" <mbligh@google.com> wrote:
>
>> On Wed, Jun 10, 2009 at 4:01 AM, Alexey Eromenko<aeromenk@redhat.com>
>> wrote:
>> >
>> > Even better would be to use "/usr/bin/python2".
>>
>> That doesn't seem to exist, on Ubuntu at least.
>>
>
> Red Hat systems have it. "/usr/bin/python2" is a symlink to "/usr/bin/python" (which is python2 executable)
>
> Is there any Ubuntu-compatible way of achieving this?

Not that I can see, other than explicit Python code, which we have already.
I think this is a solved issue?

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

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

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-09 16:33 [KVM-AUTOTEST PATCH 1/4] Make all programs on kvm test use /usr/bin/python Lucas Meneghel Rodrigues
2009-06-09 16:33 ` [KVM-AUTOTEST PATCH 2/4] Make kvm_config.py to use internal/standard exeptions Lucas Meneghel Rodrigues
2009-06-09 16:33   ` [KVM-AUTOTEST PATCH 3/4] Fix bad line breaks Lucas Meneghel Rodrigues
2009-06-09 16:33     ` [KVM-AUTOTEST PATCH 4/4] Fix bad logging calls Lucas Meneghel Rodrigues
2009-06-10 12:32     ` [KVM-AUTOTEST PATCH 3/4] Fix bad line breaks Michael Goldish
2009-06-10 12:21   ` [Autotest] [KVM-AUTOTEST PATCH 2/4] Make kvm_config.py to use internal/standard exeptions Michael Goldish
2009-06-10 12:36     ` Michael Goldish
2009-06-09 17:00 ` [Autotest] [KVM-AUTOTEST PATCH 1/4] Make all programs on kvm test use /usr/bin/python Martin Bligh
2009-06-10  0:59   ` Lucas Meneghel Rodrigues
2009-06-10 11:01     ` Alexey Eromenko
2009-06-10 14:19       ` Martin Bligh
2009-06-15 13:35         ` Alexey Eromenko
2009-06-15 14:41           ` Lucas Meneghel Rodrigues
2009-06-15 15:58           ` Martin Bligh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox