From 113d9db7cb2a6c0579fa75f8709ae9c59196aa4f Mon Sep 17 00:00:00 2001 From: Gormogon Date: Fri, 20 Feb 2015 14:54:25 -0500 Subject: [PATCH 01/17] Python Better Docstrings --- src/modules/bootloader/main.py | 44 ++++++++++++++++++++++++ src/modules/displaymanager/main.py | 35 ++++++++++++++----- src/modules/dracut/main.py | 10 ++++++ src/modules/dummypython/main.py | 5 +++ src/modules/fstab/main.py | 55 +++++++++++++++++++++++++++++- src/modules/grubcfg/main.py | 12 +++++++ src/modules/initcpio/main.py | 9 +++++ src/modules/initcpiocfg/main.py | 20 ++++++++--- src/modules/initramfs/main.py | 5 +++ src/modules/machineid/main.py | 5 +++ src/modules/mount/main.py | 10 ++++++ src/modules/packages/main.py | 22 ++++++++++++ src/modules/testmodule.py | 16 +++++++++ src/modules/umount/main.py | 10 ++++++ src/modules/unpackfs/main.py | 52 ++++++++++++++++++++++++++++ 15 files changed, 297 insertions(+), 13 deletions(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index 15a1b0364..033dae8c2 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -32,6 +32,11 @@ from libcalamares.utils import check_chroot_call def get_uuid(): + """ + + + :return: + """ root_mount_point = libcalamares.globalstorage.value("rootMountPoint") print("Root mount point: \"{!s}\"".format(root_mount_point)) partitions = libcalamares.globalstorage.value("partitions") @@ -44,6 +49,11 @@ def get_uuid(): def get_bootloader_entry_name(): + """ + + + :return: + """ if "bootloaderEntryName" in libcalamares.job.configuration: return libcalamares.job.configuration["bootloaderEntryName"] else: @@ -52,6 +62,11 @@ def get_bootloader_entry_name(): def get_kernel_line(kernel_type): + """ + + :param kernel_type: + :return: + """ if kernel_type == "fallback": if "fallbackKernelLine" in libcalamares.job.configuration: return libcalamares.job.configuration["fallbackKernelLine"] @@ -65,6 +80,12 @@ def get_kernel_line(kernel_type): def create_conf(uuid, conf_path, kernel_line): + """ + + :param uuid: + :param conf_path: + :param kernel_line: + """ distribution = get_bootloader_entry_name() kernel = libcalamares.job.configuration["kernel"] img = libcalamares.job.configuration["img"] @@ -91,6 +112,10 @@ def create_conf(uuid, conf_path, kernel_line): def create_loader(loader_path): + """ + + :param loader_path: + """ distribution = get_bootloader_entry_name() timeout = libcalamares.job.configuration["timeout"] file_name_sanitizer = str.maketrans(" /", "_-") @@ -107,6 +132,10 @@ def create_loader(loader_path): def install_gummiboot(efi_directory): + """ + + :param efi_directory: + """ print("Bootloader: gummiboot") install_path = libcalamares.globalstorage.value("rootMountPoint") install_efi_directory = install_path + efi_directory @@ -134,6 +163,11 @@ def install_gummiboot(efi_directory): def install_grub(efi_directory, fw_type): + """ + + :param efi_directory: + :param fw_type: + """ if fw_type == "efi": print("Bootloader: grub (efi)") efi_directory_firmware = efi_directory + "/EFI" @@ -166,6 +200,11 @@ def install_grub(efi_directory, fw_type): def prepare_bootloader(fw_type): + """ + + :param fw_type: + :return: + """ efi_boot_loader = libcalamares.job.configuration["efiBootLoader"] efi_directory = libcalamares.globalstorage.value("efiSystemPartition") if fw_type == "efi": @@ -194,6 +233,11 @@ def prepare_bootloader(fw_type): def run(): + """ + + + :return: + """ fw_type = libcalamares.globalstorage.value("firmwareType") prepare_bootloader(fw_type) return None diff --git a/src/modules/displaymanager/main.py b/src/modules/displaymanager/main.py index 3498f3db6..aa8cb2b2e 100644 --- a/src/modules/displaymanager/main.py +++ b/src/modules/displaymanager/main.py @@ -44,6 +44,11 @@ desktop_environments = [ def find_desktop_environment(root_mount_point): + """ + + :param root_mount_point: + :return: + """ for desktop_environment in desktop_environments: if os.path.exists( "{!s}{!s}".format(root_mount_point, desktop_environment.executable)) \ @@ -54,6 +59,12 @@ def find_desktop_environment(root_mount_point): def have_dm(dm_name, root_mount_point): + """ + + :param dm_name: + :param root_mount_point: + :return: + """ return os.path.exists( "{!s}/usr/bin/{!s}".format(root_mount_point, dm_name)) or os.path.exists( "{!s}/usr/sbin/{!s}".format(root_mount_point, dm_name)) @@ -61,8 +72,14 @@ def have_dm(dm_name, root_mount_point): def set_autologin(username, displaymanagers, default_desktop_environment, root_mount_point): - """ Enables automatic login for the installed desktop managers """ - + """ + Enables automatic login for the installed desktop managers. + + :param username: + :param displaymanagers: + :param default_desktop_environment: + :param root_mount_point: + """ if "mdm" in displaymanagers: # Systems with MDM as Desktop Manager mdm_conf_path = os.path.join(root_mount_point, "etc/mdm/custom.conf") @@ -206,12 +223,14 @@ def set_autologin(username, displaymanagers, default_desktop_environment, def run(): - """ Configure display managers """ - # We acquire a list of displaymanagers, either from config or (overridden) from globalstorage. - # This module will try to set up (including autologin) all the displaymanagers in the list, in that specific order. - # Most distros will probably only ship one displaymanager. - # If a displaymanager is in the list but not installed, a debugging message is printed and the entry ignored. - + """ + Configure display managers. + + We acquire a list of displaymanagers, either from config or (overridden) from globalstorage. + This module will try to set up (including autologin) all the displaymanagers in the list, in that specific order. + Most distros will probably only ship one displaymanager. + If a displaymanager is in the list but not installed, a debugging message is printed and the entry ignored. + """ if "displaymanagers" in libcalamares.job.configuration: displaymanagers = libcalamares.job.configuration["displaymanagers"] diff --git a/src/modules/dracut/main.py b/src/modules/dracut/main.py index 8b72e4cc5..9935b55bc 100644 --- a/src/modules/dracut/main.py +++ b/src/modules/dracut/main.py @@ -24,10 +24,20 @@ from libcalamares.utils import chroot_call def run_dracut(): + """ + + + :return: + """ return chroot_call(['dracut', '-f']) def run(): + """ + + + :return: + """ returnCode = run_dracut() if returnCode != 0: return ("Failed to run dracut on the target", "The exit code was {}".format(returnCode)) \ No newline at end of file diff --git a/src/modules/dummypython/main.py b/src/modules/dummypython/main.py index 405a0b0df..09e32e441 100644 --- a/src/modules/dummypython/main.py +++ b/src/modules/dummypython/main.py @@ -24,6 +24,11 @@ from time import gmtime, strftime def run(): + """ + + + :return: + """ os.system("/bin/sh -c \"touch ~/calamares-dummypython\"") accumulator = strftime("%Y-%m-%d %H:%M:%S", gmtime()) + "\n" accumulator += "Calamares version: " + libcalamares.VERSION_SHORT + "\n" diff --git a/src/modules/fstab/main.py b/src/modules/fstab/main.py index 336b354f4..03cfe959e 100644 --- a/src/modules/fstab/main.py +++ b/src/modules/fstab/main.py @@ -41,11 +41,20 @@ FS_MAP = { def mkdir_p(path): + """ + + :param path: + """ if not os.path.exists(path): os.makedirs(path) def is_ssd_disk(disk_name): + """ + + :param disk_name: + :return: + """ filename = os.path.join("/sys/block", disk_name, "queue/rotational") if not os.path.exists(filename): # Should not happen unless sysfs changes, but better safe than sorry @@ -55,11 +64,24 @@ def is_ssd_disk(disk_name): def disk_name_for_partition(partition): + """ + + :param partition: + :return: + """ name = os.path.basename(partition["device"]) return re.sub("[0-9]+$", "", name) class FstabGenerator(object): + """ + + :param partitions: + :param root_mount_point: + :param mount_options: + :param ssd_extra_mount_options: + """ + def __init__(self, partitions, root_mount_point, mount_options, ssd_extra_mount_options): self.partitions = partitions @@ -70,17 +92,29 @@ class FstabGenerator(object): self.root_is_ssd = False def run(self): + """ + + + :return: + """ self.find_ssd_disks() self.generate_fstab() self.create_mount_points() return None def find_ssd_disks(self): + """ + + + """ disks = {disk_name_for_partition(x) for x in self.partitions} self.ssd_disks = {x for x in disks if is_ssd_disk(x)} def generate_fstab(self): - # Create fstab + """ + Create fstab. + + """ mkdir_p(os.path.join(self.root_mount_point, "etc")) fstab_path = os.path.join(self.root_mount_point, "etc", "fstab") with open(fstab_path, "w") as fl: @@ -102,6 +136,11 @@ class FstabGenerator(object): self.print_fstab_line(dct, file=fl) def generate_fstab_line_info(self, partition): + """ + + :param partition: + :return: + """ fs = partition["fs"] mount_point = partition["mountPoint"] disk_name = disk_name_for_partition(partition) @@ -136,6 +175,11 @@ class FstabGenerator(object): check=check) def print_fstab_line(self, dct, file=None): + """ + + :param dct: + :param file: + """ line = "{:41} {:<14} {:<7} {:<10} 0 {}".format( dct["device"], dct["mount_point"], @@ -145,12 +189,21 @@ class FstabGenerator(object): print(line, file=file) def create_mount_points(self): + """ + + + """ for partition in self.partitions: if partition["mountPoint"]: mkdir_p(self.root_mount_point + partition["mountPoint"]) def run(): + """ + + + :return: + """ gs = libcalamares.globalstorage conf = libcalamares.job.configuration partitions = gs.value("partitions") diff --git a/src/modules/grubcfg/main.py b/src/modules/grubcfg/main.py index c2e4c021f..ed6c784a1 100644 --- a/src/modules/grubcfg/main.py +++ b/src/modules/grubcfg/main.py @@ -23,6 +23,13 @@ import os def modify_grub_default(partitions, root_mount_point, distributor): + """ + + :param partitions: + :param root_mount_point: + :param distributor: + :return: + """ default_dir = os.path.join(root_mount_point, "etc/default") default_grub = os.path.join(default_dir, "grub") distributor_replace = distributor.replace("'", "'\\''") @@ -95,6 +102,11 @@ def modify_grub_default(partitions, root_mount_point, distributor): def run(): + """ + + + :return: + """ partitions = libcalamares.globalstorage.value("partitions") root_mount_point = libcalamares.globalstorage.value("rootMountPoint") branding = libcalamares.globalstorage.value("branding") diff --git a/src/modules/initcpio/main.py b/src/modules/initcpio/main.py index 1a264f9d1..caeb8b078 100644 --- a/src/modules/initcpio/main.py +++ b/src/modules/initcpio/main.py @@ -23,10 +23,19 @@ from libcalamares.utils import check_chroot_call def run_mkinitcpio(): + """ + + + """ kernel = libcalamares.job.configuration['kernel'] check_chroot_call(['mkinitcpio', '-p', kernel]) def run(): + """ + + + :return: + """ run_mkinitcpio() return None diff --git a/src/modules/initcpiocfg/main.py b/src/modules/initcpiocfg/main.py index 059ea8a67..6689cc940 100644 --- a/src/modules/initcpiocfg/main.py +++ b/src/modules/initcpiocfg/main.py @@ -30,9 +30,7 @@ def cpuinfo(): Return the information in /proc/cpuinfo as a dictionary in the following format: cpu_info['proc0']={...} cpu_info['proc1']={...} - """ - cpuinfo = OrderedDict() procinfo = OrderedDict() @@ -55,8 +53,13 @@ def cpuinfo(): def set_mkinitcpio_hooks_and_modules(hooks, modules, root_mount_point): - """ Set up mkinitcpio.conf """ + """ + Set up mkinitcpio.conf. + :param hooks: + :param modules: + :param root_mount_point: + """ with open("/etc/mkinitcpio.conf", "r") as mkinitcpio_file: mklins = [x.strip() for x in mkinitcpio_file.readlines()] @@ -74,8 +77,12 @@ def set_mkinitcpio_hooks_and_modules(hooks, modules, root_mount_point): def modify_mkinitcpio_conf(partitions, root_mount_point): - """ Modifies mkinitcpio.conf """ + """ + Modifies mkinitcpio.conf + :param partitions: + :param root_mount_point: + """ cpu = cpuinfo() swap_uuid = "" btrfs = "" @@ -109,6 +116,11 @@ def modify_mkinitcpio_conf(partitions, root_mount_point): def run(): + """ + + + :return: + """ partitions = libcalamares.globalstorage.value("partitions") root_mount_point = libcalamares.globalstorage.value("rootMountPoint") modify_mkinitcpio_conf(partitions, root_mount_point) diff --git a/src/modules/initramfs/main.py b/src/modules/initramfs/main.py index cc401312d..16394477a 100644 --- a/src/modules/initramfs/main.py +++ b/src/modules/initramfs/main.py @@ -22,6 +22,11 @@ from libcalamares.utils import chroot_call def run(): + """ + + + :return: + """ returnCode = chroot_call(["update-initramfs", "-k", "all", "-u"]) if returnCode != 0: return ("Failed to run update-initramfs on the target", "The exit code was {}".format(returnCode)) diff --git a/src/modules/machineid/main.py b/src/modules/machineid/main.py index 674421687..158f729b3 100644 --- a/src/modules/machineid/main.py +++ b/src/modules/machineid/main.py @@ -24,6 +24,11 @@ from libcalamares.utils import check_chroot_call def run(): + """ + + + :return: + """ root_mount_point = libcalamares.globalstorage.value("rootMountPoint") enable_systemd = libcalamares.job.configuration["systemd"] enable_dbus = libcalamares.job.configuration["dbus"] diff --git a/src/modules/mount/main.py b/src/modules/mount/main.py index 47685ee46..47804729f 100644 --- a/src/modules/mount/main.py +++ b/src/modules/mount/main.py @@ -24,6 +24,11 @@ import libcalamares def mount_partitions(root_mount_point, partitions): + """ + + :param root_mount_point: + :param partitions: + """ for partition in partitions: if not partition["mountPoint"]: continue @@ -44,6 +49,11 @@ def mount_partitions(root_mount_point, partitions): def run(): + """ + + + :return: + """ root_mount_point = tempfile.mkdtemp(prefix="calamares-root-") partitions = libcalamares.globalstorage.value("partitions") extra_mounts = libcalamares.job.configuration["extraMounts"] diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index cecbd6a1c..bd2b2360d 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -23,10 +23,18 @@ from libcalamares.utils import check_chroot_call, chroot_call class PackageManager: + """ + + :param backend: + """ def __init__(self, backend): self.backend = backend def install(self, pkgs): + """ + + :param pkgs: + """ if self.backend == "packagekit": for pkg in pkgs: check_chroot_call(["pkcon", "-py", "install", pkg]) @@ -48,6 +56,10 @@ class PackageManager: check_chroot_call(["pacman", "-Sy", "--noconfirm"] + pkgs) def remove(self, pkgs): + """ + + :param pkgs: + """ if self.backend == "packagekit": for pkg in pkgs: check_chroot_call(["pkcon", "-py", "remove", pkg]) @@ -68,6 +80,11 @@ class PackageManager: def run_operations(pkgman, entry): + """ + + :param pkgman: + :param entry: + """ for key in entry.keys(): if key == "install": pkgman.install(entry[key]) @@ -76,6 +93,11 @@ def run_operations(pkgman, entry): def run(): + """ + + + :return: + """ backend = libcalamares.job.configuration.get("backend") if backend not in ("packagekit", "zypp", "yum", "dnf", "urpmi", "apt", "pacman"): return ("Bad backend", "backend=\"{}\"".format(backend)) diff --git a/src/modules/testmodule.py b/src/modules/testmodule.py index 9c6c9ce41..a2d7130dd 100755 --- a/src/modules/testmodule.py +++ b/src/modules/testmodule.py @@ -35,6 +35,13 @@ except ImportError: class Job: + """ + + :param working_path: + :param doc: + :param cfg_doc: + """ + def __init__(self, working_path, doc, cfg_doc): self.module_name = doc["name"] self.pretty_name = "Testing job " + doc["name"] @@ -42,10 +49,19 @@ class Job: self.configuration = cfg_doc def setprogress(self, progress): + """ + + :param progress: + """ print("Job set progress to {}%.".format(progress * 100)) def main(): + """ + + + :return: + """ parser = argparse.ArgumentParser() parser.add_argument("moduledir", help="Dir containing the Python module.") diff --git a/src/modules/umount/main.py b/src/modules/umount/main.py index 5fcc63dda..06b33a245 100644 --- a/src/modules/umount/main.py +++ b/src/modules/umount/main.py @@ -25,6 +25,11 @@ import libcalamares def list_mounts(root_mount_point): + """ + + :param root_mount_point: + :return: + """ lst = [] for line in open("/etc/mtab").readlines(): device, mount_point, _ = line.split(" ", 2) @@ -34,6 +39,11 @@ def list_mounts(root_mount_point): def run(): + """ + + + :return: + """ root_mount_point = libcalamares.globalstorage.value("rootMountPoint") if not root_mount_point: return ("No mount point for root partition in globalstorage", diff --git a/src/modules/unpackfs/main.py b/src/modules/unpackfs/main.py index 91f947c3a..90daa0389 100644 --- a/src/modules/unpackfs/main.py +++ b/src/modules/unpackfs/main.py @@ -32,6 +32,12 @@ from libcalamares import * class UnpackEntry: + """ + + :param source: + :param sourcefs: + :param destination: + """ __slots__ = ['source', 'sourcefs', 'destination', 'copied', 'total'] def __init__(self, source, sourcefs, destination): @@ -46,6 +52,11 @@ ON_POSIX = 'posix' in sys.builtin_module_names def list_excludes(destination): + """ + + :param destination: + :return: + """ lst = [] extra_mounts = globalstorage.value("extraMounts") for extra_mount in extra_mounts: @@ -56,6 +67,13 @@ def list_excludes(destination): def file_copy(source, dest, progress_cb): + """ + + :param source: + :param dest: + :param progress_cb: + :return: + """ # Environment used for executing rsync properly # Setting locale to C (fix issue with tr_TR locale) at_env = os.environ @@ -106,11 +124,19 @@ def file_copy(source, dest, progress_cb): class UnpackOperation: + """ + + :param entries: + """ def __init__(self, entries): self.entries = entries self.entry_for_source = dict((x.source, x) for x in self.entries) def report_progress(self): + """ + + + """ progress = float(0) for entry in self.entries: if entry.total == 0: @@ -124,6 +150,11 @@ class UnpackOperation: job.setprogress(progress) def run(self): + """ + + + :return: + """ source_mount_path = tempfile.mkdtemp() try: for entry in self.entries: @@ -161,6 +192,11 @@ class UnpackOperation: shutil.rmtree(source_mount_path) def mount_image(self, entry, imgmountdir): + """ + + :param entry: + :param imgmountdir: + """ subprocess.check_call(["mount", entry.source, imgmountdir, @@ -169,7 +205,18 @@ class UnpackOperation: "-o", "loop"]) def unpack_image(self, entry, imgmountdir): + """ + + :param entry: + :param imgmountdir: + :return: + """ + def progress_cb(copied): + """ + + :param copied: + """ entry.copied = copied self.report_progress() @@ -196,6 +243,11 @@ def run(): # sourcefs: "squashfs" # destination: "" + """ + + + :return: + """ PATH_PROCFS = '/proc/filesystems' root_mount_point = globalstorage.value("rootMountPoint") From b4db9fe64b2a79a47116fa585ae3ffbac3c85d8f Mon Sep 17 00:00:00 2001 From: Gormogon Date: Fri, 20 Feb 2015 16:18:21 -0500 Subject: [PATCH 02/17] =?UTF-8?q?Fixing=20PEP=20=E2=80=93=20257=20Violatio?= =?UTF-8?q?ns?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/displaymanager/main.py | 5 ++--- src/modules/fstab/main.py | 5 +---- src/modules/initcpiocfg/main.py | 6 ++---- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/modules/displaymanager/main.py b/src/modules/displaymanager/main.py index aa8cb2b2e..3d25b8368 100644 --- a/src/modules/displaymanager/main.py +++ b/src/modules/displaymanager/main.py @@ -223,9 +223,8 @@ def set_autologin(username, displaymanagers, default_desktop_environment, def run(): - """ - Configure display managers. - + """Configure display managers. + We acquire a list of displaymanagers, either from config or (overridden) from globalstorage. This module will try to set up (including autologin) all the displaymanagers in the list, in that specific order. Most distros will probably only ship one displaymanager. diff --git a/src/modules/fstab/main.py b/src/modules/fstab/main.py index 03cfe959e..d49abbe8a 100644 --- a/src/modules/fstab/main.py +++ b/src/modules/fstab/main.py @@ -111,10 +111,7 @@ class FstabGenerator(object): self.ssd_disks = {x for x in disks if is_ssd_disk(x)} def generate_fstab(self): - """ - Create fstab. - - """ + """ Create fstab. """ mkdir_p(os.path.join(self.root_mount_point, "etc")) fstab_path = os.path.join(self.root_mount_point, "etc", "fstab") with open(fstab_path, "w") as fl: diff --git a/src/modules/initcpiocfg/main.py b/src/modules/initcpiocfg/main.py index 6689cc940..7b7a32394 100644 --- a/src/modules/initcpiocfg/main.py +++ b/src/modules/initcpiocfg/main.py @@ -53,8 +53,7 @@ def cpuinfo(): def set_mkinitcpio_hooks_and_modules(hooks, modules, root_mount_point): - """ - Set up mkinitcpio.conf. + """ Set up mkinitcpio.conf. :param hooks: :param modules: @@ -77,8 +76,7 @@ def set_mkinitcpio_hooks_and_modules(hooks, modules, root_mount_point): def modify_mkinitcpio_conf(partitions, root_mount_point): - """ - Modifies mkinitcpio.conf + """ Modifies mkinitcpio.conf :param partitions: :param root_mount_point: From 0d8bdc6c4eb64e9b1992f22ba49250872506aa9b Mon Sep 17 00:00:00 2001 From: Philip Date: Sat, 21 Feb 2015 09:51:51 +0100 Subject: [PATCH 03/17] [bootloader] add python doc strings --- src/modules/bootloader/main.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index 033dae8c2..edfd933e6 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -33,7 +33,7 @@ from libcalamares.utils import check_chroot_call def get_uuid(): """ - + Checks and passes 'uuid' to other routine. :return: """ @@ -50,7 +50,7 @@ def get_uuid(): def get_bootloader_entry_name(): """ - + Passes 'bootloader_entry_name' to other routine based on configuration file. :return: """ @@ -63,6 +63,7 @@ def get_bootloader_entry_name(): def get_kernel_line(kernel_type): """ + Passes 'kernel_line' to other routine based on configuration file. :param kernel_type: :return: @@ -81,6 +82,7 @@ def get_kernel_line(kernel_type): def create_conf(uuid, conf_path, kernel_line): """ + Creates gummiboot configuration files based on given parameters. :param uuid: :param conf_path: @@ -113,6 +115,7 @@ def create_conf(uuid, conf_path, kernel_line): def create_loader(loader_path): """ + Writes configuration for loader. :param loader_path: """ @@ -133,6 +136,7 @@ def create_loader(loader_path): def install_gummiboot(efi_directory): """ + Installs gummiboot as bootloader for EFI setups. :param efi_directory: """ @@ -164,6 +168,7 @@ def install_gummiboot(efi_directory): def install_grub(efi_directory, fw_type): """ + Installs grub as bootloader, either in pc or efi mode. :param efi_directory: :param fw_type: @@ -201,6 +206,8 @@ def install_grub(efi_directory, fw_type): def prepare_bootloader(fw_type): """ + Prepares bootloader and set proper flags to EFI boot partition (esp,boot). + Based on value 'efi_boot_loader', it either calls gummiboot or grub to be installed. :param fw_type: :return: @@ -234,7 +241,7 @@ def prepare_bootloader(fw_type): def run(): """ - + Starts procedure and passes 'fw_type' to other routine. :return: """ From 60927b9363f05ebd7d5f226dc13dcd6bc5e891a1 Mon Sep 17 00:00:00 2001 From: Philip Date: Sat, 21 Feb 2015 09:57:23 +0100 Subject: [PATCH 04/17] [displaymanager] add more python doc strings --- src/modules/displaymanager/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/displaymanager/main.py b/src/modules/displaymanager/main.py index 3d25b8368..644417d81 100644 --- a/src/modules/displaymanager/main.py +++ b/src/modules/displaymanager/main.py @@ -3,7 +3,7 @@ # # === This file is part of Calamares - === # -# Copyright 2014 - 2015, Philip Müller +# Copyright 2014-2015, Philip Müller # Copyright 2014, Teo Mrnjavac # Copyright 2014, Kevin Kofler # @@ -45,6 +45,7 @@ desktop_environments = [ def find_desktop_environment(root_mount_point): """ + Checks which desktop environment is currently installed. :param root_mount_point: :return: @@ -60,6 +61,7 @@ def find_desktop_environment(root_mount_point): def have_dm(dm_name, root_mount_point): """ + Checks if display manager is properly installed. :param dm_name: :param root_mount_point: From 3330df99f382f9ebdb6b6fec244e372ee9988e5f Mon Sep 17 00:00:00 2001 From: Philip Date: Sat, 21 Feb 2015 10:01:38 +0100 Subject: [PATCH 05/17] [dracut] add python doc strings --- src/modules/dracut/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/dracut/main.py b/src/modules/dracut/main.py index 9935b55bc..5d7b175e9 100644 --- a/src/modules/dracut/main.py +++ b/src/modules/dracut/main.py @@ -3,7 +3,7 @@ # # === This file is part of Calamares - === # -# Copyright 2014, Philip Müller +# Copyright 2014-2015, Philip Müller # Copyright 2014, Teo Mrnjavac # # Calamares is free software: you can redistribute it and/or modify @@ -25,7 +25,7 @@ from libcalamares.utils import chroot_call def run_dracut(): """ - + Creates initramfs, even when initramfs already exists. :return: """ @@ -34,10 +34,10 @@ def run_dracut(): def run(): """ - + Starts routine to create initramfs. It passes back the exit code if it fails. :return: """ returnCode = run_dracut() if returnCode != 0: - return ("Failed to run dracut on the target", "The exit code was {}".format(returnCode)) \ No newline at end of file + return ("Failed to run dracut on the target", "The exit code was {}".format(returnCode)) From e7a67b9c5264c4c8e327852b8be88f1651a2e2f1 Mon Sep 17 00:00:00 2001 From: Philip Date: Sat, 21 Feb 2015 10:09:01 +0100 Subject: [PATCH 06/17] [dummypython] add python doc strings --- src/modules/bootloader/main.py | 27 +++++++++------------------ src/modules/displaymanager/main.py | 9 +++------ src/modules/dracut/main.py | 6 ++---- src/modules/dummypython/main.py | 6 +++++- 4 files changed, 19 insertions(+), 29 deletions(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index edfd933e6..0fdd889c3 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -32,8 +32,7 @@ from libcalamares.utils import check_chroot_call def get_uuid(): - """ - Checks and passes 'uuid' to other routine. + """ Checks and passes 'uuid' to other routine. :return: """ @@ -49,8 +48,7 @@ def get_uuid(): def get_bootloader_entry_name(): - """ - Passes 'bootloader_entry_name' to other routine based on configuration file. + """ Passes 'bootloader_entry_name' to other routine based on configuration file. :return: """ @@ -62,8 +60,7 @@ def get_bootloader_entry_name(): def get_kernel_line(kernel_type): - """ - Passes 'kernel_line' to other routine based on configuration file. + """ Passes 'kernel_line' to other routine based on configuration file. :param kernel_type: :return: @@ -81,8 +78,7 @@ def get_kernel_line(kernel_type): def create_conf(uuid, conf_path, kernel_line): - """ - Creates gummiboot configuration files based on given parameters. + """ Creates gummiboot configuration files based on given parameters. :param uuid: :param conf_path: @@ -114,8 +110,7 @@ def create_conf(uuid, conf_path, kernel_line): def create_loader(loader_path): - """ - Writes configuration for loader. + """ Writes configuration for loader. :param loader_path: """ @@ -135,8 +130,7 @@ def create_loader(loader_path): def install_gummiboot(efi_directory): - """ - Installs gummiboot as bootloader for EFI setups. + """ Installs gummiboot as bootloader for EFI setups. :param efi_directory: """ @@ -167,8 +161,7 @@ def install_gummiboot(efi_directory): def install_grub(efi_directory, fw_type): - """ - Installs grub as bootloader, either in pc or efi mode. + """ Installs grub as bootloader, either in pc or efi mode. :param efi_directory: :param fw_type: @@ -205,8 +198,7 @@ def install_grub(efi_directory, fw_type): def prepare_bootloader(fw_type): - """ - Prepares bootloader and set proper flags to EFI boot partition (esp,boot). + """ Prepares bootloader and set proper flags to EFI boot partition (esp,boot). Based on value 'efi_boot_loader', it either calls gummiboot or grub to be installed. :param fw_type: @@ -240,8 +232,7 @@ def prepare_bootloader(fw_type): def run(): - """ - Starts procedure and passes 'fw_type' to other routine. + """ Starts procedure and passes 'fw_type' to other routine. :return: """ diff --git a/src/modules/displaymanager/main.py b/src/modules/displaymanager/main.py index 644417d81..30404977d 100644 --- a/src/modules/displaymanager/main.py +++ b/src/modules/displaymanager/main.py @@ -44,8 +44,7 @@ desktop_environments = [ def find_desktop_environment(root_mount_point): - """ - Checks which desktop environment is currently installed. + """ Checks which desktop environment is currently installed. :param root_mount_point: :return: @@ -60,8 +59,7 @@ def find_desktop_environment(root_mount_point): def have_dm(dm_name, root_mount_point): - """ - Checks if display manager is properly installed. + """ Checks if display manager is properly installed. :param dm_name: :param root_mount_point: @@ -74,8 +72,7 @@ def have_dm(dm_name, root_mount_point): def set_autologin(username, displaymanagers, default_desktop_environment, root_mount_point): - """ - Enables automatic login for the installed desktop managers. + """ Enables automatic login for the installed desktop managers. :param username: :param displaymanagers: diff --git a/src/modules/dracut/main.py b/src/modules/dracut/main.py index 5d7b175e9..75fa8e3ad 100644 --- a/src/modules/dracut/main.py +++ b/src/modules/dracut/main.py @@ -24,8 +24,7 @@ from libcalamares.utils import chroot_call def run_dracut(): - """ - Creates initramfs, even when initramfs already exists. + """ Creates initramfs, even when initramfs already exists. :return: """ @@ -33,8 +32,7 @@ def run_dracut(): def run(): - """ - Starts routine to create initramfs. It passes back the exit code if it fails. + """ Starts routine to create initramfs. It passes back the exit code if it fails. :return: """ diff --git a/src/modules/dummypython/main.py b/src/modules/dummypython/main.py index 09e32e441..b7be37317 100644 --- a/src/modules/dummypython/main.py +++ b/src/modules/dummypython/main.py @@ -24,8 +24,12 @@ from time import gmtime, strftime def run(): - """ + """ Example Python jobmodule. + A Python jobmodule is a Python program which imports libcalamares and + has a function run() as entry point. run() must return None if everything + went well, or a tuple (str,str) with an error message and description + if something went wrong. :return: """ From 3d8ba2b088f48acae104b94089a4458466b874cc Mon Sep 17 00:00:00 2001 From: Philip Date: Sat, 21 Feb 2015 10:18:46 +0100 Subject: [PATCH 07/17] [fstab] add python doc strings --- src/modules/displaymanager/main.py | 2 +- src/modules/fstab/main.py | 28 ++++++++++------------------ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/modules/displaymanager/main.py b/src/modules/displaymanager/main.py index 30404977d..b9aa007be 100644 --- a/src/modules/displaymanager/main.py +++ b/src/modules/displaymanager/main.py @@ -222,7 +222,7 @@ def set_autologin(username, displaymanagers, default_desktop_environment, def run(): - """Configure display managers. + """ Configure display managers. We acquire a list of displaymanagers, either from config or (overridden) from globalstorage. This module will try to set up (including autologin) all the displaymanagers in the list, in that specific order. diff --git a/src/modules/fstab/main.py b/src/modules/fstab/main.py index d49abbe8a..5795e5b14 100644 --- a/src/modules/fstab/main.py +++ b/src/modules/fstab/main.py @@ -41,7 +41,7 @@ FS_MAP = { def mkdir_p(path): - """ + """ Create directory. :param path: """ @@ -50,7 +50,7 @@ def mkdir_p(path): def is_ssd_disk(disk_name): - """ + """ Checks if given disk is actually a ssd disk. :param disk_name: :return: @@ -64,7 +64,7 @@ def is_ssd_disk(disk_name): def disk_name_for_partition(partition): - """ + """ Returns disk name for each found partition. :param partition: :return: @@ -74,7 +74,7 @@ def disk_name_for_partition(partition): class FstabGenerator(object): - """ + """ Class header :param partitions: :param root_mount_point: @@ -92,8 +92,7 @@ class FstabGenerator(object): self.root_is_ssd = False def run(self): - """ - + """ Calls needed sub routines. :return: """ @@ -103,10 +102,7 @@ class FstabGenerator(object): return None def find_ssd_disks(self): - """ - - - """ + """ Checks for ssd disks """ disks = {disk_name_for_partition(x) for x in self.partitions} self.ssd_disks = {x for x in disks if is_ssd_disk(x)} @@ -133,7 +129,7 @@ class FstabGenerator(object): self.print_fstab_line(dct, file=fl) def generate_fstab_line_info(self, partition): - """ + """ Generates information for each fstab entry. :param partition: :return: @@ -172,7 +168,7 @@ class FstabGenerator(object): check=check) def print_fstab_line(self, dct, file=None): - """ + """ Prints line to /etc/fstab file. :param dct: :param file: @@ -186,18 +182,14 @@ class FstabGenerator(object): print(line, file=file) def create_mount_points(self): - """ - - - """ + """ Creates mount points """ for partition in self.partitions: if partition["mountPoint"]: mkdir_p(self.root_mount_point + partition["mountPoint"]) def run(): - """ - + """ Configures fstab. :return: """ From 06be842cfacfdc3c01c5bfbadefb2a3310779186 Mon Sep 17 00:00:00 2001 From: Philip Date: Sat, 21 Feb 2015 10:24:13 +0100 Subject: [PATCH 08/17] [grubcfg] add python doc strings --- src/modules/fstab/main.py | 2 +- src/modules/grubcfg/main.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/modules/fstab/main.py b/src/modules/fstab/main.py index 5795e5b14..cfd7d2830 100644 --- a/src/modules/fstab/main.py +++ b/src/modules/fstab/main.py @@ -168,7 +168,7 @@ class FstabGenerator(object): check=check) def print_fstab_line(self, dct, file=None): - """ Prints line to /etc/fstab file. + """ Prints line to '/etc/fstab' file. :param dct: :param file: diff --git a/src/modules/grubcfg/main.py b/src/modules/grubcfg/main.py index ed6c784a1..38afe6d5e 100644 --- a/src/modules/grubcfg/main.py +++ b/src/modules/grubcfg/main.py @@ -3,7 +3,7 @@ # # === This file is part of Calamares - === # -# Copyright 2014 - 2015, Philip Müller +# Copyright 2014-2015, Philip Müller # # Calamares is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ import os def modify_grub_default(partitions, root_mount_point, distributor): - """ + """ Configures '/etc/default/grub' for hibernation and plymouth. :param partitions: :param root_mount_point: @@ -102,8 +102,7 @@ def modify_grub_default(partitions, root_mount_point, distributor): def run(): - """ - + """ Calls routine with given parameters to modify '/etc/default/grub'. :return: """ From 98db0b3f593a5430a50a6b1345af39f76584ef88 Mon Sep 17 00:00:00 2001 From: Philip Date: Sat, 21 Feb 2015 10:26:03 +0100 Subject: [PATCH 09/17] [initcpio] add python doc strings --- src/modules/initcpio/main.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/modules/initcpio/main.py b/src/modules/initcpio/main.py index caeb8b078..db46a4ab2 100644 --- a/src/modules/initcpio/main.py +++ b/src/modules/initcpio/main.py @@ -23,17 +23,13 @@ from libcalamares.utils import check_chroot_call def run_mkinitcpio(): - """ - - - """ + """ Runs mkinitcpio with given kernel profile """ kernel = libcalamares.job.configuration['kernel'] check_chroot_call(['mkinitcpio', '-p', kernel]) def run(): - """ - + """ Calls routine :return: """ From d677fe9d015ffe58ea56578ffb2e3f00ed1cc08d Mon Sep 17 00:00:00 2001 From: Philip Date: Sat, 21 Feb 2015 10:30:13 +0100 Subject: [PATCH 10/17] [initcpiocfg] add python doc strings --- src/modules/initcpio/main.py | 2 +- src/modules/initcpiocfg/main.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/modules/initcpio/main.py b/src/modules/initcpio/main.py index db46a4ab2..fdf163a64 100644 --- a/src/modules/initcpio/main.py +++ b/src/modules/initcpio/main.py @@ -29,7 +29,7 @@ def run_mkinitcpio(): def run(): - """ Calls routine + """ Calls routine to create kernel initramfs image. :return: """ diff --git a/src/modules/initcpiocfg/main.py b/src/modules/initcpiocfg/main.py index 7b7a32394..f3754f696 100644 --- a/src/modules/initcpiocfg/main.py +++ b/src/modules/initcpiocfg/main.py @@ -26,8 +26,8 @@ from libcalamares.utils import check_chroot_call def cpuinfo(): - """ - Return the information in /proc/cpuinfo as a dictionary in the following format: + """ Return the information in /proc/cpuinfo as a dictionary in the following format: + cpu_info['proc0']={...} cpu_info['proc1']={...} """ @@ -114,8 +114,7 @@ def modify_mkinitcpio_conf(partitions, root_mount_point): def run(): - """ - + """ Calls routine with given parameters to modify '/etc/mkinitcpio.conf'. :return: """ From fc88f1a4805a6651db28aad7a5eacaf51003e0b2 Mon Sep 17 00:00:00 2001 From: Philip Date: Sat, 21 Feb 2015 10:32:35 +0100 Subject: [PATCH 11/17] [initramfs] add python doc strings --- src/modules/initramfs/main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/modules/initramfs/main.py b/src/modules/initramfs/main.py index 16394477a..73faa1f9b 100644 --- a/src/modules/initramfs/main.py +++ b/src/modules/initramfs/main.py @@ -22,8 +22,7 @@ from libcalamares.utils import chroot_call def run(): - """ - + """ Generate an initramfs image. :return: """ From d7b36e9ff7ff720d95d2d0b76c263aad66ea0237 Mon Sep 17 00:00:00 2001 From: Philip Date: Sat, 21 Feb 2015 10:35:05 +0100 Subject: [PATCH 12/17] [machineid] add python doc strings --- src/modules/machineid/main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/modules/machineid/main.py b/src/modules/machineid/main.py index 158f729b3..5bd807428 100644 --- a/src/modules/machineid/main.py +++ b/src/modules/machineid/main.py @@ -24,8 +24,7 @@ from libcalamares.utils import check_chroot_call def run(): - """ - + """ Generate machine-id using dbus and systemd. :return: """ From 016dd71db4b1a17c8c92b3256ef3ae596e19f536 Mon Sep 17 00:00:00 2001 From: Philip Date: Sat, 21 Feb 2015 10:37:56 +0100 Subject: [PATCH 13/17] [mount] add python doc strings --- src/modules/mount/main.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/modules/mount/main.py b/src/modules/mount/main.py index 47804729f..5d17b8ba0 100644 --- a/src/modules/mount/main.py +++ b/src/modules/mount/main.py @@ -24,7 +24,7 @@ import libcalamares def mount_partitions(root_mount_point, partitions): - """ + """ Pass back mount point and filesystem for each partition. :param root_mount_point: :param partitions: @@ -49,8 +49,7 @@ def mount_partitions(root_mount_point, partitions): def run(): - """ - + """ Define mountpoints. :return: """ From be2353e54bac5f09af184324d7c641a5d8be4a2c Mon Sep 17 00:00:00 2001 From: Philip Date: Sat, 21 Feb 2015 10:46:01 +0100 Subject: [PATCH 14/17] [packages] add python doc strings --- src/modules/packages/main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index bd2b2360d..62c486c06 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -23,7 +23,7 @@ from libcalamares.utils import check_chroot_call, chroot_call class PackageManager: - """ + """ Package manager class :param backend: """ @@ -31,7 +31,7 @@ class PackageManager: self.backend = backend def install(self, pkgs): - """ + """ Installs packages. :param pkgs: """ @@ -56,7 +56,7 @@ class PackageManager: check_chroot_call(["pacman", "-Sy", "--noconfirm"] + pkgs) def remove(self, pkgs): - """ + """ Removes packages. :param pkgs: """ @@ -80,7 +80,7 @@ class PackageManager: def run_operations(pkgman, entry): - """ + """ Call package manager with given parameters. :param pkgman: :param entry: @@ -93,8 +93,8 @@ def run_operations(pkgman, entry): def run(): - """ - + """ Calls routine with detected package manager to install locale packages + or remove drivers not needed on the installed system. :return: """ From d22e194ee7c2ee48edb210f8830c08b97fad6aa2 Mon Sep 17 00:00:00 2001 From: Philip Date: Sat, 21 Feb 2015 10:49:37 +0100 Subject: [PATCH 15/17] [umount] add python doc strings --- src/modules/umount/main.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/modules/umount/main.py b/src/modules/umount/main.py index 06b33a245..479cfc702 100644 --- a/src/modules/umount/main.py +++ b/src/modules/umount/main.py @@ -25,7 +25,7 @@ import libcalamares def list_mounts(root_mount_point): - """ + """ List mount points. :param root_mount_point: :return: @@ -39,8 +39,7 @@ def list_mounts(root_mount_point): def run(): - """ - + """ Unmounts given mountpoints in decreasing order. :return: """ From 82dc4c38f454e3497c28bbe2349e725e8d2f04aa Mon Sep 17 00:00:00 2001 From: Philip Date: Sat, 21 Feb 2015 11:02:25 +0100 Subject: [PATCH 16/17] [unpackfs] add python doc strings --- src/modules/unpackfs/main.py | 52 ++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/src/modules/unpackfs/main.py b/src/modules/unpackfs/main.py index 90daa0389..4b119dc35 100644 --- a/src/modules/unpackfs/main.py +++ b/src/modules/unpackfs/main.py @@ -32,7 +32,7 @@ from libcalamares import * class UnpackEntry: - """ + """ Extraction routine using rsync. :param source: :param sourcefs: @@ -52,7 +52,7 @@ ON_POSIX = 'posix' in sys.builtin_module_names def list_excludes(destination): - """ + """ List excludes for rsync. :param destination: :return: @@ -67,7 +67,7 @@ def list_excludes(destination): def file_copy(source, dest, progress_cb): - """ + """ Extract given image using rsync. :param source: :param dest: @@ -124,7 +124,7 @@ def file_copy(source, dest, progress_cb): class UnpackOperation: - """ + """ Extraction routine using unsquashfs. :param entries: """ @@ -133,10 +133,7 @@ class UnpackOperation: self.entry_for_source = dict((x.source, x) for x in self.entries) def report_progress(self): - """ - - - """ + """ Pass progress to user interface """ progress = float(0) for entry in self.entries: if entry.total == 0: @@ -150,8 +147,7 @@ class UnpackOperation: job.setprogress(progress) def run(self): - """ - + """ Extract given image using unsquashfs. :return: """ @@ -192,7 +188,7 @@ class UnpackOperation: shutil.rmtree(source_mount_path) def mount_image(self, entry, imgmountdir): - """ + """ Mount given image as loop device. :param entry: :param imgmountdir: @@ -205,7 +201,7 @@ class UnpackOperation: "-o", "loop"]) def unpack_image(self, entry, imgmountdir): - """ + """ Unpacks image. :param entry: :param imgmountdir: @@ -213,7 +209,7 @@ class UnpackOperation: """ def progress_cb(copied): - """ + """ Copies file to given destination target. :param copied: """ @@ -229,22 +225,20 @@ class UnpackOperation: def run(): - # from globalstorage: rootMountPoint - # from job.configuration: - # the path to where to mount the source image(s) for copying - # an ordered list of unpack mappings for image file <-> target dir relative - # to rootMountPoint, e.g.: - # configuration: - # unpack: - # - source: "/path/to/filesystem.img" - # sourcefs: "ext4" - # destination: "" - # - source: "/path/to/another/filesystem.sqfs" - # sourcefs: "squashfs" - # destination: "" - - """ - + """ Unsquashes given filesystem from given image file. + + from globalstorage: rootMountPoint + from job.configuration: the path to where to mount the source image(s) for copying + an ordered list of unpack mappings for image file <-> target dir relative + to rootMountPoint, e.g.: + configuration: + unpack: + - source: "/path/to/filesystem.img" + sourcefs: "ext4" + destination: "" + - source: "/path/to/another/filesystem.sqfs" + sourcefs: "squashfs" + destination: "" :return: """ From e5eee1e4ddcae0d8c5adaccf0a2d33eeed38ff0f Mon Sep 17 00:00:00 2001 From: Philip Date: Sat, 21 Feb 2015 11:24:53 +0100 Subject: [PATCH 17/17] [unpackfs] proper sentence --- src/modules/packages/main.py | 2 +- src/modules/unpackfs/main.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index 62c486c06..028a0ea1a 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -23,7 +23,7 @@ from libcalamares.utils import check_chroot_call, chroot_call class PackageManager: - """ Package manager class + """ Package manager class. :param backend: """ diff --git a/src/modules/unpackfs/main.py b/src/modules/unpackfs/main.py index 4b119dc35..bc43475b6 100644 --- a/src/modules/unpackfs/main.py +++ b/src/modules/unpackfs/main.py @@ -225,7 +225,7 @@ class UnpackOperation: def run(): - """ Unsquashes given filesystem from given image file. + """ Unsquashes filesystem from given image file. from globalstorage: rootMountPoint from job.configuration: the path to where to mount the source image(s) for copying