Pylint warnings.
authorSun Lihong <lihongx.sun@intel.com>
Wed, 30 Apr 2014 07:01:31 +0000 (15:01 +0800)
committerSun Lihong <lihongx.sun@intel.com>
Wed, 30 Apr 2014 07:14:06 +0000 (15:14 +0800)
C:139,8:Zypp._zyppQueryPackage: Comma not followed by a space
        query.addAttribute(zypp.SolvAttr.name,pkg)
                                             ^^
C:146,8:Zypp._splitPkgString: Comma not followed by a space
        sp = pkg.rsplit(".",1)
                           ^^
C:213,12:Zypp.selectPackage: Comma not followed by a space
            q.addAttribute(zypp.SolvAttr.name,pattern)
                                             ^^
C:217,12:Zypp.selectPackage: Comma not followed by a space
            q.addAttribute(zypp.SolvAttr.name,name)
                                             ^^
C:221,12:Zypp.selectPackage: Comma not followed by a space
            q.addAttribute(zypp.SolvAttr.name,pkg)
                                             ^^
W: 19,0: Unused import sys
W: 35,0: Unused import BaseImageCreator
W: 20,0: Unused import re

Change-Id: Ie6bdff4de495e93b0dd534c276cb77d5270db114

plugins/backend/yumpkgmgr.py
plugins/backend/zypppkgmgr.py
plugins/imager/fs_plugin.py
plugins/imager/raw_plugin.py
tools/mic

index 6884551..05f4dba 100644 (file)
@@ -16,8 +16,7 @@
 # with this program; if not, write to the Free Software Foundation, Inc., 59
 # Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import os, sys
-import re
+import os
 import tempfile
 import glob
 from string import Template
@@ -32,7 +31,6 @@ from mic.utils.grabber import TextProgress
 from mic.utils.proxy import get_proxy_for
 from mic.utils.errors import CreatorError
 from mic.utils.safeurl import SafeURL
-from mic.imager.baseimager import BaseImageCreator
 
 
 YUMCONF_TEMP = """[main]
@@ -387,7 +385,7 @@ class Yum(BackendPlugin, yum.YumBase):
                               % (os.path.basename(local), local))
             else:
                 download_total_size -= int(po.packagesize)
-                cached_count +=1
+                cached_count += 1
 
         cache_avail_size = misc.get_filesystem_avail(self.cachedir)
         if cache_avail_size < download_total_size:
index b323da9..e0b0a1b 100644 (file)
@@ -136,14 +136,14 @@ class Zypp(BackendPlugin):
     def _zyppQueryPackage(self, pkg):
         query = zypp.PoolQuery()
         query.addKind(zypp.ResKind.package)
-        query.addAttribute(zypp.SolvAttr.name,pkg)
+        query.addAttribute(zypp.SolvAttr.name, pkg)
         query.setMatchExact()
         for pi in query.queryResults(self.Z.pool()):
             return pi
         return None
 
     def _splitPkgString(self, pkg):
-        sp = pkg.rsplit(".",1)
+        sp = pkg.rsplit(".", 1)
         name = sp[0]
         arch = None
         if len(sp) == 2:
@@ -210,15 +210,15 @@ class Zypp(BackendPlugin):
             if endx and startx:
                 pattern = '%s' % (pkg[1:-1])
             q.setMatchRegex()
-            q.addAttribute(zypp.SolvAttr.name,pattern)
+            q.addAttribute(zypp.SolvAttr.name, pattern)
 
         elif arch:
             q.setMatchExact()
-            q.addAttribute(zypp.SolvAttr.name,name)
+            q.addAttribute(zypp.SolvAttr.name, name)
 
         else:
             q.setMatchExact()
-            q.addAttribute(zypp.SolvAttr.name,pkg)
+            q.addAttribute(zypp.SolvAttr.name, pkg)
 
         for pitem in sorted(
                         q.queryResults(self.Z.pool()),
@@ -283,17 +283,17 @@ class Zypp(BackendPlugin):
             if not ispattern:
                 if pkgarch:
                     if name == pkgname and str(item.arch()) == pkgarch:
-                        return True;
+                        return True
                 else:
                     if name == pkgname:
-                        return True;
+                        return True
             else:
                 if startx and name.endswith(pkg[1:]):
-                    return True;
+                    return True
                 if endx and name.startswith(pkg[:-1]):
-                    return True;
+                    return True
 
-        return False;
+        return False
 
     def deselectPackage(self, pkg):
         """collect packages should not be installed"""
@@ -303,7 +303,7 @@ class Zypp(BackendPlugin):
         if not self.Z:
             self.__initialize_zypp()
         found = False
-        q=zypp.PoolQuery()
+        q = zypp.PoolQuery()
         q.addKind(zypp.ResKind.pattern)
         for pitem in q.queryResults(self.Z.pool()):
             item = zypp.asKindPattern(pitem)
@@ -380,7 +380,8 @@ class Zypp(BackendPlugin):
             if not ssl_verify:
                 baseurl.setQueryParam("ssl_verify", "no")
             if proxy:
-                scheme, host, path, parm, query, frag = urlparse.urlparse(proxy)
+                host = urlparse.urlparse(proxy)[1]
+                # scheme, host, path, parm, query, frag = urlparse.urlparse(proxy)
 
                 proxyinfo = host.rsplit(":", 1)
                 host = proxyinfo[0]
@@ -712,7 +713,7 @@ class Zypp(BackendPlugin):
     def getLocalPkgPath(self, po):
         repoinfo = po.repoInfo()
         cacheroot = repoinfo.packagesPath()
-        location= po.location()
+        location = po.location()
         rpmpath = str(location.filename())
         pkgpath = "%s/%s" % (cacheroot, os.path.basename(rpmpath))
         return pkgpath
@@ -894,7 +895,7 @@ class Zypp(BackendPlugin):
                                   % (package, deppkg))
 
                 elif sense == rpm.RPMDEP_SENSE_CONFLICTS:
-                    msger.warning("[%s] Conflicts with [%s]" %(package,deppkg))
+                    msger.warning("[%s] Conflicts with [%s]" % (package, deppkg))
 
             raise RepoError("Unresolved dependencies, transaction failed.")
 
index 9d4d79f..a97fae4 100644 (file)
@@ -15,9 +15,6 @@
 # with this program; if not, write to the Free Software Foundation, Inc., 59
 # Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-import os
-import sys
-
 from mic import chroot, msger, rt_util
 from mic.utils import cmdln, misc, errors, fs_related
 from mic.imager import fs
@@ -30,10 +27,10 @@ class FsPlugin(ImagerPlugin):
 
     @classmethod
     @cmdln.option("--include-src",
-                  dest="include_src",
-                  action="store_true",
-                  default=False,
-                  help="Generate a image with source rpms included")
+                  dest = "include_src",
+                  action = "store_true",
+                  default = False,
+                  help = "Generate a image with source rpms included")
     def do_create(self, subcmd, opts, *args):
         """${cmd_name}: create fs image
 
@@ -75,9 +72,11 @@ class FsPlugin(ImagerPlugin):
 
         configmgr._ksconf = ksconf
 
-        # Called After setting the configmgr._ksconf as the creatoropts['name'] is reset there.
+        # Called After setting the configmgr._ksconf as the
+        # creatoropts['name'] is reset there.
         if creatoropts['release'] is not None:
-            creatoropts['outdir'] = "%s/%s/images/%s/" % (creatoropts['outdir'], creatoropts['release'], creatoropts['name'])
+            creatoropts['outdir'] = "%s/%s/images/%s/" % (creatoropts['outdir'],
+                    creatoropts['release'], creatoropts['name'])
 
         # try to find the pkgmgr
         pkgmgr = None
@@ -119,7 +118,8 @@ class FsPlugin(ImagerPlugin):
                 installed_pkgs =  creator.get_installed_packages()
                 msger.info('--------------------------------------------------')
                 msger.info('Generating the image with source rpms included ...')
-                if not misc.SrcpkgsDownload(installed_pkgs, creatoropts["repomd"], creator._instroot, creatoropts["cachedir"]):
+                if not misc.SrcpkgsDownload(installed_pkgs, creatoropts["repomd"],
+                        creator._instroot, creatoropts["cachedir"]):
                     msger.warning("Source packages can't be downloaded")
 
             creator.configure(creatoropts["repomd"])
@@ -128,7 +128,8 @@ class FsPlugin(ImagerPlugin):
             creator.package(creatoropts["outdir"])
             creator.create_manifest()
             if creatoropts['release'] is not None:
-                creator.release_output(ksconf, creatoropts['outdir'], creatoropts['release'])
+                creator.release_output(ksconf, creatoropts['outdir'],
+                        creatoropts['release'])
             creator.print_outimage_info()
         except errors.CreatorError:
             raise
index 905a7d0..636003c 100644 (file)
@@ -33,18 +33,18 @@ class RawPlugin(ImagerPlugin):
     name = 'raw'
 
     @classmethod
-    @cmdln.option("--compress-disk-image", dest="compress_image", type='choice',
-                  choices=("gz", "bz2", "lzo"), default=None,
-                  help="Same with --compress-image")
-    @cmdln.option("--compress-image", dest="compress_image", type='choice',
-                  choices=("gz", "bz2", "lzo"), default=None,
-                  help="Compress all raw images before package, Note: if you want "
+    @cmdln.option("--compress-disk-image", dest = "compress_image", type = 'choice',
+                  choices = ("gz", "bz2", "lzo"), default = None,
+                  help = "Same with --compress-image")
+    @cmdln.option("--compress-image", dest = "compress_image", type = 'choice',
+                  choices = ("gz", "bz2", "lzo"), default = None,
+                  help = "Compress all raw images before package, Note: if you want "
                   "to use 'lzo', package 'lzop' is needed to be installed manually.")
-    @cmdln.option("--generate-bmap", action="store_true", default = None,
-                  help="also generate the block map file")
-    @cmdln.option("--fstab-entry", dest="fstab_entry", type='choice',
-                  choices=("name", "uuid"), default="uuid",
-                  help="Set fstab entry, 'name' means using device names, "
+    @cmdln.option("--generate-bmap", action = "store_true", default = None,
+                  help = "also generate the block map file")
+    @cmdln.option("--fstab-entry", dest = "fstab_entry", type = 'choice',
+                  choices = ("name", "uuid"), default = "uuid",
+                  help = "Set fstab entry, 'name' means using device names, "
                        "'uuid' means using filesystem uuid")
     def do_create(self, subcmd, opts, *args):
         """${cmd_name}: create raw image
@@ -89,7 +89,8 @@ class RawPlugin(ImagerPlugin):
 
         # Called After setting the configmgr._ksconf as the creatoropts['name'] is reset there.
         if creatoropts['release'] is not None:
-            creatoropts['outdir'] = "%s/%s/images/%s/" % (creatoropts['outdir'], creatoropts['release'], creatoropts['name'])
+            creatoropts['outdir'] = "%s/%s/images/%s/" % (creatoropts['outdir'],
+                    creatoropts['release'], creatoropts['name'])
 
         # try to find the pkgmgr
         pkgmgr = None
@@ -178,7 +179,7 @@ class RawPlugin(ImagerPlugin):
         else:
             root_mounted = False
         partition_mounts = 0
-        for line in runner.outs([partedcmd,"-s",img,"unit","B","print"]).splitlines():
+        for line in runner.outs([ partedcmd, "-s", img, "unit", "B", "print" ]).splitlines():
             line = line.strip()
 
             # Lines that start with number are the partitions,
@@ -190,12 +191,12 @@ class RawPlugin(ImagerPlugin):
             line = line.replace(",","")
 
             # Example of parted output lines that are handled:
-            # Number  Start        End          Size         Type     File system     Flags
+            # Number  Start        End          Size         Type     File system    Flags
             #  1      512B         3400000511B  3400000000B  primary
             #  2      3400531968B  3656384511B  255852544B   primary  linux-swap(v1)
-            #  3      3656384512B  3720347647B  63963136B    primary  fat16           boot, lba
+            #  3      3656384512B  3720347647B  63963136B    primary  fat16          boot, lba
 
-            partition_info = re.split("\s+",line)
+            partition_info = re.split("\s+", line)
 
             size = partition_info[3].split("B")[0]
 
@@ -205,18 +206,19 @@ class RawPlugin(ImagerPlugin):
                 # not recognize properly.
                 # TODO: Can we make better assumption?
                 fstype = "btrfs"
-            elif partition_info[5] in ["ext2","ext3","ext4","btrfs"]:
+            elif partition_info[5] in [ "ext2", "ext3", "ext4", "btrfs" ]:
                 fstype = partition_info[5]
-            elif partition_info[5] in ["fat16","fat32"]:
+            elif partition_info[5] in [ "fat16", "fat32" ]:
                 fstype = "vfat"
             elif "swap" in partition_info[5]:
                 fstype = "swap"
             else:
-                raise errors.CreatorError("Could not recognize partition fs type '%s'." % partition_info[5])
+                raise errors.CreatorError("Could not recognize partition fs type '%s'." %
+                        partition_info[5])
 
             if rootpart and rootpart == line[0]:
                 mountpoint = '/'
-            elif not root_mounted and fstype in ["ext2","ext3","ext4","btrfs"]:
+            elif not root_mounted and fstype in [ "ext2", "ext3", "ext4", "btrfs" ]:
                 # TODO: Check that this is actually the valid root partition from /etc/fstab
                 mountpoint = "/"
                 root_mounted = True
@@ -232,9 +234,11 @@ class RawPlugin(ImagerPlugin):
             else:
                 boot = False
 
-            msger.verbose("Size: %s Bytes, fstype: %s, mountpoint: %s, boot: %s" % (size, fstype, mountpoint, boot))
+            msger.verbose("Size: %s Bytes, fstype: %s, mountpoint: %s, boot: %s" %
+                    (size, fstype, mountpoint, boot))
             # TODO: add_partition should take bytes as size parameter.
-            imgloop.add_partition((int)(size)/1024/1024, "/dev/sdb", mountpoint, fstype = fstype, boot = boot)
+            imgloop.add_partition((int)(size)/1024/1024, "/dev/sdb", mountpoint,
+                    fstype = fstype, boot = boot)
 
         try:
             imgloop.mount()
index a81a905..fb632e3 100755 (executable)
--- a/tools/mic
+++ b/tools/mic
@@ -109,8 +109,8 @@ class MicCmd(cmdln.Cmdln):
 
     @cmdln.alias("cv")
     @cmdln.option("-S", "--shell",
-                  action="store_true", dest="shell", default=False,
-                  help="Launch shell before packaging the converted image")
+                  action = "store_true", dest = "shell", default = False,
+                  help = "Launch shell before packaging the converted image")
     def do_convert(self, subcmd, opts, *args):
         """${cmd_name}: convert image format
 
@@ -180,8 +180,8 @@ class MicCmd(cmdln.Cmdln):
 
     @cmdln.alias("ch")
     @cmdln.option('-s', '--saveto',
-                  action='store', dest='saveto', default=None,
-                  help="Save the unpacked image to specified dir")
+                  action = 'store', dest = 'saveto', default = None,
+                  help = "Save the unpacked image to specified dir")
     @optparser_setup
     def do_chroot(self, subcmd, opts, *args):
         """${cmd_name}: chroot into an image