Skip to content

Commit

Permalink
Fixes for pylint.
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette committed Jun 20, 2018
1 parent 79b6d92 commit a68cf44
Show file tree
Hide file tree
Showing 22 changed files with 296 additions and 141 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $(VENV_DIR):
virtualenv: $(VENV_DIR)

unittests:
@[ -f $(VENV_DIR)/bin/activate ] && source $(VENV_DIR)/bin/activate ; python setup.py test
@[ -f $(VENV_DIR)/bin/activate ] && source $(VENV_DIR)/bin/activate ; python3 setup.py test
@(type deactivate 2>/dev/null | grep -q 'function') && deactivate || true

tests: unittests
Expand All @@ -52,7 +52,7 @@ test-coverage:
xdg-open htmlcov/index.html

pylint:
pylint --rcfile=pylint.conf oz oz-install oz-customize oz-cleanup-cache oz-generate-icicle
pylint-3 --rcfile=pylint.conf oz oz-install oz-customize oz-cleanup-cache oz-generate-icicle

flake8:
flake8-3 --ignore=E501 oz
Expand Down
12 changes: 5 additions & 7 deletions oz-cleanup-cache
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import logging
import oz.ozutil

try:
input = raw_input
get_input = raw_input
except NameError:
pass
get_input = input

def usage():
print("Usage: oz-cleanup-cache [OPTIONS]")
Expand All @@ -54,7 +54,6 @@ def main():
force = False
config_file = None
loglevel = logging.ERROR
logformat = "%(message)s"
for o, a in opts:
if o in ("-c", "--config"):
config_file = a
Expand All @@ -73,15 +72,14 @@ def main():
loglevel = logging.DEBUG
elif d_int >= 4:
loglevel = logging.DEBUG
logformat = logging.BASIC_FORMAT
elif o in ("-f", "--force"):
force = True
elif o in ("-h", "--help"):
usage()
else:
assert False, "unhandled option"

if len(args) != 0:
if args:
usage()

try:
Expand All @@ -98,8 +96,8 @@ def main():

if not force:
while True:
response = input("Going to remove all content from %s; continue? (y/N) " % (', '.join(caches)))
if len(response) == 0 or response.lower() == 'n':
response = get_input("Going to remove all content from %s; continue? (y/N) " % (', '.join(caches)))
if not response or response.lower() == 'n':
sys.exit(0)
elif response.lower() == 'y':
break
Expand Down
34 changes: 25 additions & 9 deletions oz/Debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@


class DebianConfiguration(object):
"""
Configuration class for Debian installation.
"""
def __init__(self, need_auto_direct, need_auto_iso, default_netdev,
default_diskbus):
self._need_auto_direct = need_auto_direct
Expand All @@ -41,18 +44,32 @@ def __init__(self, need_auto_direct, need_auto_iso, default_netdev,

@property
def need_auto_direct(self):
"""
Property method for whether this version of Debian needs 'auto' on the
command-line for direct installs.
"""
return self._need_auto_direct

@property
def need_auto_iso(self):
"""
Property method for whether this version of Debian needs 'auto' on the
command-line for ISO installs.
"""
return self._need_auto_iso

@property
def default_netdev(self):
"""
Property method for the default netdev for this version of Debian.
"""
return self._default_netdev

@property
def default_diskbus(self):
"""
Property method for the default diskbus for this version of Debian.
"""
return self._default_diskbus


Expand Down Expand Up @@ -138,8 +155,7 @@ def _preseed_sub(line):
return 'd-i passwd/root-password password ' + self.rootpw + '\n'
elif re.match('d-i passwd/root-password-again password', line):
return 'd-i passwd/root-password-again password ' + self.rootpw + '\n'
else:
return line
return line

oz.ozutil.copy_modify_file(self.auto, outname, _preseed_sub)
else:
Expand Down Expand Up @@ -228,7 +244,7 @@ def _get_service_runlevel_link(self, g_handle, service):
if re.match('# chkconfig:', line):
try:
startlevel = line.split(':')[1].split()[1]
except:
except Exception:
pass
break

Expand Down Expand Up @@ -454,9 +470,9 @@ def do_icicle(self, guestaddr):
XML.
"""
self.log.debug("Generating ICICLE")
stdout, stderr, retcode = self.guest_execute_command(guestaddr,
'dpkg --get-selections',
timeout=30)
stdout, stderr_unused, retcode_unused = self.guest_execute_command(guestaddr,
'dpkg --get-selections',
timeout=30)

# the data we get back from dpkg is in the form of:
#
Expand Down Expand Up @@ -560,7 +576,7 @@ def _initrd_inject_preseed(self, fetchurl, force_download):
initrd = None
try:
(kernel, initrd) = self._get_kernel_from_txt_cfg(fetchurl)
except:
except Exception:
pass

if kernel is None:
Expand Down Expand Up @@ -654,14 +670,14 @@ def cleanup_install(self):
for fname in [self.output_iso, self.initrdfname, self.kernelfname]:
try:
os.unlink(fname)
except:
except Exception:
pass

if not self.cache_original_media:
for fname in [self.orig_iso, self.kernelcache, self.initrdcache]:
try:
os.unlink(fname)
except:
except Exception:
pass


Expand Down
38 changes: 34 additions & 4 deletions oz/Fedora.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@


class FedoraConfiguration(object):
"""
The configuration class for Fedora.
"""
def __init__(self, has_virtio_channel, use_yum, use_dev_cdrom_device,
createpart, directkernel, default_netdev, default_diskbus,
brokenisomethod, haverepo):
Expand All @@ -42,38 +45,66 @@ def __init__(self, has_virtio_channel, use_yum, use_dev_cdrom_device,

@property
def has_virtio_channel(self):
"""
Property method for whether this Fedora version has a virtio channel.
"""
return self._has_virtio_channel

@property
def use_yum(self):
"""
Property method for whether this Fedora version uses yum or dnf.
"""
return self._use_yum

@property
def use_dev_cdrom_device(self):
"""
Property method for whether this Fedora version uses /dev/cdrom on the
kickstart command-line.
"""
return self._use_dev_cdrom_device

@property
def createpart(self):
"""
Property method for whether to create partitions before installation.
"""
return self._createpart

@property
def directkernel(self):
"""
Property method for whether this Fedora version supports direct kernel boot.
"""
return self._directkernel

@property
def default_netdev(self):
"""
Property method for the default netdev for this Fedora version.
"""
return self._default_netdev

@property
def default_diskbus(self):
"""
Property method for the default diskbus for this Fedora version.
"""
return self._default_diskbus

@property
def brokenisomethod(self):
"""
Property method for whether to add method to the anaconda install line.
"""
return self._brokenisomethod

@property
def haverepo(self):
"""
Property method for whether to use 'repo=' or 'method=' on the anaconda install line.
"""
return self._haverepo


Expand Down Expand Up @@ -197,8 +228,8 @@ class FedoraGuest(oz.RedHat.RedHatLinuxCDYumGuest):
"""
# Note that the 'brokenisomethod' and 'haverepo' parameters are completely
# ignored now; we leave it in place for backwards API compatibility.
def __init__(self, tdl, config, auto, nicmodel, haverepo, diskbus,
brokenisomethod, output_disk=None, macaddress=None,
def __init__(self, tdl, config, auto, nicmodel, haverepo, diskbus, # pylint: disable=unused-argument
brokenisomethod, output_disk=None, macaddress=None, # pylint: disable=unused-argument
assumed_update=None):
self.config = version_to_config[tdl.update]
if nicmodel is None:
Expand Down Expand Up @@ -269,8 +300,7 @@ def get_auto_path(self):
# newest known auto file; otherwise, do the usual thing.
if self.assumed_update is not None:
return oz.ozutil.generate_full_auto_path(self.tdl.distro + self.assumed_update + ".auto")
else:
return oz.ozutil.generate_full_auto_path(self.tdl.distro + self.tdl.update + ".auto")
return oz.ozutil.generate_full_auto_path(self.tdl.distro + self.tdl.update + ".auto")


def get_class(tdl, config, auto, output_disk=None, netdev=None, diskbus=None,
Expand Down
7 changes: 7 additions & 0 deletions oz/FedoraCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@


class FedoraCoreConfiguration(object):
"""
Configuration class for Fedora Core installation.
"""
def __init__(self, initrdtype):
self._initrdtype = initrdtype

@property
def initrdtype(self):
"""
Property method for the type of initrd this version of Fedora uses
('cpio' or 'ext2').
"""
return self._initrdtype


Expand Down
13 changes: 11 additions & 2 deletions oz/FreeBSD.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,25 @@


class FreeBSDConfiguration(object):
"""
Configuration class for FreeBSD.
"""
def __init__(self, default_netdev, default_diskbus):
self._default_netdev = default_netdev
self._default_diskbus = default_diskbus

@property
def default_netdev(self):
"""
Property method for the default netdev for this FreeBSD version.
"""
return self._default_netdev

@property
def default_diskbus(self):
"""
Property method for the default diskbus for this FreeBSD version.
"""
return self._default_diskbus


Expand Down Expand Up @@ -90,8 +99,8 @@ def _replace(line):
keys = {
'#ROOTPW#': self.rootpw,
}
for key, val in keys.iteritems():
line = line.replace(key, val)
for key in keys:
line = line.replace(key, keys[key])
return line

# Copy the installconfig file to /etc/ on the iso image so bsdinstall(8)
Expand Down
Loading

0 comments on commit a68cf44

Please sign in to comment.