Fix pylint errors in __init__.py

This commit is contained in:
Martin Gracik 2010-12-02 12:59:08 +01:00
parent 449df91699
commit 55f6acb620
1 changed files with 31 additions and 36 deletions

View File

@ -126,16 +126,15 @@ class Lorax(BaseLoraxClass):
if line and not line.startswith("#"): if line and not line.startswith("#"):
self.output.ignore(line) self.output.ignore(line)
# XXX cron does not have sbin in PATH, # cron does not have sbin in PATH,
# so we have to add it ourselves # so we have to add it ourselves
os.environ["PATH"] = "{0}:/sbin:/usr/sbin".format(os.environ["PATH"]) os.environ["PATH"] = "{0}:/sbin:/usr/sbin".format(os.environ["PATH"])
self._configured = True self._configured = True
def run(self, yb, product, version, release, variant="", bugurl="", def run(self, ybo, product, version, release, variant="", bugurl="",
is_beta=False, workdir=None, outputdir=None): is_beta=False, workdir=None, outputdir=None):
# XXX
assert self._configured assert self._configured
# do we have root privileges? # do we have root privileges?
@ -144,7 +143,7 @@ class Lorax(BaseLoraxClass):
logger.critical("no root privileges") logger.critical("no root privileges")
sys.exit(1) sys.exit(1)
# XXX do we have all lorax required commands? # do we have all lorax required commands?
self.lcmds = constants.LoraxRequiredCommands() self.lcmds = constants.LoraxRequiredCommands()
missing = self.lcmds.get_missing() missing = self.lcmds.get_missing()
if missing: if missing:
@ -153,13 +152,13 @@ class Lorax(BaseLoraxClass):
# do we have a proper yum base object? # do we have a proper yum base object?
logger.info("checking yum base object") logger.info("checking yum base object")
if not isinstance(yb, yum.YumBase): if not isinstance(ybo, yum.YumBase):
logger.critical("no yum base object") logger.critical("no yum base object")
sys.exit(1) sys.exit(1)
# set up yum helper # set up yum helper
logger.info("setting up yum helper") logger.info("setting up yum helper")
self.yum = yumhelper.LoraxYumHelper(yb) self.yum = yumhelper.LoraxYumHelper(ybo)
logger.debug("using install root: {0}".format(self.yum.installroot)) logger.debug("using install root: {0}".format(self.yum.installroot))
# set up build architecture # set up build architecture
@ -169,8 +168,6 @@ class Lorax(BaseLoraxClass):
logger.debug("set buildarch = {0.buildarch}".format(self)) logger.debug("set buildarch = {0.buildarch}".format(self))
archmap = ARCHMAPS.get(self.buildarch) archmap = ARCHMAPS.get(self.buildarch)
# XXX
assert archmap is not None assert archmap is not None
self.basearch = archmap.get("base") self.basearch = archmap.get("base")
@ -202,7 +199,7 @@ class Lorax(BaseLoraxClass):
logger.debug("set bugurl = {0.bugurl}".format(self)) logger.debug("set bugurl = {0.bugurl}".format(self))
logger.debug("set is_beta = {0.is_beta}".format(self)) logger.debug("set is_beta = {0.is_beta}".format(self))
# XXX set up work directory # set up work directory
logger.info("setting up work directory") logger.info("setting up work directory")
self.workdir = workdir or tempfile.mkdtemp(prefix="pylorax.work.") self.workdir = workdir or tempfile.mkdtemp(prefix="pylorax.work.")
if not os.path.isdir(self.workdir): if not os.path.isdir(self.workdir):
@ -214,12 +211,12 @@ class Lorax(BaseLoraxClass):
tfile = joinpaths(self.conf.get("lorax", "sharedir"), tfile = joinpaths(self.conf.get("lorax", "sharedir"),
self.conf.get("templates", "ramdisk")) self.conf.get("templates", "ramdisk"))
vars = { "basearch": self.basearch, tvars = { "basearch": self.basearch,
"libdir" : self.libdir, "libdir" : self.libdir,
"product": self.product.lower() } "product": self.product.lower() }
template = ltmpl.LoraxTemplate() template = ltmpl.LoraxTemplate()
template = template.parse(tfile, vars) template = template.parse(tfile, tvars)
# get list of required packages # get list of required packages
logger.info("getting list of required packages") logger.info("getting list of required packages")
@ -238,7 +235,7 @@ class Lorax(BaseLoraxClass):
buildstamp.write() buildstamp.write()
shutil.copy2(buildstamp.path, self.installtree.root) shutil.copy2(buildstamp.path, self.installtree.root)
# XXX save list of installed packages # save list of installed packages
with open(joinpaths(self.workdir, "packages"), "w") as fobj: with open(joinpaths(self.workdir, "packages"), "w") as fobj:
for pkgname in self.installtree.yum.installed_packages: for pkgname in self.installtree.yum.installed_packages:
fobj.write("{0}\n".format(pkgname)) fobj.write("{0}\n".format(pkgname))
@ -324,7 +321,6 @@ class Lorax(BaseLoraxClass):
shutil.copy2(discinfo.path, self.outputtree.root) shutil.copy2(discinfo.path, self.outputtree.root)
# XXX
grubefi = joinpaths(self.installtree.root, "boot/efi/EFI/redhat", grubefi = joinpaths(self.installtree.root, "boot/efi/EFI/redhat",
"grub.efi") "grub.efi")
@ -386,8 +382,8 @@ class Lorax(BaseLoraxClass):
fpath=joinpaths(self.workdir, "initrd.img")) fpath=joinpaths(self.workdir, "initrd.img"))
logger.info("compressing install tree") logger.info("compressing install tree")
ok, elapsed = self.installtree.compress(initrd) success, elapsed = self.installtree.compress(initrd)
if not ok: if not success:
logger.error("error while compressing install tree") logger.error("error while compressing install tree")
else: else:
logger.info("took {0:.2f} seconds".format(elapsed)) logger.info("took {0:.2f} seconds".format(elapsed))
@ -433,7 +429,7 @@ class Lorax(BaseLoraxClass):
logger.critical("unable to create efiboot image") logger.critical("unable to create efiboot image")
sys.exit(1) sys.exit(1)
# XXX copy efiboot and efidisk to imgdir # copy efiboot and efidisk to imgdir
shutil.copy2(efiboot, self.outputtree.imgdir) shutil.copy2(efiboot, self.outputtree.imgdir)
shutil.copy2(efidisk, self.outputtree.imgdir) shutil.copy2(efidisk, self.outputtree.imgdir)
@ -461,7 +457,7 @@ class Lorax(BaseLoraxClass):
def get_buildarch(self): def get_buildarch(self):
# get architecture of the available anaconda package # get architecture of the available anaconda package
installed, available = self.yum.search("anaconda") _, available = self.yum.search("anaconda")
if available: if available:
anaconda = available.pop(0) anaconda = available.pop(0)
@ -529,11 +525,11 @@ class Lorax(BaseLoraxClass):
if os.path.isfile(efiboot): if os.path.isfile(efiboot):
os.unlink(efiboot) os.unlink(efiboot)
# XXX calculate the size of the efi tree directory # calculate the size of the efi tree directory
overhead = 512 * 1024 overhead = 512 * 1024
sizeinbytes = overhead sizeinbytes = overhead
for root, dnames, fnames in os.walk(efitree): for root, _, fnames in os.walk(efitree):
for fname in fnames: for fname in fnames:
fpath = joinpaths(root, fname) fpath = joinpaths(root, fname)
fsize = os.path.getsize(fpath) fsize = os.path.getsize(fpath)
@ -547,8 +543,8 @@ class Lorax(BaseLoraxClass):
cmd = [self.lcmds.MKDOSFS, "-n", "ANACONDA", "-C", efiboot, str(size)] cmd = [self.lcmds.MKDOSFS, "-n", "ANACONDA", "-C", efiboot, str(size)]
logger.debug(cmd) logger.debug(cmd)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
p.wait() proc.wait()
# mount the efiboot image # mount the efiboot image
efibootdir = tempfile.mkdtemp(prefix="efiboot.", dir=self.workdir) efibootdir = tempfile.mkdtemp(prefix="efiboot.", dir=self.workdir)
@ -556,8 +552,8 @@ class Lorax(BaseLoraxClass):
cmd = [self.lcmds.MOUNT, "-o", "loop,shortname=winnt,umask=0777", cmd = [self.lcmds.MOUNT, "-o", "loop,shortname=winnt,umask=0777",
"-t", "vfat", efiboot, efibootdir] "-t", "vfat", efiboot, efibootdir]
logger.debug(cmd) logger.debug(cmd)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
p.wait() proc.wait()
# copy the files to the efiboot image # copy the files to the efiboot image
dst = joinpaths(efibootdir, "EFI/BOOT") dst = joinpaths(efibootdir, "EFI/BOOT")
@ -573,8 +569,8 @@ class Lorax(BaseLoraxClass):
# unmount the efiboot image # unmount the efiboot image
cmd = [self.lcmds.UMOUNT, efibootdir] cmd = [self.lcmds.UMOUNT, efibootdir]
logger.debug(cmd) logger.debug(cmd)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
p.wait() proc.wait()
# remove the work directories # remove the work directories
shutil.rmtree(efibootdir) shutil.rmtree(efibootdir)
@ -616,10 +612,10 @@ class Lorax(BaseLoraxClass):
str(partsize + 17408), "set", "1", "boot", "on"] str(partsize + 17408), "set", "1", "boot", "on"]
logger.debug(cmd) logger.debug(cmd)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
rc = p.wait() retcode = proc.wait()
if not rc == 0: if not retcode == 0:
remove_dm_dev(dmdev) remove_dm_dev(dmdev)
remove_loop_dev(loopdev) remove_loop_dev(loopdev)
os.unlink(efidisk) os.unlink(efidisk)
@ -639,7 +635,6 @@ class Lorax(BaseLoraxClass):
return efidisk return efidisk
def create_bootiso(self, outputtree, efiboot=None): def create_bootiso(self, outputtree, efiboot=None):
bootiso = joinpaths(self.workdir, "boot.iso") bootiso = joinpaths(self.workdir, "boot.iso")
if os.path.isfile(bootiso): if os.path.isfile(bootiso):
os.unlink(bootiso) os.unlink(bootiso)
@ -660,20 +655,20 @@ class Lorax(BaseLoraxClass):
"isolinux={0}".format(outputtree.isolinuxdir), "isolinux={0}".format(outputtree.isolinuxdir),
"images={0}".format(outputtree.imgdir)] + efigraft "images={0}".format(outputtree.imgdir)] + efigraft
logger.debug(cmd) logger.debug(cmd)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
rc = p.wait() retcode = proc.wait()
if not rc == 0: if not retcode == 0:
return None return None
# create hybrid iso # create hybrid iso
cmd = [self.lcmds.ISOHYBRID, bootiso] cmd = [self.lcmds.ISOHYBRID, bootiso]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
rc = p.wait() retcode = proc.wait()
# implant iso md5 # implant iso md5
cmd = [self.lcmds.IMPLANTISOMD5, bootiso] cmd = [self.lcmds.IMPLANTISOMD5, bootiso]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
rc = p.wait() retcode = proc.wait()
return bootiso return bootiso