Make Pylint happier.
authorIgor Stoppa <igor.stoppa@intel.com>
Tue, 4 Nov 2014 09:28:32 +0000 (11:28 +0200)
committerIgor Stoppa <igor.stoppa@intel.com>
Tue, 11 Nov 2014 08:33:10 +0000 (10:33 +0200)
This patch removes a handful of pylint warning:
* indentations
* unused imports and variables

It also replace the error code with its symbolic counterpart,
to make the code more readable.

Change-Id: Ib4910068be77ca694632f7559bc105a012b7e68e

job_imager.py
job_test_build.py

index f22cdb4..e0f8c1b 100755 (executable)
@@ -10,19 +10,20 @@ from random import randint
 
 from common.buildtrigger import trigger_info, trigger_next
 from common.utils import sync, set_permissions, Workdir
-from common.prerelease import is_prerelease_project
+
 
 def get_xml(image_dir, ks_name):
     """ Get the xml the image, return the body as string """
 
-    for root, subdir, files in os.walk(image_dir):
+    for root, _subdir, files in os.walk(image_dir):
         for fname in files:
-            if fname.endswith("%s.xml" %(ks_name)):
+            if fname.endswith("%s.xml" % (ks_name)):
                 return open(os.path.join(root,
                                          fname)).read()
 
     return ''
 
+
 def convert_image_dir(image_dir, repo_name, image_name):
     """
     Insert repo name into image directory hierarchy.
@@ -36,6 +37,7 @@ def convert_image_dir(image_dir, repo_name, image_name):
             return
         shutil.move(image_name, repo_name)
 
+
 def run_inside_vm(vm_image, vm_memory, vm_cpus, basedir):
     """
     Run mic inside VM
@@ -61,8 +63,8 @@ def run_inside_vm(vm_image, vm_memory, vm_cpus, basedir):
     # processid from pid
     # buildid from BUILD_NUMBER
     mac_address = '52:%02x:%02x:%02x:%02x:%02x' % \
-                   (lastip, exeid, processid,
-                    buildid, randint(0x00, 0xff))
+                  (lastip, exeid, processid,
+                   buildid, randint(0x00, 0xff))
     cmd = 'qemu-system-x86_64 -machine accel=kvm:xen:tcg -name '\
           'opensuse -M pc -m %d -smp %d -vga none -drive file=%s,'\
           'snapshot=on -nographic -virtfs local,id=test_dev,'\
@@ -72,7 +74,7 @@ def run_inside_vm(vm_image, vm_memory, vm_cpus, basedir):
 
     subprocess.call(cmd, stdout=sys.stdout,
                     stderr=sys.stderr, shell=True)
-    #read mic status from file
+    # read mic status from file
     try:
         with open(os.path.join(basedir, 'status')) as statusf:
             status = statusf.read().strip()
@@ -80,9 +82,10 @@ def run_inside_vm(vm_image, vm_memory, vm_cpus, basedir):
             return 0
         else:
             return -1
-    except IOError, _err:
+    except IOError:
         return -1
 
+
 def main():
     """The main body"""
 
@@ -116,7 +119,8 @@ def main():
 
     if int(os.getenv('USE_VM')):
         vm_image = os.getenv("VM_IMAGE",
-                os.path.join(os.getenv('JENKINS_HOME'), 'mic-appliance'))
+                             os.path.join(os.getenv('JENKINS_HOME'),
+                                          'mic-appliance'))
         # check if tarball exists
         if not vm_image or not os.access(vm_image, os.R_OK):
             print 'VM image %s is not found' % vm_image
index dab7bd2..cfa1dae 100755 (executable)
@@ -15,11 +15,11 @@ from common.buildtrigger import trigger_info, trigger_next
 
 def fetch_image(url):
     """Tries to download locally the image that will be tested."""
-    logging.info("Attempt retrieving flashable image from {0} ."\
+    logging.info("Attempt retrieving flashable image from {0} ."
                  .format(url))
     try:
         command = ["/usr/bin/wget", "-r", "-l1", "-np", "-nd", "-q", "-A",
-            os.getenv("TESTABLE_IMAGE_DOWNLOADABLES"), url]
+                   os.getenv("TESTABLE_IMAGE_DOWNLOADABLES"), url]
         subprocess.check_output(command)
         image = glob.glob(os.getenv("TESTABLE_IMAGE_FILTER"))[0]
         logging.info("Image retrieved successfully.")
@@ -82,11 +82,12 @@ def pack_results(results_folder):
     else:
         logging.info("Completed packing test results.")
 
+
 def xml_tree_to_dict(tree):
     """Converts junit xml file to a dictionary"""
-    #pylint: disable=W0141
-    dic = {tree.tag : map(xml_tree_to_dict, tree.iterchildren())}
-    #pylint: enable=W0141
+    # pylint: disable=bad-builtin
+    dic = {tree.tag: map(xml_tree_to_dict, tree.iterchildren())}
+    # pylint: enable=bad-builtin
     dic.update(('@' + k, v) for k, v in tree.attrib.iteritems())
     dic['text'] = tree.text
     return dic