index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | jaybent <55739788+jaybent@users.noreply.github.com> | 2023-02-27 23:13:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-27 23:13:00 +0100 |
commit | f26b5308597273dfa182b89d265bcc59e057bd0e (patch) | |
tree | a066b9115de1c83656c64299f0471113157a3597 /archinstall/lib/general.py | |
parent | fa1bec9679b2b8a85f450e7dd8aa24dc7c22d848 (diff) |
-rw-r--r-- | archinstall/lib/general.py | 32 |
diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index 8c7aed91..bf32a9a8 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -185,12 +185,16 @@ class SysCommandWorker: def __init__(self, cmd :Union[str, List[str]], callbacks :Optional[Dict[str, Any]] = None, + peek_output :Optional[bool] = False, peak_output :Optional[bool] = False, environment_vars :Optional[Dict[str, Any]] = None, logfile :Optional[None] = None, working_directory :Optional[str] = './', remove_vt100_escape_codes_from_lines :bool = True): + if peak_output: + log("SysCommandWorker()'s peak_output is deprecated, use peek_output instead.", level=logging.WARNING, fg='red') + if not callbacks: callbacks = {} if not environment_vars: @@ -208,7 +212,9 @@ class SysCommandWorker: self.cmd = cmd self.callbacks = callbacks - self.peak_output = peak_output + self.peek_output = peek_output + if not self.peek_output and peak_output: + self.peek_output = peak_output # define the standard locale for command outputs. For now the C ascii one. Can be overridden self.environment_vars = {**storage.get('CMD_LOCALE',{}),**environment_vars} self.logfile = logfile @@ -262,7 +268,7 @@ class SysCommandWorker: except: pass - if self.peak_output: + if self.peek_output: # To make sure any peaked output didn't leave us hanging # on the same line we were on. sys.stdout.write("\n") @@ -307,7 +313,7 @@ class SysCommandWorker: self._trace_log_pos = min(max(0, pos), len(self._trace_log)) def peak(self, output: Union[str, bytes]) -> bool: - if self.peak_output: + if self.peek_output: if type(output) == bytes: try: output = output.decode('UTF-8') @@ -320,8 +326,8 @@ class SysCommandWorker: if peak_logfile.exists() is False: change_perm = True - with peak_logfile.open("a") as peak_output_log: - peak_output_log.write(output) + with peak_logfile.open("a") as peek_output_log: + peek_output_log.write(output) if change_perm: os.chmod(str(peak_logfile), stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) @@ -412,11 +418,15 @@ class SysCommand: cmd :Union[str, List[str]], callbacks :Optional[Dict[str, Callable[[Any], Any]]] = None, start_callback :Optional[Callable[[Any], Any]] = None, + peek_output :Optional[bool] = False, peak_output :Optional[bool] = False, environment_vars :Optional[Dict[str, Any]] = None, working_directory :Optional[str] = './', remove_vt100_escape_codes_from_lines :bool = True): + if peak_output: + log("SysCommandWorker()'s peak_output is deprecated, use peek_output instead.", level=logging.WARNING, fg='red') + _callbacks = {} if callbacks: for hook, func in callbacks.items(): @@ -426,7 +436,9 @@ class SysCommand: self.cmd = cmd self._callbacks = _callbacks - self.peak_output = peak_output + self.peek_output = peek_output + if not self.peek_output and peak_output: + self.peek_output = peak_output self.environment_vars = environment_vars self.working_directory = working_directory self.remove_vt100_escape_codes_from_lines = remove_vt100_escape_codes_from_lines @@ -469,7 +481,7 @@ class SysCommand: return { 'cmd': self.cmd, 'callbacks': self._callbacks, - 'peak': self.peak_output, + 'peak': self.peek_output, 'environment_vars': self.environment_vars, 'session': True if self.session else False } @@ -478,7 +490,7 @@ class SysCommand: """ Initiates a :ref:`SysCommandWorker` session in this class ``.session``. It then proceeds to poll the process until it ends, after which it also - clears any printed output if ``.peak_output=True``. + clears any printed output if ``.peek_output=True``. """ if self.session: return self.session @@ -486,7 +498,7 @@ class SysCommand: with SysCommandWorker( self.cmd, callbacks=self._callbacks, - peak_output=self.peak_output, + peek_output=self.peek_output, environment_vars=self.environment_vars, remove_vt100_escape_codes_from_lines=self.remove_vt100_escape_codes_from_lines, working_directory=self.working_directory) as session: @@ -497,7 +509,7 @@ class SysCommand: while self.session.ended is None: self.session.poll() - if self.peak_output: + if self.peek_output: sys.stdout.write('\n') sys.stdout.flush() |