[PEP 8] General Style Part 2
This commit is contained in:
parent
d8df3d7a59
commit
09dc6bb5d7
@ -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))
|
||||
|
@ -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
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
from libcalamares.utils import chroot_call
|
||||
|
||||
|
||||
def run():
|
||||
returnCode = chroot_call(["update-initramfs", "-k", "all", "-u"])
|
||||
if returnCode != 0:
|
||||
|
@ -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"):
|
||||
|
@ -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(
|
||||
|
@ -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])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user