From 97867af2aafbea0189c6736c98986006656a2af8 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Thu, 16 Oct 2014 21:08:18 +0200 Subject: [PATCH] Autopep8 pass on bootloader module. --- src/modules/bootloader/main.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index 493cdad72..d9f35f3a4 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -28,6 +28,7 @@ import subprocess from libcalamares.utils import check_chroot_call + def detect_firmware_type(): # Check for EFI variables support if(os.path.exists("/sys/firmware/efi/efivars")): @@ -35,6 +36,7 @@ def detect_firmware_type(): else: fw_type = 'bios' + def get_uuid(): root_mount_point = libcalamares.globalstorage.value("rootMountPoint") print(root_mount_point) @@ -45,7 +47,8 @@ def get_uuid(): print(partition["uuid"]) return partition["uuid"] return "" - + + def create_conf(uuid, conf_path): distribution = libcalamares.job.configuration["distribution"] lines = [ @@ -57,12 +60,13 @@ def create_conf(uuid, conf_path): 'initrd /initramfs-linux.img\n', 'options root=UUID=%s quiet rw\n' % uuid, ] - + with open(conf_path, 'w') as f: for l in lines: f.write(l) f.close() - + + def create_loader(loader_path): distribution = libcalamares.job.configuration["distribution"] timeout = libcalamares.job.configuration["timeout"] @@ -70,20 +74,24 @@ def create_loader(loader_path): 'timeout %s\n' % timeout, 'default %s\n' % distribution, ] - + with open(loader_path, 'w') as f: for l in lines: f.write(l) f.close() - + + def install_bootloader(boot_loader, fw_type): if fw_type == 'efi': - install_path = libcalamares.globalstorage.value( "rootMountPoint" ) + install_path = libcalamares.globalstorage.value("rootMountPoint") uuid = get_uuid() distribution = libcalamares.job.configuration["distribution"] - conf_path = os.path.join(install_path, "boot", "loader", "entries", "%s.conf" % distribution) - loader_path = os.path.join(install_path, "boot", "loader", "loader.conf") - subprocess.call(["gummiboot", "--path=%s/boot" % install_path, "install"]) + conf_path = os.path.join( + install_path, "boot", "loader", "entries", "%s.conf" % distribution) + loader_path = os.path.join( + install_path, "boot", "loader", "loader.conf") + subprocess.call( + ["gummiboot", "--path=%s/boot" % install_path, "install"]) create_conf(uuid, conf_path) create_loader(loader_path) else: @@ -91,6 +99,7 @@ def install_bootloader(boot_loader, fw_type): check_chroot_call(["grub-install", install_path]) check_chroot_call(["grub-mkconfig", "-o", "/boot/grub/grub.cfg"]) + def run(): detect_firmware_type() boot_loader = libcalamares.globalstorage.value("bootLoader")