From 09dc6bb5d7106fa5c100c1a0dff30be2aa765323 Mon Sep 17 00:00:00 2001 From: Gormogon Date: Wed, 18 Feb 2015 09:47:24 -0500 Subject: [PATCH] [PEP 8] General Style Part 2 --- src/modules/hwclock/main.py | 2 +- src/modules/initcpio/main.py | 2 ++ src/modules/initramfs/main.py | 1 + src/modules/packages/main.py | 11 +++++++++-- src/modules/services/main.py | 2 +- src/modules/unpackfs/main.py | 23 ++++++++++++----------- 6 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/modules/hwclock/main.py b/src/modules/hwclock/main.py index 7e3ba88d9..4bc672713 100644 --- a/src/modules/hwclock/main.py +++ b/src/modules/hwclock/main.py @@ -32,7 +32,7 @@ def run(): try: subprocess.check_call(["hwclock", "--systohc", "--utc"]) except subprocess.CalledProcessError as e: - return "Cannot set hardware clock.",\ + return "Cannot set hardware clock.", \ "hwclock terminated with exit code {}.".format(e.returncode) shutil.copy2("/etc/adjtime", "{!s}/etc/".format(root_mount_point)) diff --git a/src/modules/initcpio/main.py b/src/modules/initcpio/main.py index 8571ea94f..1a264f9d1 100644 --- a/src/modules/initcpio/main.py +++ b/src/modules/initcpio/main.py @@ -21,10 +21,12 @@ import libcalamares from libcalamares.utils import check_chroot_call + def run_mkinitcpio(): kernel = libcalamares.job.configuration['kernel'] check_chroot_call(['mkinitcpio', '-p', kernel]) + def run(): run_mkinitcpio() return None diff --git a/src/modules/initramfs/main.py b/src/modules/initramfs/main.py index 0467b13a5..cc401312d 100644 --- a/src/modules/initramfs/main.py +++ b/src/modules/initramfs/main.py @@ -20,6 +20,7 @@ from libcalamares.utils import chroot_call + def run(): returnCode = chroot_call(["update-initramfs", "-k", "all", "-u"]) if returnCode != 0: diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index 038a7272b..18fa7874d 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -21,6 +21,7 @@ import libcalamares from libcalamares.utils import check_chroot_call, chroot_call + class PackageManager: def __init__(self, backend): self.backend = backend @@ -30,13 +31,17 @@ class PackageManager: for pkg in pkgs: check_chroot_call(["pkcon", "-py", "install", pkg]) elif self.backend == "zypp": - check_chroot_call(["zypper", "--non-interactive", "--quiet-install", "install", "--auto-agree-with-licenses", "install"] + pkgs) + check_chroot_call( + ["zypper", "--non-interactive", "--quiet-install", "install", + "--auto-agree-with-licenses", "install"] + pkgs) elif self.backend == "yum": check_chroot_call(["yum", "install", "-y"] + pkgs) elif self.backend == "dnf": check_chroot_call(["dnf", "install", "-y"] + pkgs) elif self.backend == "urpmi": - check_chroot_call(["urpmi", "--download-all", "--no-suggests", "--no-verify-rpm", "--fastunsafe", "--ignoresize", "--nolock", "--auto"] + pkgs) + check_chroot_call( + ["urpmi", "--download-all", "--no-suggests", "--no-verify-rpm", + "--fastunsafe", "--ignoresize", "--nolock", "--auto"] + pkgs) elif self.backend == "apt": check_chroot_call(["apt-get", "-q", "-y", "install"] + pkgs) elif self.backend == "pacman": @@ -61,6 +66,7 @@ class PackageManager: elif self.backend == "pacman": check_chroot_call(["pacman", "-Rs", "--noconfirm"] + pkgs) + def run_operations(pkgman, entry): for key in entry.keys(): if key == "install": @@ -68,6 +74,7 @@ def run_operations(pkgman, entry): elif key == "remove": pkgman.remove(entry[key]) + def run(): backend = libcalamares.job.configuration.get("backend") if backend not in ("packagekit", "zypp", "yum", "dnf", "urpmi", "apt", "pacman"): diff --git a/src/modules/services/main.py b/src/modules/services/main.py index bd6cb9e31..941ea51e1 100644 --- a/src/modules/services/main.py +++ b/src/modules/services/main.py @@ -35,7 +35,7 @@ def run(): '{}.service'.format(svc['name'])]) if ec != 0: if svc['mandatory']: - return "Cannot enable systemd service {}".format(svc['name']),\ + return "Cannot enable systemd service {}".format(svc['name']), \ "systemctl enable call in chroot returned error code {}".format(ec) else: libcalamares.utils.debug( diff --git a/src/modules/unpackfs/main.py b/src/modules/unpackfs/main.py index 747e7fb5f..91f947c3a 100644 --- a/src/modules/unpackfs/main.py +++ b/src/modules/unpackfs/main.py @@ -30,8 +30,9 @@ from collections import namedtuple from libcalamares import * + class UnpackEntry: - __slots__= ['source', 'sourcefs', 'destination', 'copied', 'total'] + __slots__ = ['source', 'sourcefs', 'destination', 'copied', 'total'] def __init__(self, source, sourcefs, destination): self.source = source @@ -40,6 +41,7 @@ class UnpackEntry: self.copied = 0 self.total = 0 + ON_POSIX = 'posix' in sys.builtin_module_names @@ -104,7 +106,6 @@ def file_copy(source, dest, progress_cb): class UnpackOperation: - def __init__(self, entries): self.entries = entries self.entry_for_source = dict((x.source, x) for x in self.entries) @@ -117,8 +118,7 @@ class UnpackOperation: partialprogress = 0.05 # Having a total !=0 gives 5% - partialprogress += 0.95 * \ - (entry.copied / float(entry.total)) + partialprogress += 0.95 * (entry.copied / float(entry.total)) progress += partialprogress / len(self.entries) job.setprogress(progress) @@ -138,12 +138,13 @@ class UnpackOperation: if entry.sourcefs == "squashfs": if shutil.which("unsquashfs") is None: - return ("Failed to unpack image", "Failed to find unsquashfs, make sure you have " - "the squashfs-tools package installed") + return ("Failed to unpack image", + "Failed to find unsquashfs, make sure you have " + "the squashfs-tools package installed") fslist = subprocess.check_output(["unsquashfs", - "-l", - entry.source]) + "-l", + entry.source]) if entry.sourcefs == "ext4": fslist = subprocess.check_output(["find", imgmountdir, @@ -154,7 +155,7 @@ class UnpackOperation: error_msg = self.unpack_image(entry, imgmountdir) if error_msg: return ("Failed to unpack image {}".format(entry.source), - error_msg) + error_msg) return None finally: shutil.rmtree(source_mount_path) @@ -174,8 +175,8 @@ class UnpackOperation: try: return file_copy(imgmountdir, - entry.destination, - progress_cb) + entry.destination, + progress_cb) finally: subprocess.check_call(["umount", "-l", imgmountdir])