; 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]
%{!?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
Name: mic
Summary: Image Creator for Linux Distributions
-Version: 0.6
+Version: 0.7
Release: 1
Group: System/Base
License: GPLv2
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():
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))
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
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):