[PATCH 1/4] KVM test: Move top level docstrings, other cleanups

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

 



In order to prepare for the subsequent changes, made
some cleanups on the kvm source files: I've noticed
that the top level docstrings were going before the
imports block, and that does not follow the pattern
found on other files (my fault). This patch fixes
that problem and fixed some places on scan_results.py
where 80 char line width was not being obeyed. Also,
cleaned up the last places where we were using the
shebang #/usr/bin/env python, which is not the
preferred usage of the shebang across the project.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx>
---
 client/tests/kvm/calc_md5sum_1m.py   |    8 ++++----
 client/tests/kvm/fix_cdkeys.py       |    6 +++---
 client/tests/kvm/kvm_config.py       |   10 +++++-----
 client/tests/kvm/kvm_guest_wizard.py |   12 ++++++------
 client/tests/kvm/kvm_subprocess.py   |    8 ++++----
 client/tests/kvm/kvm_tests.py        |    8 ++++----
 client/tests/kvm/kvm_utils.py        |   12 ++++++------
 client/tests/kvm/kvm_vm.py           |    6 +++---
 client/tests/kvm/make_html_report.py |   13 +++----------
 client/tests/kvm/ppm_utils.py        |    5 ++---
 client/tests/kvm/scan_results.py     |   25 +++++++++++++++++--------
 client/tests/kvm/stepeditor.py       |    8 ++++----
 client/tests/kvm/stepmaker.py        |   13 +++++++------
 13 files changed, 68 insertions(+), 66 deletions(-)

diff --git a/client/tests/kvm/calc_md5sum_1m.py b/client/tests/kvm/calc_md5sum_1m.py
index 6660d0e..2325673 100755
--- a/client/tests/kvm/calc_md5sum_1m.py
+++ b/client/tests/kvm/calc_md5sum_1m.py
@@ -1,7 +1,4 @@
-#!/usr/bin/env python
-import os, sys
-import kvm_utils
-
+#!/usr/bin/python
 """
 Program that calculates the md5sum for the first megabyte of a file.
 It's faster than calculating the md5sum for the whole ISO image.
@@ -10,6 +7,9 @@ It's faster than calculating the md5sum for the whole ISO image.
 @author: Uri Lublin (uril@xxxxxxxxxx)
 """
 
+import os, sys
+import kvm_utils
+
 
 if len(sys.argv) < 2:
     print 'usage: %s <iso-filename>' % sys.argv[0]
diff --git a/client/tests/kvm/fix_cdkeys.py b/client/tests/kvm/fix_cdkeys.py
index 7a821fa..aa9fc3e 100755
--- a/client/tests/kvm/fix_cdkeys.py
+++ b/client/tests/kvm/fix_cdkeys.py
@@ -1,7 +1,4 @@
 #!/usr/bin/python
-import shutil, os, sys
-import common
-
 """
 Program that replaces the CD keys present on a KVM autotest configuration file.
 
@@ -9,6 +6,9 @@ Program that replaces the CD keys present on a KVM autotest configuration file.
 @author: uril@xxxxxxxxxx (Uri Lublin)
 """
 
+import shutil, os, sys
+import common
+
 
 def file_to_lines(filename):
     f = open(filename, 'r')
diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py
index da7988b..9404f28 100755
--- a/client/tests/kvm/kvm_config.py
+++ b/client/tests/kvm/kvm_config.py
@@ -1,15 +1,15 @@
 #!/usr/bin/python
-import logging, re, os, sys, StringIO, optparse
-import common
-from autotest_lib.client.common_lib import error
-from autotest_lib.client.common_lib import logging_config, logging_manager
-
 """
 KVM configuration file utility functions.
 
 @copyright: Red Hat 2008-2009
 """
 
+import logging, re, os, sys, StringIO, optparse
+import common
+from autotest_lib.client.common_lib import error
+from autotest_lib.client.common_lib import logging_config, logging_manager
+
 
 class KvmLoggingConfig(logging_config.LoggingConfig):
     def configure_logging(self, results_dir=None, verbose=False):
diff --git a/client/tests/kvm/kvm_guest_wizard.py b/client/tests/kvm/kvm_guest_wizard.py
index 3d3f3b2..8bc85f2 100644
--- a/client/tests/kvm/kvm_guest_wizard.py
+++ b/client/tests/kvm/kvm_guest_wizard.py
@@ -1,3 +1,9 @@
+"""
+Utilities to perform automatic guest installation using step files.
+
+@copyright: Red Hat 2008-2009
+"""
+
 import os, time, md5, re, shutil, logging
 from autotest_lib.client.common_lib import utils, error
 import kvm_utils, ppm_utils, kvm_subprocess
@@ -9,12 +15,6 @@ except ImportError:
                     'please install python-imaging or the equivalent for your '
                     'distro.')
 
-"""
-Utilities to perform automatic guest installation using step files.
-
-@copyright: Red Hat 2008-2009
-"""
-
 
 def handle_var(vm, params, varname):
     var = params.get(varname)
diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py
index 07303a8..5df9e9b 100755
--- a/client/tests/kvm/kvm_subprocess.py
+++ b/client/tests/kvm/kvm_subprocess.py
@@ -1,14 +1,14 @@
 #!/usr/bin/python
-import sys, subprocess, pty, select, os, time, signal, re, termios, fcntl
-import threading, logging, commands
-import common, kvm_utils
-
 """
 A class and functions used for running and controlling child processes.
 
 @copyright: 2008-2009 Red Hat Inc.
 """
 
+import sys, subprocess, pty, select, os, time, signal, re, termios, fcntl
+import threading, logging, commands
+import common, kvm_utils
+
 
 def run_bg(command, termination_func=None, output_func=None, output_prefix="",
            timeout=1.0):
diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
index 4e3391e..43ca943 100644
--- a/client/tests/kvm/kvm_tests.py
+++ b/client/tests/kvm/kvm_tests.py
@@ -1,13 +1,13 @@
-import time, os, logging, re, commands
-from autotest_lib.client.common_lib import utils, error
-import kvm_utils, kvm_subprocess, ppm_utils, scan_results
-
 """
 KVM test definitions.
 
 @copyright: 2008-2009 Red Hat Inc.
 """
 
+import time, os, logging, re, commands
+from autotest_lib.client.common_lib import utils, error
+import kvm_utils, kvm_subprocess, ppm_utils, scan_results
+
 
 def run_boot(test, params, env):
     """
diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index dfca938..bfb5117 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -1,15 +1,15 @@
-import md5, thread, subprocess, time, string, random, socket, os, signal, pty
-import select, re, logging, commands
-from autotest_lib.client.bin import utils
-from autotest_lib.client.common_lib import error
-import kvm_subprocess
-
 """
 KVM test utility functions.
 
 @copyright: 2008-2009 Red Hat Inc.
 """
 
+import md5, thread, subprocess, time, string, random, socket, os, signal, pty
+import select, re, logging, commands
+from autotest_lib.client.bin import utils
+from autotest_lib.client.common_lib import error
+import kvm_subprocess
+
 
 def get_sub_dict(dict, name):
     """
diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index bd7e0fc..9e3a10f 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -1,13 +1,13 @@
 #!/usr/bin/python
-import time, socket, os, logging, fcntl, re, commands
-import kvm_utils, kvm_subprocess
-
 """
 Utility classes and functions to handle Virtual Machine creation using qemu.
 
 @copyright: 2008-2009 Red Hat Inc.
 """
 
+import time, socket, os, logging, fcntl, re, commands
+import kvm_utils, kvm_subprocess
+
 
 def get_image_filename(params, root_dir):
     """
diff --git a/client/tests/kvm/make_html_report.py b/client/tests/kvm/make_html_report.py
index e63fcfa..e6b698c 100755
--- a/client/tests/kvm/make_html_report.py
+++ b/client/tests/kvm/make_html_report.py
@@ -1,7 +1,4 @@
 #!/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.
 
@@ -10,6 +7,9 @@ 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
+import common
+
 
 format_css="""
 html,body {
@@ -1376,13 +1376,6 @@ function processList(ul) {
 """
 
 
-
-
-
-
-
-
-
 #################################################################
 ##  This script gets kvm autotest results directory path as an ##
 ##  input and create a single html formatted result page.      ##
diff --git a/client/tests/kvm/ppm_utils.py b/client/tests/kvm/ppm_utils.py
index f0435ce..d3af737 100644
--- a/client/tests/kvm/ppm_utils.py
+++ b/client/tests/kvm/ppm_utils.py
@@ -1,12 +1,11 @@
-import md5, os, struct, time, re
-
 """
 Utility functions to deal with ppm (qemu screendump format) files.
 
 @copyright: Red Hat 2008-2009
 """
 
-# Some directory/filename utils, for consistency
+import md5, os, struct, time, re
+
 
 def find_id_for_screendump(md5sum, dir):
     """
diff --git a/client/tests/kvm/scan_results.py b/client/tests/kvm/scan_results.py
index 95507bd..8d9e104 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.
@@ -7,7 +7,11 @@ result.
 """
 
 def parse_results(text):
-    """Parse text containing Autotest results and return a list of result 4-tuples."""
+    """
+    Parse text containing Autotest results.
+
+    @return: A list of result 4-tuples.
+    """
     result_list = []
     start_time_list = []
     info_list = []
@@ -18,13 +22,15 @@ def parse_results(text):
         parts = line.split("\t")
 
         # Found a START line -- get start time
-        if line.startswith("START") and len(parts) >= 5 and parts[3].startswith("timestamp"):
+        if (line.startswith("START") and len(parts) >= 5 and
+            parts[3].startswith("timestamp")):
             start_time = float(parts[3].split('=')[1])
             start_time_list.append(start_time)
             info_list.append("")
 
         # Found an END line -- get end time, name and status
-        elif line.startswith("END") and len(parts) >= 5 and parts[3].startswith("timestamp"):
+        elif (line.startswith("END") and len(parts) >= 5
+              and parts[3].startswith("timestamp")):
             end_time = float(parts[3].split('=')[1])
             start_time = start_time_list.pop()
             info = info_list.pop()
@@ -33,19 +39,22 @@ def parse_results(text):
             # Remove 'kvm.' prefix
             if test_name.startswith("kvm."):
                 test_name = test_name.split("kvm.")[1]
-            result_list.append((test_name, test_status, int(end_time - start_time), info))
+            result_list.append((test_name, test_status,
+                                int(end_time - start_time), info))
 
         # Found a FAIL/ERROR/GOOD line -- get failure/success info
-        elif len(parts) >= 6 and parts[3].startswith("timestamp") and parts[4].startswith("localtime"):
+        elif (len(parts) >= 6 and parts[3].startswith("timestamp") and
+              parts[4].startswith("localtime")):
             info_list[-1] = parts[5]
 
     return result_list
 
 
 def print_result(result):
-    """Nicely print a single Autotest result.
+    """
+    Nicely print a single Autotest result.
 
-    result -- a 4-tuple
+    @param result: A 4-tuple
     """
     if result:
         print '%-48s\t\t%s\t%s\t%s' % tuple(map(str, result))
diff --git a/client/tests/kvm/stepeditor.py b/client/tests/kvm/stepeditor.py
index e7794ac..43e189f 100755
--- a/client/tests/kvm/stepeditor.py
+++ b/client/tests/kvm/stepeditor.py
@@ -1,8 +1,4 @@
 #!/usr/bin/python
-import pygtk, gtk, os, glob, shutil, sys, logging
-import common, ppm_utils
-pygtk.require('2.0')
-
 """
 Step file creator/editor.
 
@@ -11,6 +7,10 @@ Step file creator/editor.
 @version: "20090401"
 """
 
+import pygtk, gtk, os, glob, shutil, sys, logging
+import common, ppm_utils
+pygtk.require('2.0')
+
 
 # General utilities
 
diff --git a/client/tests/kvm/stepmaker.py b/client/tests/kvm/stepmaker.py
index e478350..24060db 100755
--- a/client/tests/kvm/stepmaker.py
+++ b/client/tests/kvm/stepmaker.py
@@ -1,10 +1,4 @@
 #!/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.
 
@@ -13,6 +7,13 @@ Step file creator/editor.
 @version: "20090401"
 """
 
+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')
+
+
 class StepMaker(stepeditor.StepMakerWindow):
     """
     Application used to create a step file. It will grab your input to the
-- 
1.6.2.5

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