From 69d675f4aa14b4957d6376d642bec5cf4b96674e Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Sat, 15 May 2021 12:29:57 -0400 Subject: Many more manual changes --- archinstall/lib/services.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'archinstall/lib/services.py') diff --git a/archinstall/lib/services.py b/archinstall/lib/services.py index bb6f64f2..46aa7846 100644 --- a/archinstall/lib/services.py +++ b/archinstall/lib/services.py @@ -1,8 +1,6 @@ -import os - -from .exceptions import * from .general import * + def service_state(service_name: str): if os.path.splitext(service_name)[1] != '.service': service_name += '.service' # Just to be safe -- cgit v1.2.3-70-g09d2 From 3b20adb7d216cbe72bf1770e219207216bee96ee Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Sat, 15 May 2021 13:59:37 -0400 Subject: Whitespace changes --- archinstall/lib/disk.py | 16 ++++++++++------ archinstall/lib/general.py | 2 ++ archinstall/lib/hardware.py | 2 +- archinstall/lib/installer.py | 5 ++--- archinstall/lib/mirrors.py | 2 +- archinstall/lib/profiles.py | 6 +++--- archinstall/lib/services.py | 2 +- docs/pull_request_template.md | 3 +-- examples/guided.py | 12 ++++++------ profiles/gnome.py | 4 ++-- profiles/xorg.py | 4 ++-- 11 files changed, 31 insertions(+), 27 deletions(-) (limited to 'archinstall/lib/services.py') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 2241ac8e..62f1785f 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -152,8 +152,9 @@ class BlockDevice(): def flush_cache(self): self.part_cache = OrderedDict() + class Partition(): - def __init__(self, path :str, block_device :BlockDevice, part_id=None, size=-1, filesystem=None, mountpoint=None, encrypted=False, autodetect_filesystem=True): + def __init__(self, path: str, block_device: BlockDevice, part_id=None, size=-1, filesystem=None, mountpoint=None, encrypted=False, autodetect_filesystem=True): if not part_id: part_id = os.path.basename(path) @@ -506,9 +507,9 @@ class Filesystem(): self.blockdevice.partition[0].allow_formatting = True self.blockdevice.partition[1].allow_formatting = True else: - #we don't need a seprate boot partition it would be a waste of space + # we don't need a seprate boot partition it would be a waste of space self.add_partition('primary', start='1MB', end='100%') - self.blockdevice.partition[0].filesystem=root_filesystem_type + self.blockdevice.partition[0].filesystem = root_filesystem_type log(f"Set the root partition {self.blockdevice.partition[0]} to use filesystem {root_filesystem_type}.", level=logging.DEBUG) self.blockdevice.partition[0].target_mountpoint = '/' self.blockdevice.partition[0].allow_formatting = True @@ -558,28 +559,31 @@ def device_state(name, *args, **kwargs): return return True + # lsblk --json -l -n -o path def all_disks(*args, **kwargs): kwargs.setdefault("partitions", False) drives = OrderedDict() - #for drive in json.loads(sys_command(f'losetup --json', *args, **lkwargs, hide_from_log=True)).decode('UTF_8')['loopdevices']: + # for drive in json.loads(sys_command(f'losetup --json', *args, **lkwargs, hide_from_log=True)).decode('UTF_8')['loopdevices']: for drive in json.loads(b''.join(sys_command(f'lsblk --json -l -n -o path,size,type,mountpoint,label,pkname,model', *args, **kwargs, hide_from_log=True)).decode('UTF_8'))['blockdevices']: if not kwargs['partitions'] and drive['type'] == 'part': continue drives[drive['path']] = BlockDevice(drive['path'], drive) return drives + def convert_to_gigabytes(string): unit = string.strip()[-1] size = float(string.strip()[:-1]) if unit == 'M': - size = size/1024 + size = size / 1024 elif unit == 'T': - size = size*1024 + size = size * 1024 return size + def harddrive(size=None, model=None, fuzzy=False): collection = all_disks() for drive in collection: diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index 9f6de666..f9b9078a 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -83,10 +83,12 @@ class JSON(json.JSONEncoder, json.JSONDecoder): def encode(self, obj): return super(JSON, self).encode(self._encode(obj)) + class sys_command: """ Stolen from archinstall_gui """ + def __init__(self, cmd, callback=None, start_callback=None, peak_output=False, environment_vars={}, *args, **kwargs): kwargs.setdefault("worker_id", gen_uid()) kwargs.setdefault("emulate", False) diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py index 9eaff22e..3203daee 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -108,7 +108,7 @@ def cpuVendor() -> Optional[str]: def isVM() -> bool: try: - subprocess.check_call(["systemd-detect-virt"]) # systemd-detect-virt issues a non-zero exit code if it is not on a virtual machine + subprocess.check_call(["systemd-detect-virt"]) # systemd-detect-virt issues a non-zero exit code if it is not on a virtual machine return True except: return False diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index eccd2c49..cacdff69 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -153,7 +153,7 @@ class Installer(): return True - def set_hostname(self, hostname :str, *args, **kwargs): + def set_hostname(self, hostname: str, *args, **kwargs): with open(f'{self.target}/etc/hostname', 'w') as fh: fh.write(hostname + '\n') @@ -423,7 +423,6 @@ class Installer(): ## blkid doesn't trigger on loopback devices really well, ## so we'll use the old manual method until we get that sorted out. - if (real_device := self.detect_encryption(root_partition)): # TODO: We need to detect if the encrypted device is a whole disk encryption, # or simply a partition encryption. Right now we assume it's a partition (and we always have) @@ -446,7 +445,7 @@ class Installer(): sys_command('/usr/bin/arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg') return True else: - root_device = subprocess.check_output(f'basename "$(readlink -f /sys/class/block/{root_partition.path.replace("/dev/","")}/..)"', shell=True).decode().strip() + root_device = subprocess.check_output(f'basename "$(readlink -f /sys/class/block/{root_partition.path.replace("/dev/", "")}/..)"', shell=True).decode().strip() if root_device == "block": root_device = f"{root_partition.path}" o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.target} grub-install --target=i386-pc /dev/{root_device}')) diff --git a/archinstall/lib/mirrors.py b/archinstall/lib/mirrors.py index e53b356a..4b05b96a 100644 --- a/archinstall/lib/mirrors.py +++ b/archinstall/lib/mirrors.py @@ -22,7 +22,7 @@ def filter_mirrors_by_region(regions, destination='/etc/pacman.d/mirrorlist', tm return True -def add_custom_mirrors(mirrors:list, *args, **kwargs): +def add_custom_mirrors(mirrors: list, *args, **kwargs): """ This will append custom mirror definitions in pacman.conf diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py index 8b5525b4..2f97231c 100644 --- a/archinstall/lib/profiles.py +++ b/archinstall/lib/profiles.py @@ -14,7 +14,7 @@ from .storage import storage def grab_url_data(path): - safe_path = path[:path.find(':')+1]+''.join([item if item in ('/', '?', '=', '&') else urllib.parse.quote(item) for item in multisplit(path[path.find(':')+1:], ('/', '?', '=', '&'))]) + safe_path = path[:path.find(':') + 1] + ''.join([item if item in ('/', '?', '=', '&') else urllib.parse.quote(item) for item in multisplit(path[path.find(':') + 1:], ('/', '?', '=', '&'))]) ssl_context = ssl.create_default_context() ssl_context.check_hostname = False ssl_context.verify_mode = ssl.CERT_NONE @@ -47,7 +47,7 @@ def list_profiles(filter_irrelevant_macs=True, subpath='', filter_top_level_prof if len(first_line) and first_line[0] == '#': description = first_line[1:].strip() - cache[file[:-3]] = {'path' : os.path.join(root, file), 'description' : description, 'tailored' : tailored} + cache[file[:-3]] = {'path': os.path.join(root, file), 'description': description, 'tailored': tailored} break # Grab profiles from upstream URL @@ -70,7 +70,7 @@ def list_profiles(filter_irrelevant_macs=True, subpath='', filter_top_level_prof continue tailored = True - cache[profile[:-3]] = {'path' : os.path.join(storage["UPSTREAM_URL"]+subpath, profile), 'description' : profile_list[profile], 'tailored' : tailored} + cache[profile[:-3]] = {'path': os.path.join(storage["UPSTREAM_URL"] + subpath, profile), 'description': profile_list[profile], 'tailored': tailored} if filter_top_level_profiles: for profile in list(cache.keys()): diff --git a/archinstall/lib/services.py b/archinstall/lib/services.py index 46aa7846..537a2f84 100644 --- a/archinstall/lib/services.py +++ b/archinstall/lib/services.py @@ -5,6 +5,6 @@ def service_state(service_name: str): if os.path.splitext(service_name)[1] != '.service': service_name += '.service' # Just to be safe - state = b''.join(sys_command(f'systemctl show --no-pager -p SubState --value {service_name}', environment_vars={'SYSTEMD_COLORS' : '0'})) + state = b''.join(sys_command(f'systemctl show --no-pager -p SubState --value {service_name}', environment_vars={'SYSTEMD_COLORS': '0'})) return state.strip().decode('UTF-8') diff --git a/docs/pull_request_template.md b/docs/pull_request_template.md index 18d01ab2..1cbcf76a 100644 --- a/docs/pull_request_template.md +++ b/docs/pull_request_template.md @@ -12,5 +12,4 @@ If the PR is larger than ~20 lines, please describe it here unless described in # Testing -Any new feature or stability improvement should be tested if possible. Please follow the test instructions at the bottom -of the README or use the ISO built on each PR. +Any new feature or stability improvement should be tested if possible. Please follow the test instructions at the bottom of the README or use the ISO built on each PR. diff --git a/examples/guided.py b/examples/guided.py index ae5c5f54..ca50f838 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -85,7 +85,7 @@ def ask_user_questions(): # If we provide keys as options, it's better to convert them to list and sort before passing mountpoints_list = sorted(list(partition_mountpoints.keys())) partition = archinstall.generic_select(mountpoints_list, - "Select a partition by number that you want to set a mount-point for (leave blank when done): ") + "Select a partition by number that you want to set a mount-point for (leave blank when done): ") if not partition: if set(mountpoints_set) & {'/', '/boot'} == {'/', '/boot'}: break @@ -316,12 +316,12 @@ def perform_installation(mountpoint): time.sleep(1) # Set mirrors used by pacstrap (outside of installation) if archinstall.arguments.get('mirror-region', None): - archinstall.use_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors for the live medium + archinstall.use_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors for the live medium if installation.minimal_installation(): installation.set_hostname(archinstall.arguments['hostname']) if archinstall.arguments['mirror-region'].get("mirrors", None) is not None: - installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium - if archinstall.arguments["bootloader"]=="grub-install" and hasUEFI()==True: + installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium + if archinstall.arguments["bootloader"] == "grub-install" and hasUEFI() == True: installation.add_additional_packages("grub") installation.set_keyboard_language(archinstall.arguments['keyboard-language']) installation.add_bootloader(archinstall.arguments["bootloader"]) @@ -329,8 +329,8 @@ def perform_installation(mountpoint): # If user selected to copy the current ISO network configuration # Perform a copy of the config if archinstall.arguments.get('nic', {}) == 'Copy ISO network configuration to installation': - installation.copy_ISO_network_config(enable_services=True) # Sources the ISO network configuration to the install medium. - elif archinstall.arguments.get('nic', {}).get('NetworkManager',False): + installation.copy_ISO_network_config(enable_services=True) # Sources the ISO network configuration to the install medium. + elif archinstall.arguments.get('nic', {}).get('NetworkManager', False): installation.add_additional_packages("networkmanager") installation.enable_service('NetworkManager.service') # Otherwise, if a interface was selected, configure that interface diff --git a/profiles/gnome.py b/profiles/gnome.py index 09fac1bb..7bf5b7fd 100644 --- a/profiles/gnome.py +++ b/profiles/gnome.py @@ -37,5 +37,5 @@ if __name__ == 'gnome': archinstall.storage['installation_session'].add_additional_packages(__packages__) archinstall.storage['installation_session'].enable_service('gdm') # Gnome Display Manager - # We could also start it via xinitrc since we do have Xorg, - # but for gnome that's deprecated and wayland is preferred. +# We could also start it via xinitrc since we do have Xorg, +# but for gnome that's deprecated and wayland is preferred. diff --git a/profiles/xorg.py b/profiles/xorg.py index 3351e4e5..e18a4f03 100644 --- a/profiles/xorg.py +++ b/profiles/xorg.py @@ -30,11 +30,11 @@ if __name__ == 'xorg': try: if "nvidia" in _gfx_driver_packages: if "linux-zen" in archinstall.storage['installation_session'].base_packages or "linux-lts" in archinstall.storage['installation_session'].base_packages: - archinstall.storage['installation_session'].add_additional_packages("dkms")#I've had kernel regen fail if it wasn't installed before nvidia-dkms + archinstall.storage['installation_session'].add_additional_packages("dkms") # I've had kernel regen fail if it wasn't installed before nvidia-dkms archinstall.storage['installation_session'].add_additional_packages("xorg-server xorg-xinit nvidia-dkms") else: archinstall.storage['installation_session'].add_additional_packages(f"xorg-server xorg-xinit {' '.join(_gfx_driver_packages)}") else: archinstall.storage['installation_session'].add_additional_packages(f"xorg-server xorg-xinit {' '.join(_gfx_driver_packages)}") except: - archinstall.storage['installation_session'].add_additional_packages("xorg-server xorg-xinit") # Prep didn't run, so there's no driver to install \ No newline at end of file + archinstall.storage['installation_session'].add_additional_packages("xorg-server xorg-xinit") # Prep didn't run, so there's no driver to install -- cgit v1.2.3-70-g09d2 From 1796bbb91885d8a11837b0d50c4b2093e2314352 Mon Sep 17 00:00:00 2001 From: Dylan Taylor Date: Sat, 15 May 2021 17:50:28 -0400 Subject: Perform refactoring to PEP 8 naming conventions --- archinstall/lib/disk.py | 54 ++++++++++++++-------------- archinstall/lib/general.py | 14 ++++---- archinstall/lib/hardware.py | 30 ++++++++-------- archinstall/lib/installer.py | 70 ++++++++++++++++++------------------- archinstall/lib/luks.py | 16 ++++----- archinstall/lib/mirrors.py | 8 ++--- archinstall/lib/networking.py | 6 ++-- archinstall/lib/output.py | 4 +-- archinstall/lib/services.py | 2 +- archinstall/lib/user_interaction.py | 8 ++--- docs/conf.py | 4 +-- examples/guided.py | 10 +++--- examples/minimal.py | 2 +- 13 files changed, 114 insertions(+), 114 deletions(-) (limited to 'archinstall/lib/services.py') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 410bb481..60c264e1 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -5,7 +5,7 @@ from collections import OrderedDict from typing import Optional from .general import * -from .hardware import hasUEFI +from .hardware import has_uefi from .output import log ROOT_DIR_PATTERN = re.compile('^.*?/devices') @@ -77,7 +77,7 @@ class BlockDevice: raise DiskError(f'Could not locate backplane info for "{self.path}"') if self.info['type'] == 'loop': - for drive in json.loads(b''.join(sys_command(['losetup', '--json'], hide_from_log=True)).decode('UTF_8'))['loopdevices']: + for drive in json.loads(b''.join(SysCommand(['losetup', '--json'], hide_from_log=True)).decode('UTF_8'))['loopdevices']: if not drive['name'] == self.path: continue @@ -99,10 +99,10 @@ class BlockDevice: @property def partitions(self): - o = b''.join(sys_command(['partprobe', self.path])) + o = b''.join(SysCommand(['partprobe', self.path])) # o = b''.join(sys_command('/usr/bin/lsblk -o name -J -b {dev}'.format(dev=dev))) - o = b''.join(sys_command(['/usr/bin/lsblk', '-J', self.path])) + o = b''.join(SysCommand(['/usr/bin/lsblk', '-J', self.path])) if b'not a block device' in o: raise DiskError(f'Can not read partitions off something that isn\'t a block device: {self.path}') @@ -116,7 +116,7 @@ class BlockDevice: for part in r['blockdevices'][0]['children']: part_id = part['name'][len(os.path.basename(self.path)):] if part_id not in self.part_cache: - ## TODO: Force over-write even if in cache? + # TODO: Force over-write even if in cache? if part_id not in self.part_cache or self.part_cache[part_id].size != part['size']: self.part_cache[part_id] = Partition(root_path + part_id, self, part_id=part_id, size=part['size']) @@ -139,7 +139,7 @@ class BlockDevice: This is more reliable than relying on /dev/disk/by-partuuid as it doesn't seam to be able to detect md raid partitions. """ - lsblk = b''.join(sys_command(f'lsblk -J -o+UUID {self.path}')) + lsblk = b''.join(SysCommand(f'lsblk -J -o+UUID {self.path}')) for partition in json.loads(lsblk.decode('UTF-8'))['blockdevices']: return partition.get('uuid', None) @@ -216,7 +216,7 @@ class Partition: This is more reliable than relying on /dev/disk/by-partuuid as it doesn't seam to be able to detect md raid partitions. """ - lsblk = b''.join(sys_command(f'lsblk -J -o+PARTUUID {self.path}')) + lsblk = b''.join(SysCommand(f'lsblk -J -o+PARTUUID {self.path}')) for partition in json.loads(lsblk.decode('UTF-8'))['blockdevices']: return partition.get('partuuid', None) return None @@ -236,7 +236,7 @@ class Partition: @property def real_device(self): - for blockdevice in json.loads(b''.join(sys_command('lsblk -J')).decode('UTF-8'))['blockdevices']: + for blockdevice in json.loads(b''.join(SysCommand('lsblk -J')).decode('UTF-8'))['blockdevices']: if parent := self.find_parent_of(blockdevice, os.path.basename(self.path)): return f"/dev/{parent}" # raise DiskError(f'Could not find appropriate parent for encrypted partition {self}') @@ -260,11 +260,11 @@ class Partition: temporary_path = pathlib.Path(temporary_mountpoint) temporary_path.mkdir(parents=True, exist_ok=True) - if (handle := sys_command(f'/usr/bin/mount {self.path} {temporary_mountpoint}')).exit_code != 0: + if (handle := SysCommand(f'/usr/bin/mount {self.path} {temporary_mountpoint}')).exit_code != 0: raise DiskError(f'Could not mount and check for content on {self.path} because: {b"".join(handle)}') files = len(glob.glob(f"{temporary_mountpoint}/*")) - sys_command(f'/usr/bin/umount {temporary_mountpoint}') + SysCommand(f'/usr/bin/umount {temporary_mountpoint}') temporary_path.rmdir() @@ -327,29 +327,29 @@ class Partition: log(f'Formatting {path} -> {filesystem}', level=logging.INFO) if filesystem == 'btrfs': - o = b''.join(sys_command(f'/usr/bin/mkfs.btrfs -f {path}')) + o = b''.join(SysCommand(f'/usr/bin/mkfs.btrfs -f {path}')) if b'UUID' not in o: raise DiskError(f'Could not format {path} with {filesystem} because: {o}') self.filesystem = 'btrfs' elif filesystem == 'vfat': - o = b''.join(sys_command(f'/usr/bin/mkfs.vfat -F32 {path}')) + o = b''.join(SysCommand(f'/usr/bin/mkfs.vfat -F32 {path}')) if (b'mkfs.fat' not in o and b'mkfs.vfat' not in o) or b'command not found' in o: raise DiskError(f'Could not format {path} with {filesystem} because: {o}') self.filesystem = 'vfat' elif filesystem == 'ext4': - if (handle := sys_command(f'/usr/bin/mkfs.ext4 -F {path}')).exit_code != 0: + if (handle := SysCommand(f'/usr/bin/mkfs.ext4 -F {path}')).exit_code != 0: raise DiskError(f'Could not format {path} with {filesystem} because: {b"".join(handle)}') self.filesystem = 'ext4' elif filesystem == 'xfs': - if (handle := sys_command(f'/usr/bin/mkfs.xfs -f {path}')).exit_code != 0: + if (handle := SysCommand(f'/usr/bin/mkfs.xfs -f {path}')).exit_code != 0: raise DiskError(f'Could not format {path} with {filesystem} because: {b"".join(handle)}') self.filesystem = 'xfs' elif filesystem == 'f2fs': - if (handle := sys_command(f'/usr/bin/mkfs.f2fs -f {path}')).exit_code != 0: + if (handle := SysCommand(f'/usr/bin/mkfs.f2fs -f {path}')).exit_code != 0: raise DiskError(f'Could not format {path} with {filesystem} because: {b"".join(handle)}') self.filesystem = 'f2fs' @@ -389,9 +389,9 @@ class Partition: try: if options: - sys_command(f'/usr/bin/mount -o {options} {self.path} {target}') + SysCommand(f'/usr/bin/mount -o {options} {self.path} {target}') else: - sys_command(f'/usr/bin/mount {self.path} {target}') + SysCommand(f'/usr/bin/mount {self.path} {target}') except SysCallError as err: raise err @@ -400,7 +400,7 @@ class Partition: def unmount(self): try: - exit_code = sys_command(f'/usr/bin/umount {self.path}').exit_code + exit_code = SysCommand(f'/usr/bin/umount {self.path}').exit_code except SysCallError as err: exit_code = err.exit_code @@ -450,7 +450,7 @@ class Filesystem: else: raise DiskError('Problem setting the partition format to GPT:', f'/usr/bin/parted -s {self.blockdevice.device} mklabel gpt') elif self.mode == MBR: - if sys_command(f'/usr/bin/parted -s {self.blockdevice.device} mklabel msdos').exit_code == 0: + if SysCommand(f'/usr/bin/parted -s {self.blockdevice.device} mklabel msdos').exit_code == 0: return self else: raise DiskError('Problem setting the partition format to GPT:', f'/usr/bin/parted -s {self.blockdevice.device} mklabel msdos') @@ -472,7 +472,7 @@ class Filesystem: # TODO: https://stackoverflow.com/questions/28157929/how-to-safely-handle-an-exception-inside-a-context-manager if len(args) >= 2 and args[1]: raise args[1] - b''.join(sys_command('sync')) + b''.join(SysCommand('sync')) return True def find_partition(self, mountpoint): @@ -481,7 +481,7 @@ class Filesystem: return partition def raw_parted(self, string: str): - x = sys_command(f'/usr/bin/parted -s {string}') + x = SysCommand(f'/usr/bin/parted -s {string}') return x def parted(self, string: str): @@ -495,7 +495,7 @@ class Filesystem: def use_entire_disk(self, root_filesystem_type='ext4'): log(f"Using and formatting the entire {self.blockdevice}.", level=logging.DEBUG) - if hasUEFI(): + if has_uefi(): self.add_partition('primary', start='1MiB', end='513MiB', format='fat32') self.set_name(0, 'EFI') self.set(0, 'boot on') @@ -572,7 +572,7 @@ def all_disks(*args, **kwargs): kwargs.setdefault("partitions", False) drives = OrderedDict() # for drive in json.loads(sys_command(f'losetup --json', *args, **lkwargs, hide_from_log=True)).decode('UTF_8')['loopdevices']: - for drive in json.loads(b''.join(sys_command('lsblk --json -l -n -o path,size,type,mountpoint,label,pkname,model', *args, **kwargs, hide_from_log=True)).decode('UTF_8'))['blockdevices']: + for drive in json.loads(b''.join(SysCommand('lsblk --json -l -n -o path,size,type,mountpoint,label,pkname,model', *args, **kwargs, hide_from_log=True)).decode('UTF_8'))['blockdevices']: if not kwargs['partitions'] and drive['type'] == 'part': continue @@ -605,7 +605,7 @@ def harddrive(size=None, model=None, fuzzy=False): def get_mount_info(path): try: - output = b''.join(sys_command(f'/usr/bin/findmnt --json {path}')) + output = b''.join(SysCommand(f'/usr/bin/findmnt --json {path}')) except SysCallError: return {} @@ -620,7 +620,7 @@ def get_mount_info(path): def get_partitions_in_use(mountpoint): try: - output = b''.join(sys_command(f'/usr/bin/findmnt --json -R {mountpoint}')) + output = b''.join(SysCommand(f'/usr/bin/findmnt --json -R {mountpoint}')) except SysCallError: return {} @@ -639,7 +639,7 @@ def get_partitions_in_use(mountpoint): def get_filesystem_type(path): try: - handle = sys_command(f"blkid -o value -s TYPE {path}") + handle = SysCommand(f"blkid -o value -s TYPE {path}") return b''.join(handle).strip().decode('UTF-8') except SysCallError: return None @@ -647,7 +647,7 @@ def get_filesystem_type(path): def disk_layouts(): try: - handle = sys_command("lsblk -f -o+TYPE,SIZE -J") + handle = SysCommand("lsblk -f -o+TYPE,SIZE -J") return json.loads(b''.join(handle).decode('UTF-8')) except SysCallError as err: log(f"Could not return disk layouts: {err}") diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index 7296b943..9fbf2654 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -42,7 +42,7 @@ def locate_binary(name): break # Don't recurse -class JSON_Encoder: +class JsonEncoder: def _encode(obj): if isinstance(obj, dict): # We'll need to iterate not just the value that default() usually gets passed @@ -54,12 +54,12 @@ class JSON_Encoder: # This, is a EXTREMELY ugly hack.. but it's the only quick way I can think of to trigger a encoding of sub-dictionaries. val = json.loads(json.dumps(val, cls=JSON)) else: - val = JSON_Encoder._encode(val) + val = JsonEncoder._encode(val) if type(key) == str and key[0] == '!': - copy[JSON_Encoder._encode(key)] = '******' + copy[JsonEncoder._encode(key)] = '******' else: - copy[JSON_Encoder._encode(key)] = val + copy[JsonEncoder._encode(key)] = val return copy elif hasattr(obj, 'json'): return obj.json() @@ -78,13 +78,13 @@ class JSON_Encoder: class JSON(json.JSONEncoder, json.JSONDecoder): def _encode(self, obj): - return JSON_Encoder._encode(obj) + return JsonEncoder._encode(obj) def encode(self, obj): return super(JSON, self).encode(self._encode(obj)) -class sys_command: +class SysCommand: """ Stolen from archinstall_gui """ @@ -336,4 +336,4 @@ def prerequisite_check(): def reboot(): - o = b''.join(sys_command("/usr/bin/reboot")) + o = b''.join(SysCommand("/usr/bin/reboot")) diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py index d1723cde..f527b5da 100644 --- a/archinstall/lib/hardware.py +++ b/archinstall/lib/hardware.py @@ -3,7 +3,7 @@ import os import subprocess from typing import Optional -from .general import sys_command +from .general import SysCommand from .networking import list_interfaces, enrich_iface_types __packages__ = [ @@ -56,48 +56,48 @@ AVAILABLE_GFX_DRIVERS = { } -def hasWifi() -> bool: +def has_wifi() -> bool: return 'WIRELESS' in enrich_iface_types(list_interfaces().values()).values() -def hasAMDCPU() -> bool: +def has_amd_cpu() -> bool: if subprocess.check_output("lscpu | grep AMD", shell=True).strip().decode(): return True return False -def hasIntelCPU() -> bool: +def has_intel_cpu() -> bool: if subprocess.check_output("lscpu | grep Intel", shell=True).strip().decode(): return True return False -def hasUEFI() -> bool: +def has_uefi() -> bool: return os.path.isdir('/sys/firmware/efi') -def graphicsDevices() -> dict: +def graphics_devices() -> dict: cards = {} - for line in sys_command("lspci"): + for line in SysCommand("lspci"): if b' VGA ' in line: _, identifier = line.split(b': ', 1) cards[identifier.strip().lower().decode('UTF-8')] = line return cards -def hasNvidiaGraphics() -> bool: - return any('nvidia' in x for x in graphicsDevices()) +def has_nvidia_graphics() -> bool: + return any('nvidia' in x for x in graphics_devices()) -def hasAmdGraphics() -> bool: - return any('amd' in x for x in graphicsDevices()) +def has_amd_graphics() -> bool: + return any('amd' in x for x in graphics_devices()) -def hasIntelGraphics() -> bool: - return any('intel' in x for x in graphicsDevices()) +def has_intel_graphics() -> bool: + return any('intel' in x for x in graphics_devices()) -def cpuVendor() -> Optional[str]: +def cpu_vendor() -> Optional[str]: cpu_info = json.loads(subprocess.check_output("lscpu -J", shell=True).decode('utf-8'))['lscpu'] for info in cpu_info: if info.get('field', None): @@ -106,7 +106,7 @@ def cpuVendor() -> Optional[str]: return None -def isVM() -> bool: +def is_vm() -> bool: try: subprocess.check_call(["systemd-detect-virt"]) # systemd-detect-virt issues a non-zero exit code if it is not on a virtual machine return True diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 9ddb8825..aa2ea920 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -135,8 +135,8 @@ class Installer: packages = packages[0] self.log(f'Installing packages: {packages}', level=logging.INFO) - if (sync_mirrors := sys_command('/usr/bin/pacman -Syy')).exit_code == 0: - if (pacstrap := sys_command(f'/usr/bin/pacstrap {self.target} {" ".join(packages)}', **kwargs)).exit_code == 0: + if (sync_mirrors := SysCommand('/usr/bin/pacman -Syy')).exit_code == 0: + if (pacstrap := SysCommand(f'/usr/bin/pacstrap {self.target} {" ".join(packages)}', **kwargs)).exit_code == 0: return True else: self.log(f'Could not strap in packages: {pacstrap.exit_code}', level=logging.INFO) @@ -149,7 +149,7 @@ class Installer: def genfstab(self, flags='-pU'): self.log(f"Updating {self.target}/etc/fstab", level=logging.INFO) - fstab = sys_command(f'/usr/bin/genfstab {flags} {self.target}').trace_log + fstab = SysCommand(f'/usr/bin/genfstab {flags} {self.target}').trace_log with open(f"{self.target}/etc/fstab", 'ab') as fstab_fh: fstab_fh.write(fstab) @@ -171,7 +171,7 @@ class Installer: with open(f'{self.target}/etc/locale.conf', 'w') as fh: fh.write(f'LANG={locale}.{encoding}\n') - return True if sys_command(f'/usr/bin/arch-chroot {self.target} locale-gen').exit_code == 0 else False + return True if SysCommand(f'/usr/bin/arch-chroot {self.target} locale-gen').exit_code == 0 else False def set_timezone(self, zone, *args, **kwargs): if not zone: @@ -181,7 +181,7 @@ class Installer: if (pathlib.Path("/usr") / "share" / "zoneinfo" / zone).exists(): (pathlib.Path(self.target) / "etc" / "localtime").unlink(missing_ok=True) - sys_command(f'/usr/bin/arch-chroot {self.target} ln -s /usr/share/zoneinfo/{zone} /etc/localtime') + SysCommand(f'/usr/bin/arch-chroot {self.target} ln -s /usr/share/zoneinfo/{zone} /etc/localtime') return True else: self.log( @@ -203,7 +203,7 @@ class Installer: raise ServiceException(f"Unable to start service {service}: {output}") def run_command(self, cmd, *args, **kwargs): - return sys_command(f'/usr/bin/arch-chroot {self.target} {cmd}') + return SysCommand(f'/usr/bin/arch-chroot {self.target} {cmd}') def arch_chroot(self, cmd, *args, **kwargs): if 'runas' in kwargs: @@ -232,7 +232,7 @@ class Installer: with open(f"{self.target}/etc/systemd/network/10-{nic}.network", "a") as netconf: netconf.write(str(conf)) - def copy_ISO_network_config(self, enable_services=False): + def copy_iso_network_config(self, enable_services=False): # Copy (if any) iwd password and config files if os.path.isdir('/var/lib/iwd/'): if psk_files := glob.glob('/var/lib/iwd/*.psk'): @@ -297,13 +297,13 @@ class Installer: mkinit.write(f"BINARIES=({' '.join(self.BINARIES)})\n") mkinit.write(f"FILES=({' '.join(self.FILES)})\n") mkinit.write(f"HOOKS=({' '.join(self.HOOKS)})\n") - sys_command(f'/usr/bin/arch-chroot {self.target} mkinitcpio {" ".join(flags)}') + SysCommand(f'/usr/bin/arch-chroot {self.target} mkinitcpio {" ".join(flags)}') def minimal_installation(self): - ## Add necessary packages if encrypting the drive - ## (encrypted partitions default to btrfs for now, so we need btrfs-progs) - ## TODO: Perhaps this should be living in the function which dictates - ## the partitioning. Leaving here for now. + # Add necessary packages if encrypting the drive + # (encrypted partitions default to btrfs for now, so we need btrfs-progs) + # TODO: Perhaps this should be living in the function which dictates + # the partitioning. Leaving here for now. for partition in self.partitions: if partition.filesystem == 'btrfs': @@ -325,11 +325,11 @@ class Installer: if 'encrypt' not in self.HOOKS: self.HOOKS.insert(self.HOOKS.index('filesystems'), 'encrypt') - if not hasUEFI(): + if not has_uefi(): self.base_packages.append('grub') - if not isVM(): - vendor = cpuVendor() + if not is_vm(): + vendor = cpu_vendor() if vendor == "AuthenticAMD": self.base_packages.append("amd-ucode") elif vendor == "GenuineIntel": @@ -343,7 +343,7 @@ class Installer: with open(f"{self.target}/etc/fstab", "a") as fstab: fstab.write("\ntmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0\n") # Redundant \n at the start? who knows? - ## TODO: Support locale and timezone + # TODO: Support locale and timezone # os.remove(f'{self.target}/etc/localtime') # sys_command(f'/usr/bin/arch-chroot {self.target} ln -s /usr/share/zoneinfo/{localtime} /etc/localtime') # sys_command('/usr/bin/arch-chroot /mnt hwclock --hctosys --localtime') @@ -351,7 +351,7 @@ class Installer: self.set_locale('en_US') # TODO: Use python functions for this - sys_command(f'/usr/bin/arch-chroot {self.target} chmod 700 /root') + SysCommand(f'/usr/bin/arch-chroot {self.target} chmod 700 /root') self.mkinitcpio('-P') @@ -378,16 +378,16 @@ class Installer: if bootloader == 'systemd-bootctl': self.pacstrap('efibootmgr') - if not hasUEFI(): + if not has_uefi(): raise HardwareIncompatibilityError # TODO: Ideally we would want to check if another config # points towards the same disk and/or partition. # And in which case we should do some clean up. # Install the boot loader - if sys_command(f'/usr/bin/arch-chroot {self.target} bootctl --path=/boot install').exit_code != 0: + if SysCommand(f'/usr/bin/arch-chroot {self.target} bootctl --path=/boot install').exit_code != 0: # Fallback, try creating the boot loader without touching the EFI variables - sys_command(f'/usr/bin/arch-chroot {self.target} bootctl --no-variables --path=/boot install') + SysCommand(f'/usr/bin/arch-chroot {self.target} bootctl --no-variables --path=/boot install') # Modify or create a loader.conf if os.path.isfile(f'{self.target}/boot/loader/loader.conf'): @@ -409,8 +409,8 @@ class Installer: else: loader.write(f"{line}\n") - ## For some reason, blkid and /dev/disk/by-uuid are not getting along well. - ## And blkid is wrong in terms of LUKS. + # For some reason, blkid and /dev/disk/by-uuid are not getting along well. + # And blkid is wrong in terms of LUKS. # UUID = sys_command('blkid -s PARTUUID -o value {drive}{partition_2}'.format(**args)).decode('UTF-8').strip() # Setup the loader entry with open(f'{self.target}/boot/loader/entries/{self.init_time}.conf', 'w') as entry: @@ -418,8 +418,8 @@ class Installer: entry.write(f'# Created on: {self.init_time}\n') entry.write('title Arch Linux\n') entry.write('linux /vmlinuz-linux\n') - if not isVM(): - vendor = cpuVendor() + if not is_vm(): + vendor = cpu_vendor() if vendor == "AuthenticAMD": entry.write("initrd /amd-ucode.img\n") elif vendor == "GenuineIntel": @@ -427,8 +427,8 @@ class Installer: else: self.log("unknow cpu vendor, not adding ucode to systemd-boot config") entry.write('initrd /initramfs-linux.img\n') - ## blkid doesn't trigger on loopback devices really well, - ## so we'll use the old manual method until we get that sorted out. + # blkid doesn't trigger on loopback devices really well, + # so we'll use the old manual method until we get that sorted out. if real_device := self.detect_encryption(root_partition): # TODO: We need to detect if the encrypted device is a whole disk encryption, @@ -446,17 +446,17 @@ class Installer: elif bootloader == "grub-install": self.pacstrap('grub') - if hasUEFI(): + if has_uefi(): self.pacstrap('efibootmgr') - o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.target} grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB')) - sys_command('/usr/bin/arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg') + o = b''.join(SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB')) + SysCommand('/usr/bin/arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg') return True else: root_device = subprocess.check_output(f'basename "$(readlink -f /sys/class/block/{root_partition.path.replace("/dev/", "")}/..)"', shell=True).decode().strip() if root_device == "block": root_device = f"{root_partition.path}" - o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.target} grub-install --target=i386-pc /dev/{root_device}')) - sys_command('/usr/bin/arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg') + o = b''.join(SysCommand(f'/usr/bin/arch-chroot {self.target} grub-install --target=i386-pc /dev/{root_device}')) + SysCommand('/usr/bin/arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg') self.helper_flags['bootloader'] = bootloader return True else: @@ -484,13 +484,13 @@ class Installer: if groups is None: groups = [] self.log(f'Creating user {user}', level=logging.INFO) - o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.target} useradd -m -G wheel {user}')) + o = b''.join(SysCommand(f'/usr/bin/arch-chroot {self.target} useradd -m -G wheel {user}')) if password: self.user_set_pw(user, password) if groups: for group in groups: - o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.target} gpasswd -a {user} {group}')) + o = b''.join(SysCommand(f'/usr/bin/arch-chroot {self.target} gpasswd -a {user} {group}')) if sudo and self.enable_sudo(user): self.helper_flags['user'] = True @@ -502,13 +502,13 @@ class Installer: # This means the root account isn't locked/disabled with * in /etc/passwd self.helper_flags['user'] = True - o = b''.join(sys_command(f"/usr/bin/arch-chroot {self.target} sh -c \"echo '{user}:{password}' | chpasswd\"")) + o = b''.join(SysCommand(f"/usr/bin/arch-chroot {self.target} sh -c \"echo '{user}:{password}' | chpasswd\"")) pass def user_set_shell(self, user, shell): self.log(f'Setting shell for {user} to {shell}', level=logging.INFO) - o = b''.join(sys_command(f"/usr/bin/arch-chroot {self.target} sh -c \"chsh -s {shell} {user}\"")) + o = b''.join(SysCommand(f"/usr/bin/arch-chroot {self.target} sh -c \"chsh -s {shell} {user}\"")) pass def set_keyboard_language(self, language): diff --git a/archinstall/lib/luks.py b/archinstall/lib/luks.py index 1cb6777f..6fab9b94 100644 --- a/archinstall/lib/luks.py +++ b/archinstall/lib/luks.py @@ -78,7 +78,7 @@ class luks2: try: # Try to setup the crypt-device - cmd_handle = sys_command(cryptsetup_args) + cmd_handle = SysCommand(cryptsetup_args) except SysCallError as err: if err.exit_code == 256: log(f'{partition} is being used, trying to unmount and crypt-close the device and running one more attempt at encrypting the device.', level=logging.DEBUG) @@ -87,7 +87,7 @@ class luks2: # Get crypt-information about the device by doing a reverse lookup starting with the partition path # For instance: /dev/sda - devinfo = json.loads(b''.join(sys_command(f"lsblk --fs -J {partition.path}")).decode('UTF-8'))['blockdevices'][0] + devinfo = json.loads(b''.join(SysCommand(f"lsblk --fs -J {partition.path}")).decode('UTF-8'))['blockdevices'][0] # For each child (sub-partition/sub-device) if len(children := devinfo.get('children', [])): @@ -95,14 +95,14 @@ class luks2: # Unmount the child location if child_mountpoint := child.get('mountpoint', None): log(f'Unmounting {child_mountpoint}', level=logging.DEBUG) - sys_command(f"umount -R {child_mountpoint}") + SysCommand(f"umount -R {child_mountpoint}") # And close it if possible. log(f"Closing crypt device {child['name']}", level=logging.DEBUG) - sys_command(f"cryptsetup close {child['name']}") + SysCommand(f"cryptsetup close {child['name']}") # Then try again to set up the crypt-device - cmd_handle = sys_command(cryptsetup_args) + cmd_handle = SysCommand(cryptsetup_args) else: raise err @@ -128,7 +128,7 @@ class luks2: while pathlib.Path(partition.path).exists() is False and time.time() - wait_timer < 10: time.sleep(0.025) - sys_command(f'/usr/bin/cryptsetup open {partition.path} {mountpoint} --key-file {os.path.abspath(key_file)} --type luks2') + SysCommand(f'/usr/bin/cryptsetup open {partition.path} {mountpoint} --key-file {os.path.abspath(key_file)} --type luks2') if os.path.islink(f'/dev/mapper/{mountpoint}'): self.mapdev = f'/dev/mapper/{mountpoint}' unlocked_partition = Partition(self.mapdev, None, encrypted=True, filesystem=get_filesystem_type(self.mapdev), autodetect_filesystem=False) @@ -139,9 +139,9 @@ class luks2: if not mountpoint: mountpoint = self.mapdev - sys_command(f'/usr/bin/cryptsetup close {self.mapdev}') + SysCommand(f'/usr/bin/cryptsetup close {self.mapdev}') return os.path.islink(self.mapdev) is False def format(self, path): - if (handle := sys_command(f"/usr/bin/cryptsetup -q -v luksErase {path}")).exit_code != 0: + if (handle := SysCommand(f"/usr/bin/cryptsetup -q -v luksErase {path}")).exit_code != 0: raise DiskError(f'Could not format {path} with {self.filesystem} because: {b"".join(handle)}') diff --git a/archinstall/lib/mirrors.py b/archinstall/lib/mirrors.py index 55ec5a98..3215122f 100644 --- a/archinstall/lib/mirrors.py +++ b/archinstall/lib/mirrors.py @@ -15,9 +15,9 @@ def filter_mirrors_by_region(regions, destination='/etc/pacman.d/mirrorlist', tm region_list = [] for region in regions.split(','): region_list.append(f'country={region}') - o = b''.join(sys_command(f"/usr/bin/wget 'https://archlinux.org/mirrorlist/?{'&'.join(region_list)}&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on' -O {tmp_dir}/mirrorlist")) - o = b''.join(sys_command(f"/usr/bin/sed -i 's/#Server/Server/' {tmp_dir}/mirrorlist")) - o = b''.join(sys_command(f"/usr/bin/mv {tmp_dir}/mirrorlist {destination}")) + o = b''.join(SysCommand(f"/usr/bin/wget 'https://archlinux.org/mirrorlist/?{'&'.join(region_list)}&protocol=https&ip_version=4&ip_version=6&use_mirror_status=on' -O {tmp_dir}/mirrorlist")) + o = b''.join(SysCommand(f"/usr/bin/sed -i 's/#Server/Server/' {tmp_dir}/mirrorlist")) + o = b''.join(SysCommand(f"/usr/bin/mv {tmp_dir}/mirrorlist {destination}")) return True @@ -71,7 +71,7 @@ def use_mirrors(regions: dict, destination='/etc/pacman.d/mirrorlist'): def re_rank_mirrors(top=10, *positionals, **kwargs): - if sys_command(f'/usr/bin/rankmirrors -n {top} /etc/pacman.d/mirrorlist > /etc/pacman.d/mirrorlist').exit_code == 0: + if SysCommand(f'/usr/bin/rankmirrors -n {top} /etc/pacman.d/mirrorlist > /etc/pacman.d/mirrorlist').exit_code == 0: return True return False diff --git a/archinstall/lib/networking.py b/archinstall/lib/networking.py index 1a5c403f..b0c4b569 100644 --- a/archinstall/lib/networking.py +++ b/archinstall/lib/networking.py @@ -5,7 +5,7 @@ import struct from collections import OrderedDict from .exceptions import * -from .general import sys_command +from .general import SysCommand from .storage import storage @@ -53,7 +53,7 @@ def wireless_scan(interface): if interfaces[interface] != 'WIRELESS': raise HardwareIncompatibilityError(f"Interface {interface} is not a wireless interface: {interfaces}") - sys_command(f"iwctl station {interface} scan") + SysCommand(f"iwctl station {interface} scan") if '_WIFI' not in storage: storage['_WIFI'] = {} @@ -72,5 +72,5 @@ def get_wireless_networks(interface): wireless_scan(interface) time.sleep(5) - for line in sys_command(f"iwctl station {interface} get-networks"): + for line in SysCommand(f"iwctl station {interface} get-networks"): print(line) diff --git a/archinstall/lib/output.py b/archinstall/lib/output.py index f69571c0..8bc6cacb 100644 --- a/archinstall/lib/output.py +++ b/archinstall/lib/output.py @@ -18,7 +18,7 @@ class LogLevels: Debug = 0b111 -class journald(dict): +class Journald(dict): @abc.abstractmethod def log(message, level=logging.DEBUG): try: @@ -161,7 +161,7 @@ def log(*args, **kwargs): return None try: - journald.log(string, level=kwargs.get('level', logging.INFO)) + Journald.log(string, level=kwargs.get('level', logging.INFO)) except ModuleNotFoundError: pass # Ignore writing to journald diff --git a/archinstall/lib/services.py b/archinstall/lib/services.py index 537a2f84..6f8f2a87 100644 --- a/archinstall/lib/services.py +++ b/archinstall/lib/services.py @@ -5,6 +5,6 @@ def service_state(service_name: str): if os.path.splitext(service_name)[1] != '.service': service_name += '.service' # Just to be safe - state = b''.join(sys_command(f'systemctl show --no-pager -p SubState --value {service_name}', environment_vars={'SYSTEMD_COLORS': '0'})) + state = b''.join(SysCommand(f'systemctl show --no-pager -p SubState --value {service_name}', environment_vars={'SYSTEMD_COLORS': '0'})) return state.strip().decode('UTF-8') diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index d490aeec..c640cb83 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -12,8 +12,8 @@ import time import tty from .exceptions import * -from .general import sys_command -from .hardware import AVAILABLE_GFX_DRIVERS, hasUEFI +from .general import SysCommand +from .hardware import AVAILABLE_GFX_DRIVERS, has_uefi from .locale_helpers import list_keyboard_languages, verify_keyboard_layout, search_keyboard_layout from .networking import list_interfaces from .output import log @@ -363,7 +363,7 @@ def ask_for_a_timezone(): def ask_for_bootloader() -> str: bootloader = "systemd-bootctl" - if not hasUEFI(): + if not has_uefi(): bootloader = "grub-install" else: bootloader_choice = input("Would you like to use GRUB as a bootloader instead of systemd-boot? [y/N] ").lower() @@ -705,7 +705,7 @@ def select_driver(options=AVAILABLE_GFX_DRIVERS): default_option = options["All open-source (default)"] if drivers: - lspci = sys_command('/usr/bin/lspci') + lspci = SysCommand('/usr/bin/lspci') for line in lspci.trace_log.split(b'\r\n'): if b' vga ' in line.lower(): if b'nvidia' in line.lower(): diff --git a/docs/conf.py b/docs/conf.py index 88a55e02..375ff434 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -8,8 +8,8 @@ sys.path.insert(0, os.path.abspath('..')) def process_docstring(app, what, name, obj, options, lines): spaces_pat = re.compile(r"( {8})") ll = [] - for l in lines: - ll.append(spaces_pat.sub(" ", l)) + for line in lines: + ll.append(spaces_pat.sub(" ", line)) lines[:] = ll diff --git a/examples/guided.py b/examples/guided.py index e9873ef0..177f4adb 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -3,7 +3,7 @@ import logging import time import archinstall -from archinstall.lib.hardware import hasUEFI +from archinstall.lib.hardware import has_uefi if archinstall.arguments.get('help'): print("See `man archinstall` for help.") @@ -257,7 +257,7 @@ def perform_installation_steps(): Once that's done, we'll hand over to perform_installation() """ mode = archinstall.GPT - if hasUEFI() is False: + if has_uefi() is False: mode = archinstall.MBR with archinstall.Filesystem(archinstall.arguments['harddrive'], mode) as fs: @@ -294,7 +294,7 @@ def perform_installation_steps(): else: fs.find_partition('/').mount('/mnt') - if hasUEFI(): + if has_uefi(): fs.find_partition('/boot').mount('/mnt/boot') perform_installation('/mnt') @@ -321,7 +321,7 @@ def perform_installation(mountpoint): installation.set_hostname(archinstall.arguments['hostname']) if archinstall.arguments['mirror-region'].get("mirrors", None) is not None: installation.set_mirrors(archinstall.arguments['mirror-region']) # Set the mirrors in the installation medium - if archinstall.arguments["bootloader"] == "grub-install" and hasUEFI(): + if archinstall.arguments["bootloader"] == "grub-install" and has_uefi(): installation.add_additional_packages("grub") installation.set_keyboard_language(archinstall.arguments['keyboard-language']) installation.add_bootloader(archinstall.arguments["bootloader"]) @@ -329,7 +329,7 @@ def perform_installation(mountpoint): # If user selected to copy the current ISO network configuration # Perform a copy of the config if archinstall.arguments.get('nic', {}) == 'Copy ISO network configuration to installation': - installation.copy_ISO_network_config(enable_services=True) # Sources the ISO network configuration to the install medium. + installation.copy_iso_network_config(enable_services=True) # Sources the ISO network configuration to the install medium. elif archinstall.arguments.get('nic', {}).get('NetworkManager', False): installation.add_additional_packages("networkmanager") installation.enable_service('NetworkManager.service') diff --git a/examples/minimal.py b/examples/minimal.py index 308a5e30..5da6f0c1 100644 --- a/examples/minimal.py +++ b/examples/minimal.py @@ -23,7 +23,7 @@ def install_on(mountpoint): # Optionally enable networking: if archinstall.arguments.get('network', None): - installation.copy_ISO_network_config(enable_services=True) + installation.copy_iso_network_config(enable_services=True) installation.add_additional_packages(['nano', 'wget', 'git']) installation.install_profile('minimal') -- cgit v1.2.3-70-g09d2