Replacing static variables with more dynamic ones that can live across scopes. No need to pass things around unless strictly nessecary

This commit is contained in:
Anton Hvornum 2021-02-07 18:43:05 +01:00
parent ea65e3599a
commit 819a8f742e
1 changed files with 9 additions and 7 deletions

View File

@ -93,17 +93,19 @@ if not archinstall.arguments.get('mirror-region', None):
archinstall.arguments['mirror-region'] = archinstall.select_mirror_regions(archinstall.list_mirrors()) archinstall.arguments['mirror-region'] = archinstall.select_mirror_regions(archinstall.list_mirrors())
# Ask which harddrive/block-device we will install to # Ask which harddrive/block-device we will install to
if not archinstall.arguments.get('harddrive', None): if archinstall.arguments.get('harddrive', None):
archinstall.arguments['harddrive'] = archinstall.BlockDevice(archinstall.arguments['harddrive'])
else:
archinstall.arguments['harddrive'] = archinstall.select_disk(archinstall.all_disks()) archinstall.arguments['harddrive'] = archinstall.select_disk(archinstall.all_disks())
# Perform a quick sanity check on the selected harddrive. # Perform a quick sanity check on the selected harddrive.
# 1. Check if it has partitions # 1. Check if it has partitions
# 3. Check that we support the current partitions # 3. Check that we support the current partitions
# 2. If so, ask if we should keep them or wipe everything # 2. If so, ask if we should keep them or wipe everything
if harddrive.has_partitions(): if archinstall.arguments['harddrive'].has_partitions():
archinstall.log(f" ! {harddrive} contains existing partitions", fg='red') archinstall.log(f" ! {archinstall.arguments['harddrive']} contains existing partitions", fg='red')
try: try:
for partition in harddrive: for partition in archinstall.arguments['harddrive']:
if partition.filesystem_supported(): if partition.filesystem_supported():
archinstall.log(f" {partition}") archinstall.log(f" {partition}")
@ -111,8 +113,8 @@ if harddrive.has_partitions():
# If we want to keep the existing partitioning table # If we want to keep the existing partitioning table
# Make sure that it's the selected drive mounted under /mnt # Make sure that it's the selected drive mounted under /mnt
# That way, we can rely on genfstab and some manual post-installation steps. # That way, we can rely on genfstab and some manual post-installation steps.
if harddrive.has_mount_point(archinstall.storage['MOUNT_POINT']) is False: if archinstall.arguments['harddrive'].has_mount_point(archinstall.storage['MOUNT_POINT']) is False:
raise archinstall.DiskError(f"The selected drive {harddrive} is not pre-mounted to {archinstall.storage['MOUNT_POINT']}. This is required when keeping a existing partitioning scheme.") raise archinstall.DiskError(f"The selected drive {archinstall.arguments['harddrive']} is not pre-mounted to {archinstall.storage['MOUNT_POINT']}. This is required when keeping a existing partitioning scheme.")
archinstall.log('Using existing partition table reported above.') archinstall.log('Using existing partition table reported above.')
except UnknownFilesystemFormat as err: except UnknownFilesystemFormat as err:
@ -261,7 +263,7 @@ input('Press Enter to continue.')
We mention the drive one last time, and count from 5 to 0. We mention the drive one last time, and count from 5 to 0.
""" """
print(f' ! Formatting {harddrive} in ', end='') print(f' ! Formatting {archinstall.arguments['harddrive']} in ', end='')
for i in range(5, 0, -1): for i in range(5, 0, -1):
print(f"{i}", end='') print(f"{i}", end='')