development after 0.6 release
authorJF Ding <jian-feng.ding@intel.com>
Fri, 17 Feb 2012 14:22:48 +0000 (22:22 +0800)
committerJF Ding <jian-feng.ding@intel.com>
Fri, 17 Feb 2012 14:30:34 +0000 (22:30 +0800)
using the 0.7git version and unified style and
comments for recent patches

VERSION
distfiles/mic.conf
distfiles/mic.spec
distfiles/mic.yaml
mic/conf.py
mic/utils/misc.py
tools/mic

diff --git a/VERSION b/VERSION
index 5a2a580..b183568 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.6
+0.7git
index 7b8d702..cbad959 100644 (file)
@@ -13,8 +13,10 @@ pkgmgr = zypp
 
 ; proxy = http://proxy.yourcompany.com:8080/
 ; no_proxy = localhost,127.0.0.0/8,.yourcompany.com
+
 # Prefix that is added in front of files that are produced.
 ; name_prefix = output
+
 ; ssl_verify = no
 
 [convert]
index d9fd526..6880be6 100644 (file)
@@ -8,7 +8,7 @@
 %{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
 Name:       mic
 Summary:    Image Creator for Linux Distributions
-Version:    0.6
+Version:    0.7
 Release:    1
 Group:      System/Base
 License:    GPLv2
index c504a2c..12628b4 100644 (file)
@@ -1,6 +1,6 @@
 Name: mic
 Summary: Image Creator for Linux Distributions
-Version: 0.6
+Version: 0.7
 Release: 1
 Group: System/Base
 License: GPLv2
index 40dea22..b199483 100644 (file)
@@ -132,17 +132,18 @@ class ConfigMgr(object):
             if section != "common" and not section.startswith('bootstrap'):
                 getattr(self, section).update(self.common)
 
+        # check and normalize the scheme of proxy url
         if self.create['proxy']:
-            urlptn = re.compile('://')
-            m = urlptn.search(self.create['proxy'])
+            m = re.match('^(\w+)://.*', self.create['proxy'])
             if m:
-                scheme = self.create['proxy'].split(':')[0]
+                scheme = m.group(1)
                 if scheme not in ('http', 'https', 'ftp', 'socks'):
                     msger.error("%s: proxy scheme is incorrect" % siteconf)
             else:
-                msger.warning("%s: proxy set without scheme, use http default"
+                msger.warning("%s: proxy url w/o scheme, use http as default"
                               % siteconf)
-                self.create['proxy'] = "http://%s" % self.create['proxy']
+                self.create['proxy'] = "http://" + self.create['proxy']
+
         proxy.set_proxies(self.create['proxy'], self.create['no_proxy'])
 
         for section in parser.sections():
index 9bec55b..de38a3d 100644 (file)
@@ -54,7 +54,9 @@ RPM_FMT = "%(name)s.%(arch)s %(ver_rel)s"
 SRPM_RE = re.compile("(.*)-(\d+.*)-(\d+\.\d+).src.rpm")
 
 def human_size(size):
-    # make Bytes size readable by human
+    """Return human readable string for Bytes size
+    """
+
     import math
     measure = ['B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']
     expo = int(math.log(size, 1024))
@@ -62,12 +64,15 @@ def human_size(size):
     return "{0:.1f}{1:s}".format(mant, measure[expo])
 
 def check_space_pre_cp(src, dst):
-    # check whether space is enough before 'cp'
-    srcsize = get_file_size(src) * 1024 * 1024
-    dstsize = get_filesystem_avail(dst)
-    if srcsize > dstsize:
-        raise CreatorError("Space on %s (%s) is not enough than needed (%s)"
-                           % (dst, human_size(dstsize), human_size(srcsize)))
+    """Check whether disk space is enough before 'cp' like
+    operations, else exception will be raised.
+    """
+
+    srcsize  = get_file_size(src) * 1024 * 1024
+    freesize = get_filesystem_avail(dst)
+    if srcsize > freesize:
+        raise CreatorError("space on %s(%s) is not enough for about %s files"
+                           % (dst, human_size(freesize), human_size(srcsize)))
 
 def get_md5sum(fpath):
     blksize = 65536 # should be optimized enough
index 4d5ee3f..4070357 100755 (executable)
--- a/tools/mic
+++ b/tools/mic
@@ -131,14 +131,18 @@ class MicCmd(cmdln.Cmdln):
         if (srcimager and destimager) is None:
            raise errors.CreatorError("Can't convert from %s to %s" \
                                      % (srcformat, destformat))
+
         else:
-            maptab = {"livecd": "iso",
-                      "liveusb": "usbimg",
-                      "loop": "img"
+            maptab = {
+                        "livecd": "iso",
+                        "liveusb": "usbimg",
+                        "loop": "img",
                      }
-            if destformat in maptab.keys():
+
+            if destformat in maptab:
                 imgname = os.path.splitext(os.path.basename(srcimg))[0]
                 dstname = "{0}.{1}".format(imgname, maptab[destformat])
+
                 if os.path.exists(dstname):
                     if msger.ask("Converted image %s seems existed, "
                                  "remove and continue?" % dstname):