Pylint for job_imager.py
authorLingchaox Xin <lingchaox.xin@intel.com>
Tue, 2 Jul 2013 06:50:36 +0000 (14:50 +0800)
committerLingchaox Xin <lingchaox.xin@intel.com>
Tue, 2 Jul 2013 06:50:36 +0000 (14:50 +0800)
Change-Id: I0aab62dd84faa0c9b1426ab0cf9789afc24bedcc

job_imager.py

index 6245b88..4371119 100755 (executable)
@@ -1,5 +1,7 @@
 #!/usr/bin/env python
 
+"""This script is used to create image"""
+
 import os
 import sys
 import subprocess
@@ -7,7 +9,7 @@ import tempfile
 from common.buildtrigger import trigger_info
 from common.utils import sync
 
-kvmic_conf_template ="""
+KVMIC_CONF_TEMPLATE = """
 [general]
 resdir = /usr/share/kvmic
 imgdir = /var/tmp/mic2image
@@ -45,7 +47,8 @@ packages=mic-bootstrap-x86-arm
 """
 
 def gen_kvmic_conf():
-    kvmic_conf_string = kvmic_conf_template %{
+    """Generate kvmic conf file"""
+    kvmic_conf_string = KVMIC_CONF_TEMPLATE % {
         "tmpdir": os.getenv("MIC_TMPDIR", "/var/tmp/mic"),
         "cachedir": os.getenv("MIC_CACHEDIR", "/var/tmp/mic/cache"),
         "outdir": os.path.join(os.getenv("WORKSPACE"),"image"),
@@ -60,6 +63,7 @@ def gen_kvmic_conf():
     return path
 
 def main():
+    """The main body"""
 
     fields = trigger_info(os.getenv('TRIGGER_INFO'))
 
@@ -68,12 +72,9 @@ def main():
         build_id = fields.get("buildid") or 'prerelease'
         name = fields["name"]
         path_to_repo = fields.get("repo_path", '')
-        image_pub_path = fields.get("images_path")
-        image_dest_path = image_pub_path.replace(\
-                os.getenv('IMG_PUB_PATH_BASE','_NULL_'), os.getenv('IMG_DEST_PATH_BASE','_NULL_'))
 
-    except KeyError, e:
-        print 'Lost field: %s' % str(e)
+    except KeyError, ker:
+        print 'Lost field: %s' % str(ker)
         sys.exit(-1)
 
     # Work directory
@@ -89,7 +90,7 @@ def main():
     # Temp configuration
     kvmic_conf = gen_kvmic_conf()
     print 'starting kvmic instance to create image...'
-    kvmic_cmd = "/usr/bin/kvmic -b %s -k %s -d %s -T %s -c %s"  %(build_id,
+    kvmic_cmd = "/usr/bin/kvmic -b %s -k %s -d %s -T %s -c %s"  % (build_id,
                                                                   ks_path,
                                                                   output_path,
                                                                   '20m',
@@ -118,5 +119,4 @@ def main():
     return ret
 
 if __name__ == "__main__":
-
     sys.exit(main())