diff mbox

[2/3] KVM test: Infrastructure cleanups

Message ID 1295842941-11557-3-git-send-email-lmr@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lucas Meneghel Rodrigues Jan. 24, 2011, 4:22 a.m. UTC
None
diff mbox

Patch

diff --git a/client/tests/kvm/cd_hash.py b/client/tests/kvm/cd_hash.py
index bcd14dc..04f8cbe 100755
--- a/client/tests/kvm/cd_hash.py
+++ b/client/tests/kvm/cd_hash.py
@@ -8,7 +8,7 @@  Program that calculates several hashes for a given CD image.
 import os, sys, optparse, logging
 import common
 import kvm_utils
-from autotest_lib.client.common_lib import logging_config, logging_manager
+from autotest_lib.client.common_lib import logging_manager
 from autotest_lib.client.bin import utils
 
 
diff --git a/client/tests/kvm/get_started.py b/client/tests/kvm/get_started.py
index 126d8a7..5ce7349 100755
--- a/client/tests/kvm/get_started.py
+++ b/client/tests/kvm/get_started.py
@@ -5,10 +5,10 @@  Program to help setup kvm test environment
 @copyright: Red Hat 2010
 """
 
-import os, sys, optparse, logging, shutil
+import os, sys, logging, shutil
 import common, kvm_utils
 from autotest_lib.client.common_lib import logging_manager
-from autotest_lib.client.bin import utils, os_dep
+from autotest_lib.client.bin import utils
 
 
 def check_iso(url, destination, hash):
diff --git a/client/tests/kvm/html_report.py b/client/tests/kvm/html_report.py
index ebc9c12..8b4b109 100755
--- a/client/tests/kvm/html_report.py
+++ b/client/tests/kvm/html_report.py
@@ -11,7 +11,7 @@  import os, sys, re, getopt, time, datetime, commands
 import common
 
 
-format_css="""
+format_css = """
 html,body {
     padding:0;
     color:#222;
@@ -180,7 +180,7 @@  font-size: 13px;}
 """
 
 
-table_js="""
+table_js = """
 /**
  * Copyright (c)2005-2007 Matt Kruse (javascripttoolbox.com)
  *
@@ -1380,11 +1380,11 @@  function processList(ul) {
 ##  input and create a single html formatted result page.      ##
 #################################################################
 
-stimelist=[]
+stimelist = []
 
 
 def make_html_file(metadata, results, tag, host, output_file_name, dirname):
-    html_prefix="""
+    html_prefix = """
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 <html>
 <head>
@@ -1405,7 +1405,7 @@  return true;
 </script>
 </head>
 <body>
-"""%(format_css, table_js, maketree_js)
+""" % (format_css, table_js, maketree_js)
 
 
     if output_file_name:
@@ -1427,13 +1427,13 @@  return true;
     total_failed = 0
     total_passed = 0
     for res in results:
-        total_executed+=1
+        total_executed += 1
         if res['status'] == 'GOOD':
-            total_passed+=1
+            total_passed += 1
         else:
-            total_failed+=1
+            total_failed += 1
     stat_str = 'No test cases executed'
-    if total_executed>0:
+    if total_executed > 0:
         failed_perct = int(float(total_failed)/float(total_executed)*100)
         stat_str = ('From %d tests executed, %d have passed (%d%% failures)' %
                     (total_executed, total_passed, failed_perct))
@@ -1486,15 +1486,15 @@  id="t1" class="stats table-autosort:4 table-autofilter table-stripeclass:alterna
         if res['log']:
             #chop all '\n' from log text (to prevent html errors)
             rx1 = re.compile('(\s+)')
-            log_text = rx1.sub(' ',res['log'])
+            log_text = rx1.sub(' ', res['log'])
 
             # allow only a-zA-Z0-9_ in html title name
             # (due to bug in MS-explorer)
             rx2 = re.compile('([^a-zA-Z_0-9])')
-            updated_tag = rx2.sub('_',res['title'])
+            updated_tag = rx2.sub('_', res['title'])
 
-            html_body_text = '<html><head><title>%s</title></head><body>%s</body></html>'%(str(updated_tag),log_text)
-            print >> output, '<td align=\"left\"><A HREF=\"#\" onClick=\"popup(\'%s\',\'%s\')\">Info</A></td>'%(str(updated_tag),str(html_body_text))
+            html_body_text = '<html><head><title>%s</title></head><body>%s</body></html>' % (str(updated_tag), log_text)
+            print >> output, '<td align=\"left\"><A HREF=\"#\" onClick=\"popup(\'%s\',\'%s\')\">Info</A></td>' % (str(updated_tag), str(html_body_text))
         else:
             print >> output, '<td align=\"left\"></td>'
         # print execution time
@@ -1514,7 +1514,7 @@  id="t1" class="stats table-autosort:4 table-autofilter table-stripeclass:alterna
     print >> output, '</p>'
 
     print >> output, '<ul class="mktree" id="meta_tree">'
-    counter=0
+    counter = 0
     keys = metadata.keys()
     keys.sort()
     for key in keys:
@@ -1528,7 +1528,7 @@  id="t1" class="stats table-autosort:4 table-autofilter table-stripeclass:alterna
         output.close()
 
 
-def parse_result(dirname,line):
+def parse_result(dirname, line):
     parts = line.split()
     if len(parts) < 4:
         return None
@@ -1560,7 +1560,7 @@  def parse_result(dirname,line):
         result['title'] = str(tag)
         result['status'] = parts[1]
         if result['status'] != 'GOOD':
-            result['log'] = get_exec_log(dirname,tag)
+            result['log'] = get_exec_log(dirname, tag)
         if len(stimelist)>0:
             pair = parts[4].split('=')
             etime = int(pair[1])
@@ -1572,10 +1572,10 @@  def parse_result(dirname,line):
 
 
 def get_exec_log(resdir, tag):
-    stdout_file = os.path.join(resdir,tag) + '/debug/stdout'
-    stderr_file = os.path.join(resdir,tag) + '/debug/stderr'
-    status_file = os.path.join(resdir,tag) + '/status'
-    dmesg_file = os.path.join(resdir,tag) + '/sysinfo/dmesg'
+    stdout_file = os.path.join(resdir, tag) + '/debug/stdout'
+    stderr_file = os.path.join(resdir, tag) + '/debug/stderr'
+    status_file = os.path.join(resdir, tag) + '/status'
+    dmesg_file = os.path.join(resdir, tag) + '/sysinfo/dmesg'
     log = ''
     log += '<br><b>STDERR:</b><br>'
     log += get_info_file(stderr_file)
@@ -1589,20 +1589,20 @@  def get_exec_log(resdir, tag):
 
 
 def get_info_file(filename):
-    data=''
+    data = ''
     errors = re.compile(r"\b(error|fail|failed)\b", re.IGNORECASE)
     if os.path.isfile(filename):
         f = open('%s' % filename, "r")
-        lines=f.readlines()
+        lines = f.readlines()
         f.close()
         rx = re.compile('(\'|\")')
         for line in lines:
-            new_line = rx.sub('',line)
+            new_line = rx.sub('', line)
             errors_found = errors.findall(new_line)
-            if len(errors_found)>0:
-                data += '<font color=red>%s</font><br>'%str(new_line)
+            if len(errors_found) > 0:
+                data += '<font color=red>%s</font><br>' % str(new_line)
             else:
-                data += '%s<br>'%str(new_line)
+                data += '%s<br>' % str(new_line)
         if not data:
             data = 'No Information Found.<br>'
     else:
@@ -1687,12 +1687,12 @@  def main(argv):
             status_file_name = dirname + '/status'
             sysinfo_dir = dirname + '/sysinfo'
             host = get_info_file('%s/hostname' % sysinfo_dir)
-            rx=re.compile('^\s+[END|START].*$')
+            rx = re.compile('^\s+[END|START].*$')
             # create the results set dict
-            results_data=[]
+            results_data = []
             if os.path.exists(status_file_name):
                 f = open(status_file_name, "r")
-                lines=f.readlines()
+                lines = f.readlines()
                 f.close()
                 for line in lines:
                     if rx.match(line):
diff --git a/client/tests/kvm/installer.py b/client/tests/kvm/installer.py
index 30ee657..a757223 100644
--- a/client/tests/kvm/installer.py
+++ b/client/tests/kvm/installer.py
@@ -1,6 +1,6 @@ 
-import time, os, sys, urllib, re, signal, logging, datetime, glob, ConfigParser
+import os, logging, datetime, glob
 import shutil
-from autotest_lib.client.bin import utils, test, os_dep
+from autotest_lib.client.bin import utils, os_dep
 from autotest_lib.client.common_lib import error
 import kvm_utils
 
@@ -41,7 +41,7 @@  def cpu_vendor():
     vendor = "intel"
     if os.system("grep vmx /proc/cpuinfo 1>/dev/null") != 0:
         vendor = "amd"
-    logging.debug("Detected CPU vendor as '%s'" %(vendor))
+    logging.debug("Detected CPU vendor as '%s'", vendor)
     return vendor
 
 
diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
index dbe29c3..b88fd51 100644
--- a/client/tests/kvm/kvm.py
+++ b/client/tests/kvm/kvm.py
@@ -1,4 +1,4 @@ 
-import sys, os, time, logging, imp
+import os, logging, imp
 from autotest_lib.client.bin import test
 from autotest_lib.client.common_lib import error
 import kvm_utils, kvm_preprocessing
diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py
index 89df489..13cdfe2 100755
--- a/client/tests/kvm/kvm_config.py
+++ b/client/tests/kvm/kvm_config.py
@@ -9,7 +9,7 @@  import logging, re, os, sys, optparse, array, traceback, cPickle
 import common
 import kvm_utils
 from autotest_lib.client.common_lib import error
-from autotest_lib.client.common_lib import logging_config, logging_manager
+from autotest_lib.client.common_lib import logging_manager
 
 
 class config:
diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py
index 2713805..9c53f02 100644
--- a/client/tests/kvm/kvm_preprocessing.py
+++ b/client/tests/kvm/kvm_preprocessing.py
@@ -1,5 +1,5 @@ 
-import sys, os, time, commands, re, logging, signal, glob, threading, shutil
-from autotest_lib.client.bin import test, utils
+import os, time, commands, re, logging, glob, threading, shutil
+from autotest_lib.client.bin import utils
 from autotest_lib.client.common_lib import error
 import kvm_vm, kvm_utils, kvm_subprocess, kvm_monitor, ppm_utils, test_setup
 try:
diff --git a/client/tests/kvm/kvm_test_utils.py b/client/tests/kvm/kvm_test_utils.py
index c9a9b42..b5c4a24 100644
--- a/client/tests/kvm/kvm_test_utils.py
+++ b/client/tests/kvm/kvm_test_utils.py
@@ -21,7 +21,7 @@  More specifically:
 @copyright: 2008-2009 Red Hat Inc.
 """
 
-import time, os, logging, re, commands, signal, threading
+import time, os, logging, re, signal
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.bin import utils
 import kvm_utils, kvm_vm, kvm_subprocess, scan_results
@@ -364,21 +364,21 @@  def get_time(session, time_command, time_filter_re, time_format):
         try:
             s = re.findall(time_filter_re, s)[0]
         except IndexError:
-            logging.debug("The time string from guest is:\n%s" % s)
+            logging.debug("The time string from guest is:\n%s", s)
             raise error.TestError("The time string from guest is unexpected.")
         except Exception, e:
-            logging.debug("(time_filter_re, time_string): (%s, %s)" %
-                           (time_filter_re, s))
+            logging.debug("(time_filter_re, time_string): (%s, %s)",
+                          time_filter_re, s)
             raise e
 
         guest_time = time.mktime(time.strptime(s, time_format))
     else:
         o = session.cmd(time_command)
         if re.match('ntpdate', time_command):
-            offset = re.findall('offset (.*) sec',o)[0]
+            offset = re.findall('offset (.*) sec', o)[0]
             host_main, host_mantissa = re.findall(time_filter_re, o)[0]
-            host_time = time.mktime(time.strptime(host_main, time_format)) \
-                        + float("0.%s" % host_mantissa)
+            host_time = (time.mktime(time.strptime(host_main, time_format)) +
+                         float("0.%s" % host_mantissa))
             guest_time = host_time + float(offset)
         else:
             guest_time =  re.findall(time_filter_re, o)[0]
diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index 78c9f25..44ebb88 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -427,8 +427,7 @@  def get_git_branch(repository, branch, srcdir, commit=None, lbranch=None):
     except error.CmdError:
         desc = "no tag found"
 
-    logging.info("Commit hash for %s is %s (%s)" % (repository, h.strip(),
-                                                    desc))
+    logging.info("Commit hash for %s is %s (%s)", repository, h.strip(), desc)
     return srcdir
 
 
@@ -566,7 +565,7 @@  def _remote_login(session, username, password, prompt, timeout=10):
                 continue
             elif match == 1:  # "password:"
                 if password_prompt_count == 0:
-                    logging.debug("Got password prompt; sending '%s'" % password)
+                    logging.debug("Got password prompt; sending '%s'", password)
                     session.sendline(password)
                     password_prompt_count += 1
                     continue
@@ -575,7 +574,7 @@  def _remote_login(session, username, password, prompt, timeout=10):
                                                    text)
             elif match == 2:  # "login:"
                 if login_prompt_count == 0 and password_prompt_count == 0:
-                    logging.debug("Got username prompt; sending '%s'" % username)
+                    logging.debug("Got username prompt; sending '%s'", username)
                     session.sendline(username)
                     login_prompt_count += 1
                     continue
@@ -634,7 +633,7 @@  def remote_login(client, host, port, username, password, prompt, linesep="\n",
     else:
         raise LoginBadClientError(client)
 
-    logging.debug("Trying to login with command '%s'" % cmd)
+    logging.debug("Trying to login with command '%s'", cmd)
     session = kvm_subprocess.ShellSession(cmd, linesep=linesep, prompt=prompt)
     try:
         _remote_login(session, username, password, prompt, timeout)
@@ -661,8 +660,8 @@  def wait_for_login(client, host, port, username, password, prompt, linesep="\n",
     @raise: Whatever remote_login() raises
     @return: A ShellSession object.
     """
-    logging.debug("Attempting to log into %s:%s using %s (timeout %ds)" %
-                  (host, port, client, timeout))
+    logging.debug("Attempting to log into %s:%s using %s (timeout %ds)",
+                  host, port, client, timeout)
     end_time = time.time() + timeout
     while time.time() < end_time:
         try:
@@ -713,7 +712,7 @@  def _remote_scp(session, password, transfer_timeout=600, login_timeout=10):
                 continue
             elif match == 1:  # "password:"
                 if password_prompt_count == 0:
-                    logging.debug("Got password prompt; sending '%s'" % password)
+                    logging.debug("Got password prompt; sending '%s'", password)
                     session.sendline(password)
                     password_prompt_count += 1
                     timeout = transfer_timeout
@@ -836,7 +835,8 @@  def copy_files_to(address, client, username, password, port, local_path,
                       remote_path, log_filename, timeout)
     elif client == "rss":
         log_func = None
-        if verbose: log_func = logging.debug
+        if verbose:
+            log_func = logging.debug
         c = rss_file_transfer.FileUploadClient(address, port, log_func)
         c.upload(local_path, remote_path, timeout)
         c.close()
@@ -864,7 +864,8 @@  def copy_files_from(address, client, username, password, port, remote_path,
                         local_path, log_filename, timeout)
     elif client == "rss":
         log_func = None
-        if verbose: log_func = logging.debug
+        if verbose:
+            log_func = logging.debug
         c = rss_file_transfer.FileDownloadClient(address, port, log_func)
         c.download(remote_path, local_path, timeout)
         c.close()
@@ -1056,7 +1057,7 @@  def wait_for(func, timeout, first=0.0, step=1.0, text=None):
 
     while time.time() < end_time:
         if text:
-            logging.debug("%s (%f secs)" % (text, time.time() - start_time))
+            logging.debug("%s (%f secs)", text, (time.time() - start_time))
 
         output = func()
         if output:
@@ -1453,8 +1454,8 @@  class PciAssignable(object):
         # Re-probe driver with proper number of VFs
         if re_probe:
             cmd = "modprobe %s %s" % (self.driver, self.driver_option)
-            logging.info("Loading the driver '%s' with option '%s'" %
-                                   (self.driver, self.driver_option))
+            logging.info("Loading the driver '%s' with option '%s'",
+                         self.driver, self.driver_option)
             s, o = commands.getstatusoutput(cmd)
             if s:
                 return False
@@ -1482,8 +1483,8 @@  class PciAssignable(object):
             if not full_id:
                 continue
             drv_path = os.path.join(base_dir, "devices/%s/driver" % full_id)
-            dev_prev_driver= os.path.realpath(os.path.join(drv_path,
-                                              os.readlink(drv_path)))
+            dev_prev_driver = os.path.realpath(os.path.join(drv_path,
+                                               os.readlink(drv_path)))
             self.dev_drivers[pci_id] = dev_prev_driver
 
             # Judge whether the device driver has been binded to stub
@@ -1687,7 +1688,7 @@  def umount(src, mount_point, type):
         except error.CmdError:
             return False
     else:
-        logging.debug("%s is not mounted under %s" % (src, mount_point))
+        logging.debug("%s is not mounted under %s", src, mount_point)
         return True
 
 
@@ -1704,8 +1705,8 @@  def mount(src, mount_point, type, perm="rw"):
     mount_string = "%s %s %s %s" % (src, mount_point, type, perm)
 
     if mount_string in file("/etc/mtab").read():
-        logging.debug("%s is already mounted in %s with %s" %
-                      (src, mount_point, perm))
+        logging.debug("%s is already mounted in %s with %s",
+                      src, mount_point, perm)
         return True
 
     mount_cmd = "mount -t %s %s %s -o %s" % (type, src, mount_point, perm)
@@ -1716,9 +1717,9 @@  def mount(src, mount_point, type, perm="rw"):
 
     logging.debug("Verify the mount through /etc/mtab")
     if mount_string in file("/etc/mtab").read():
-        logging.debug("%s is successfully mounted" % src)
+        logging.debug("%s is successfully mounted", src)
         return True
     else:
-        logging.error("Can't find mounted NFS share - /etc/mtab contents \n%s" %
+        logging.error("Can't find mounted NFS share - /etc/mtab contents \n%s",
                       file("/etc/mtab").read())
         return False
diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 9336c75..969558b 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -5,8 +5,8 @@  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, shelve, glob
-import kvm_utils, kvm_subprocess, kvm_monitor, rss_file_transfer
+import time, os, logging, fcntl, re, commands, glob
+import kvm_utils, kvm_subprocess, kvm_monitor
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.bin import utils
 
@@ -225,7 +225,7 @@  def create_image(params, root_dir):
     qemu_img_cmd += " %s" % size
 
     utils.system(qemu_img_cmd)
-    logging.info("Image created in %r" % image_filename)
+    logging.info("Image created in %r", image_filename)
     return image_filename
 
 
@@ -241,7 +241,7 @@  def remove_image(params, root_dir):
            image_format -- the format of the image (qcow2, raw etc)
     """
     image_filename = get_image_filename(params, root_dir)
-    logging.debug("Removing image file %s..." % image_filename)
+    logging.debug("Removing image file %s...", image_filename)
     if os.path.exists(image_filename):
         os.unlink(image_filename)
     else:
@@ -262,7 +262,7 @@  def check_image(params, root_dir):
     @raise VMImageCheckError: In case qemu-img check fails on the image.
     """
     image_filename = get_image_filename(params, root_dir)
-    logging.debug("Checking image file %s..." % image_filename)
+    logging.debug("Checking image file %s...", image_filename)
     qemu_img_cmd = kvm_utils.get_path(root_dir,
                                       params.get("qemu_img_binary", "qemu-img"))
     image_is_qcow2 = params.get("image_format") == 'qcow2'
@@ -445,13 +445,20 @@  class VM:
         def add_drive(help, filename, index=None, format=None, cache=None,
                       werror=None, serial=None, snapshot=False, boot=False):
             cmd = " -drive file='%s'" % filename
-            if index is not None: cmd += ",index=%s" % index
-            if format: cmd += ",if=%s" % format
-            if cache: cmd += ",cache=%s" % cache
-            if werror: cmd += ",werror=%s" % werror
-            if serial: cmd += ",serial='%s'" % serial
-            if snapshot: cmd += ",snapshot=on"
-            if boot: cmd += ",boot=on"
+            if index is not None:
+                cmd += ",index=%s" % index
+            if format:
+                cmd += ",if=%s" % format
+            if cache:
+                cmd += ",cache=%s" % cache
+            if werror:
+                cmd += ",werror=%s" % werror
+            if serial:
+                cmd += ",serial='%s'" % serial
+            if snapshot:
+                cmd += ",snapshot=on"
+            if boot:
+                cmd += ",boot=on"
             return cmd
 
         def add_nic(help, vlan, model=None, mac=None, netdev_id=None,
@@ -564,9 +571,12 @@  class VM:
 
         # End of command line option wrappers
 
-        if name is None: name = self.name
-        if params is None: params = self.params
-        if root_dir is None: root_dir = self.root_dir
+        if name is None:
+            name = self.name
+        if params is None:
+            params = self.params
+        if root_dir is None:
+            root_dir = self.root_dir
 
         # Clone this VM using the new params
         vm = self.clone(name, params, root_dir, copy_state=True)
@@ -1032,7 +1042,7 @@  class VM:
                 logging.debug("VM is down")
                 return
 
-            logging.error("Process %s is a zombie!" % self.process.get_pid())
+            logging.error("Process %s is a zombie!", self.process.get_pid())
 
         finally:
             self.monitors = []
@@ -1322,8 +1332,8 @@  class VM:
         @param internal_timeout: Timeout to pass to login().
         @return: A ShellSession object.
         """
-        logging.debug("Attempting to log into '%s' (timeout %ds)" % (self.name,
-                                                                     timeout))
+        logging.debug("Attempting to log into '%s' (timeout %ds)", self.name,
+                      timeout)
         end_time = time.time() + timeout
         while time.time() < end_time:
             try:
@@ -1426,7 +1436,7 @@  class VM:
         @return: A ShellSession object.
         """
         logging.debug("Attempting to log into '%s' via serial console "
-                      "(timeout %ds)" % (self.name, timeout))
+                      "(timeout %ds)", self.name, timeout)
         end_time = time.time() + timeout
         while time.time() < end_time:
             try:
@@ -1527,7 +1537,7 @@  class VM:
             if offline:
                 self.monitor.cmd("stop")
 
-            logging.info("Migrating to %s" % uri)
+            logging.info("Migrating to %s", uri)
             self.monitor.migrate(uri)
 
             if cancel_delay:
diff --git a/client/tests/kvm/scan_results.py b/client/tests/kvm/scan_results.py
index 97105fb..be825f6 100755
--- a/client/tests/kvm/scan_results.py
+++ b/client/tests/kvm/scan_results.py
@@ -86,7 +86,7 @@  def main(resfiles):
 
 
 if __name__ == "__main__":
-    import sys, os, glob
+    import sys, glob
 
     resfiles = glob.glob("../../results/default/status*")
     if len(sys.argv) > 1:
diff --git a/client/tests/kvm/stepeditor.py b/client/tests/kvm/stepeditor.py
index 43e189f..bcdf572 100755
--- a/client/tests/kvm/stepeditor.py
+++ b/client/tests/kvm/stepeditor.py
@@ -17,14 +17,22 @@  pygtk.require('2.0')
 def corner_and_size_clipped(startpoint, endpoint, limits):
     c0 = startpoint[:]
     c1 = endpoint[:]
-    if c0[0] < 0: c0[0] = 0
-    if c0[1] < 0: c0[1] = 0
-    if c1[0] < 0: c1[0] = 0
-    if c1[1] < 0: c1[1] = 0
-    if c0[0] > limits[0] - 1: c0[0] = limits[0] - 1
-    if c0[1] > limits[1] - 1: c0[1] = limits[1] - 1
-    if c1[0] > limits[0] - 1: c1[0] = limits[0] - 1
-    if c1[1] > limits[1] - 1: c1[1] = limits[1] - 1
+    if c0[0] < 0:
+        c0[0] = 0
+    if c0[1] < 0:
+        c0[1] = 0
+    if c1[0] < 0:
+        c1[0] = 0
+    if c1[1] < 0:
+        c1[1] = 0
+    if c0[0] > limits[0] - 1:
+        c0[0] = limits[0] - 1
+    if c0[1] > limits[1] - 1:
+        c0[1] = limits[1] - 1
+    if c1[0] > limits[0] - 1:
+        c1[0] = limits[0] - 1
+    if c1[1] > limits[1] - 1:
+        c1[1] = limits[1] - 1
     return ([min(c0[0], c1[0]),
              min(c0[1], c1[1])],
             [abs(c1[0] - c0[0]) + 1,
@@ -88,9 +96,12 @@  def key_event_to_qemu_string(event):
     else:
         return ""
 
-    if event.state & gtk.gdk.CONTROL_MASK: str = "ctrl-" + str
-    if event.state & gtk.gdk.MOD1_MASK: str = "alt-" + str
-    if event.state & gtk.gdk.SHIFT_MASK: str = "shift-" + str
+    if event.state & gtk.gdk.CONTROL_MASK:
+        str = "ctrl-" + str
+    if event.state & gtk.gdk.MOD1_MASK:
+        str = "alt-" + str
+    if event.state & gtk.gdk.SHIFT_MASK:
+        str = "shift-" + str
 
     return str
 
@@ -259,7 +270,7 @@  class StepMakerWindow:
         box.pack_start(frame)
         frame.show()
 
-        self.text_buffer = gtk.TextBuffer() ;
+        self.text_buffer = gtk.TextBuffer()
         self.entry_keys = gtk.TextView(self.text_buffer)
         self.entry_keys.set_wrap_mode(gtk.WRAP_WORD)
         self.entry_keys.connect("key-press-event", self.event_key_press)
diff --git a/client/tests/kvm/test_setup.py b/client/tests/kvm/test_setup.py
index e906e18..eebe0c3 100644
--- a/client/tests/kvm/test_setup.py
+++ b/client/tests/kvm/test_setup.py
@@ -1,7 +1,7 @@ 
 """
 Library to perform pre/post test setup for KVM autotest.
 """
-import os, sys, shutil, tempfile, re, ConfigParser, glob, inspect, commands
+import os, shutil, tempfile, re, ConfigParser, glob, inspect
 import logging, time
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.bin import utils