Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
authorSecondThundeR <awayfromgalaxy@gmail.com>2021-04-23 01:55:53 +0300
committerSecondThundeR <awayfromgalaxy@gmail.com>2021-04-23 01:55:53 +0300
commitf5b6e7bafead1f604c27bfb31b84f3f560a682c8 (patch)
treedce070c9133655f81547b98b0d855382d780da1c /archinstall
parent2d3d3c54ef5ec5f4311afe75d87733a27b1d7509 (diff)
Update logging for some functions
- Unified view of warning (red) and info (yellow) logs - Fixed some PEP8 related issues, like removing redundant f-strings and replacing double quotes to single ones - Removed warning logging level for simple logs - Removed other background color settings for logs to fully close https://github.com/archlinux/archinstall/pull/171
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/lib/disk.py4
-rw-r--r--archinstall/lib/installer.py10
-rw-r--r--archinstall/lib/mirrors.py2
-rw-r--r--archinstall/lib/output.py4
-rw-r--r--archinstall/lib/user_interaction.py25
5 files changed, 19 insertions, 26 deletions
diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py
index bada4076..de93556a 100644
--- a/archinstall/lib/disk.py
+++ b/archinstall/lib/disk.py
@@ -128,7 +128,7 @@ class BlockDevice():
@property
def uuid(self):
- log(f'BlockDevice().uuid is untested!', level=LOG_LEVELS.Warning, fg='yellow')
+ log('BlockDevice().uuid is untested!', level=LOG_LEVELS.Warning, fg='yellow')
"""
Returns the disk UUID as returned by lsblk.
This is more reliable than relying on /dev/disk/by-partuuid as
@@ -292,7 +292,7 @@ class Partition():
raise DiskError(f"Attempting to encrypt a partition that was not marked for encryption: {self}")
if not self.safe_to_format():
- log(f"Partition {self} was marked as protected but encrypt() was called on it!", level=LOG_LEVELS.Error, fg="red")
+ log(f" * Partition {self} was marked as protected but encrypt() was called on it! * ", level=LOG_LEVELS.Error, fg='red')
return False
handle = luks2(self, None, None)
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
index 758033a7..c64079f6 100644
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -79,14 +79,14 @@ class Installer():
self.genfstab()
if not (missing_steps := self.post_install_check()):
- self.log('Installation completed without any errors. You may now reboot.', bg='black', fg='green', level=LOG_LEVELS.Info)
+ self.log('Installation completed without any errors. You may now reboot.', fg='green', level=LOG_LEVELS.Info)
self.sync_log_to_install_medium()
return True
else:
- self.log('Some required steps were not successfully installed/configured before leaving the installer:', bg='black', fg='red', level=LOG_LEVELS.Warning)
+ self.log('Some required steps were not successfully installed/configured before leaving the installer:', fg='red', level=LOG_LEVELS.Warning)
for step in missing_steps:
- self.log(f' - {step}', bg='black', fg='red', level=LOG_LEVELS.Warning)
+ self.log(f' - {step}', fg='red', level=LOG_LEVELS.Warning)
self.log(f"Detailed error logs can be found at: {storage['LOG_PATH']}", level=LOG_LEVELS.Warning)
self.log(f"Submit this zip file as an issue to https://github.com/archlinux/archinstall/issues", level=LOG_LEVELS.Warning)
@@ -168,7 +168,7 @@ class Installer():
return True
else:
self.log(
- f"Time zone {zone} does not exist, continuing with system default.",
+ f" * Timezone \"{zone}\" does not exist, continuing with system default * ",
level=LOG_LEVELS.Warning,
fg='red'
)
@@ -460,5 +460,5 @@ class Installer():
vconsole.write(f'KEYMAP={language}\n')
vconsole.write(f'FONT=lat9w-16\n')
else:
- self.log(f'Keyboard language was not changed from default (no language specified).', fg="yellow", level=LOG_LEVELS.Info)
+ self.log('Keyboard language was not changed from default (no language specified).', fg='yellow', level=LOG_LEVELS.Info)
return True
diff --git a/archinstall/lib/mirrors.py b/archinstall/lib/mirrors.py
index 04f47c0d..57271bf8 100644
--- a/archinstall/lib/mirrors.py
+++ b/archinstall/lib/mirrors.py
@@ -79,7 +79,7 @@ def list_mirrors():
try:
response = urllib.request.urlopen(url)
except urllib.error.URLError as err:
- log(f'Could not fetch an active mirror-list: {err}', level=LOG_LEVELS.Warning, fg="yellow")
+ log(f"Could not fetch an active mirror-list: {err}", level=LOG_LEVELS.Warning, fg='yellow')
return regions
diff --git a/archinstall/lib/output.py b/archinstall/lib/output.py
index 6b184b4b..eb23faf4 100644
--- a/archinstall/lib/output.py
+++ b/archinstall/lib/output.py
@@ -100,12 +100,12 @@ def log(*args, **kwargs):
Path(absolute_logfile).parents[0].mkdir(exist_ok=True, parents=True)
except PermissionError:
# Fallback to creating the log file in the current folder
- err_string = f"Not enough permission to place log file at {absolute_logfile}, creating it in {Path('./').absolute()/filename} instead."
+ err_string = f" * Not enough permission to place log file at {absolute_logfile}, creating it in {Path('./').absolute()/filename} instead * "
absolute_logfile = Path('./').absolute()/filename
absolute_logfile.parents[0].mkdir(exist_ok=True)
absolute_logfile = str(absolute_logfile)
storage['LOG_PATH'] = './'
- log(err_string, fg="red")
+ log(err_string, fg='red')
Path(absolute_logfile).touch() # Overkill?
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index 572acf4f..ec6b6d34 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -22,11 +22,7 @@ def get_longest_option(options):
def check_for_correct_username(username):
if re.match(r'^[a-z_][a-z0-9_-]*\$?$', username) and len(username) <= 32:
return True
- log(
- "The username you entered is invalid. Try again",
- level=LOG_LEVELS.Warning,
- fg='red'
- )
+ log(' * The username you entered is invalid. Try again * ', fg='red')
return False
def do_countdown():
@@ -138,8 +134,7 @@ def ask_for_a_timezone():
return timezone
else:
log(
- f"Specified timezone {timezone} does not exist.",
- level=LOG_LEVELS.Warning,
+ f"* Specified timezone {timezone} does not exist * ",
fg='red'
)
@@ -185,8 +180,7 @@ def ask_to_configure_network():
break
except ValueError:
log(
- "You need to enter a valid IP in IP-config mode.",
- level=LOG_LEVELS.Warning,
+ 'You need to enter a valid IP in IP-config mode',
fg='red'
)
@@ -201,8 +195,7 @@ def ask_to_configure_network():
break
except ValueError:
log(
- "You need to enter a valid gateway (router) IP address.",
- level=LOG_LEVELS.Warning,
+ 'You need to enter a valid gateway (router) IP address',
fg='red'
)
@@ -258,15 +251,15 @@ def generic_select(options, input_text="Select one of the above by index or abso
# Checking if options are different from `list` or `dict`
if type(options) not in [list, dict]:
log(f" * Generic select doesn't support ({type(options)}) as type of options * ", fg='red')
- log(" * If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues * ", fg='yellow')
+ log('If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues', fg='yellow')
raise RequirementError("generic_select() requires list or dictionary as options.")
# To allow only `list` and `dict`, converting values of options here.
# Therefore, now we can only provide the dictionary itself
if type(options) == dict: options = list(options.values())
if sort: options = sorted(options) # As we pass only list and dict (converted to list), we can skip converting to list
if len(options) == 0:
- log(f" * Generic select didn't find any options to choose from * ", fg='red')
- log(" * If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues * ", fg='yellow')
+ log(' * Generic select didn\'t find any options to choose from * ', fg='red')
+ log('If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues', fg='yellow')
raise RequirementError('generic_select() requires at least one option to proceed.')
@@ -398,7 +391,7 @@ def select_language(options, show_only_country_codes=True):
new_options = list(search_keyboard_layout(filter_string))
if len(new_options) <= 0:
- log(f"Search string '{filter_string}' yielded no results, please try another search.", fg='yellow')
+ log(f"Search string '{filter_string}' yielded no results, please try another search", fg='yellow')
continue
return select_language(new_options, show_only_country_codes=False)
@@ -411,7 +404,7 @@ def select_language(options, show_only_country_codes=True):
elif verify_keyboard_layout(selected_language):
return selected_language
else:
- log(" * Given language wasn't found * ", fg='red')
+ log(' * Given language was not found * ', fg='red')
raise RequirementError("Selecting languages require a least one language to be given as an option.")