Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/general.py
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib/general.py')
-rw-r--r--archinstall/lib/general.py12
1 files changed, 11 insertions, 1 deletions
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')