index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Anton Hvornum <anton@hvornum.se> | 2021-09-06 16:42:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-06 16:42:31 +0200 |
commit | e39e49ecc73c327fbb2161a080a7f9b4eacafb21 (patch) | |
tree | 3ba3d199d010f8f87793b6bd37a459782ad318a7 /archinstall/lib/general.py | |
parent | 4505c3a11ff8a6bda21fc0d86a621b0cb86ee498 (diff) | |
parent | e10daf4c57b0aa6a8ce4677fc9375b6e8fbc84d0 (diff) |
-rw-r--r-- | archinstall/lib/general.py | 12 |
diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index 5200033a..1e8fc837 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -71,6 +71,8 @@ def locate_binary(name): raise RequirementError(f"Binary {name} does not exist.") +def json_dumps(*args, **kwargs): + return json.dumps(*args, **{**kwargs, 'cls': JSON}) class JsonEncoder: def _encode(obj): @@ -110,7 +112,6 @@ class JSON(json.JSONEncoder, json.JSONDecoder): def encode(self, obj): return super(JSON, self).encode(self._encode(obj)) - class SysCommandWorker: def __init__(self, cmd, callbacks=None, peak_output=False, environment_vars=None, logfile=None, working_directory='./'): if not callbacks: @@ -318,6 +319,15 @@ class SysCommand: for line in self.session: yield line + def __getitem__(self, key): + if type(key) is slice: + start = key.start if key.start else 0 + end = key.stop if key.stop else len(self.session._trace_log) + + return self.session._trace_log[start:end] + else: + raise ValueError("SysCommand() doesn't have key & value pairs, only slices, SysCommand('ls')[:10] as an example.") + def __repr__(self, *args, **kwargs): return self.session._trace_log.decode('UTF-8') |