@@ -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@redhat.com)
"""
+import os, sys
+import kvm_utils
+
if len(sys.argv) < 2:
print 'usage: %s <iso-filename>' % sys.argv[0]
@@ -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@redhat.com (Uri Lublin)
"""
+import shutil, os, sys
+import common
+
def file_to_lines(filename):
f = open(filename, 'r')
@@ -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):
@@ -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)
@@ -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):
@@ -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):
"""
@@ -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):
"""
@@ -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):
"""
@@ -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@redhat.com)
"""
+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. ##
@@ -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):
"""
@@ -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))
@@ -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
@@ -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
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@redhat.com> --- 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(-)