Skip to content

Commit 3453c08

Browse files
committed
Fix up problems pointed out by pylint.
Signed-off-by: Chris Lalancette <[email protected]>
1 parent 0d041ef commit 3453c08

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

oz/Debian.py

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,7 @@ def do_customize(self, guestaddr):
495495

496496
if packstr != '':
497497
self.guest_execute_command(guestaddr,
498-
'apt-get install -y %s' % (packstr),
499-
tunnels=None)
498+
'apt-get install -y %s' % (packstr))
500499

501500
self._customize_files(guestaddr)
502501

@@ -552,7 +551,7 @@ def _get_kernel_from_txt_cfg(self, fetchurl):
552551
raise oz.OzException.OzException("Could not find %s" % (txtcfgurl))
553552

554553
txtcfg = os.path.join(self.icicle_tmp, "txt.cfg")
555-
self.log.debug("Going to write txt.cfg to %s" % (txtcfg))
554+
self.log.debug("Going to write txt.cfg to %s", txtcfg)
556555
txtcfgfd = os.open(txtcfg, os.O_RDWR | os.O_CREAT | os.O_TRUNC)
557556
os.unlink(txtcfg)
558557
fp = os.fdopen(txtcfgfd)
@@ -580,7 +579,7 @@ def _get_kernel_from_txt_cfg(self, fetchurl):
580579
if kernel is None or initrd is None:
581580
raise oz.OzException.OzException("Empty kernel or initrd")
582581

583-
self.log.debug("Returning kernel %s and initrd %s" % (kernel, initrd))
582+
self.log.debug("Returning kernel %s and initrd %s", kernel, initrd)
584583
return (kernel, initrd)
585584

586585
def _gzip_file(self, inputfile, outputmode):
@@ -606,7 +605,7 @@ def _create_cpio_initrd(self, preseedpath):
606605
Internal method to create a modified CPIO initrd
607606
"""
608607
extrafname = os.path.join(self.icicle_tmp, "extra.cpio")
609-
self.log.debug("Writing cpio to %s" % (extrafname))
608+
self.log.debug("Writing cpio to %s", extrafname)
610609
cpiofiledict = {}
611610
cpiofiledict[preseedpath] = 'preseed.cfg'
612611
oz.ozutil.write_cpio(cpiofiledict, extrafname)
@@ -631,30 +630,40 @@ def _initrd_inject_preseed(self, fetchurl, force_download):
631630
pass
632631

633632
if kernel is None:
634-
self.log.debug("Kernel was None, trying debian-installer/%s/linux" % (self.debarch))
633+
self.log.debug("Kernel was None, trying debian-installer/%s/linux", self.debarch)
635634
# we couldn't find the kernel in the txt.cfg, so try a
636635
# hard-coded path
637636
kernel = "debian-installer/%s/linux" % (self.debarch)
638637
if initrd is None:
639-
self.log.debug("Initrd was None, trying debian-installer/%s/initrd.gz" % (self.debarch))
638+
self.log.debug("Initrd was None, trying debian-installer/%s/initrd.gz", self.debarch)
640639
# we couldn't find the initrd in the txt.cfg, so try a
641640
# hard-coded path
642641
initrd = "debian-installer/%s/initrd.gz" % (self.debarch)
643642

644-
self._get_original_media('/'.join([self.url.rstrip('/'),
645-
kernel.lstrip('/')]),
646-
self.kernelcache, force_download)
643+
(fd, outdir) = self._open_locked_file(self.kernelcache)
647644

648645
try:
649646
self._get_original_media('/'.join([self.url.rstrip('/'),
650-
initrd.lstrip('/')]),
651-
self.initrdcache, force_download)
652-
except:
653-
os.unlink(self.kernelfname)
654-
raise
647+
kernel.lstrip('/')]),
648+
fd, outdir, force_download)
649+
650+
# if we made it here, then we can copy the kernel into place
651+
shutil.copyfile(self.kernelcache, self.kernelfname)
652+
finally:
653+
os.close(fd)
654+
655+
(fd, outdir) = self._open_locked_file(self.initrdcache)
655656

656-
# if we made it here, then we can copy the kernel into place
657-
shutil.copyfile(self.kernelcache, self.kernelfname)
657+
try:
658+
try:
659+
self._get_original_media('/'.join([self.url.rstrip('/'),
660+
initrd.lstrip('/')]),
661+
fd, outdir, force_download)
662+
except:
663+
os.unlink(self.kernelfname)
664+
raise
665+
finally:
666+
os.close(fd)
658667

659668
try:
660669
preseedpath = os.path.join(self.icicle_tmp, "preseed.cfg")

oz/Guest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ def _generate_xml(self, bootdev, installdev, kernel=None, initrd=None,
516516
# install disk (if any)
517517
if not installdev:
518518
installdev_list = []
519-
elif not type(installdev) is list:
519+
elif not isinstance(installdev, list):
520520
installdev_list = [installdev]
521521
else:
522522
installdev_list = installdev

oz/Mageia.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def _cfg_sub(line):
9999
flags = "automatic=method:cdrom"
100100

101101
with open(isolinuxcfg, 'w') as f:
102-
f.write("""\
102+
f.write("""\
103103
default customiso
104104
timeout 1
105105
prompt 0

oz/ozutil.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import os
2323
import random
2424
import subprocess
25-
import tempfile
2625
import errno
2726
import stat
2827
import shutil

0 commit comments

Comments
 (0)