Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
authorkpcyrd <git@rxv.cc>2021-04-02 20:03:38 +0200
committerkpcyrd <git@rxv.cc>2021-04-02 20:03:38 +0200
commit4221473e6782c659dbd1f2681b0d2e05a3aa54b6 (patch)
tree1d17670ad927f546bef16df540efacc6f874e1d1 /archinstall
parent0488c93a507fcb9e687b083ed8f11622d43ca9c2 (diff)
Support passing commands as lists
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/lib/disk.py8
-rw-r--r--archinstall/lib/general.py18
2 files changed, 17 insertions, 9 deletions
diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py
index 9ad49ac2..0f29a8bc 100644
--- a/archinstall/lib/disk.py
+++ b/archinstall/lib/disk.py
@@ -72,7 +72,7 @@ class BlockDevice():
raise DiskError(f'Could not locate backplane info for "{self.path}"')
if self.info['type'] == 'loop':
- for drive in json.loads(b''.join(sys_command(f'losetup --json', hide_from_log=True)).decode('UTF_8'))['loopdevices']:
+ for drive in json.loads(b''.join(sys_command(['losetup', '--json'], hide_from_log=True)).decode('UTF_8'))['loopdevices']:
if not drive['name'] == self.path: continue
return drive['back-file']
@@ -88,10 +88,10 @@ class BlockDevice():
@property
def partitions(self):
- o = b''.join(sys_command(f'partprobe {self.path}'))
+ o = b''.join(sys_command(['partprobe', self.path]))
#o = b''.join(sys_command('/usr/bin/lsblk -o name -J -b {dev}'.format(dev=dev)))
- o = b''.join(sys_command(f'/usr/bin/lsblk -J {self.path}'))
+ o = b''.join(sys_command(['/usr/bin/lsblk', '-J', self.path]))
if b'not a block device' in o:
raise DiskError(f'Can not read partitions off something that isn\'t a block device: {self.path}')
@@ -202,7 +202,7 @@ class Partition():
if not self._encrypted:
return self.path
else:
- for blockdevice in json.loads(b''.join(sys_command('lsblk -J')).decode('UTF-8'))['blockdevices']:
+ for blockdevice in json.loads(b''.join(sys_command(['lsblk', '-J'])).decode('UTF-8'))['blockdevices']:
if (parent := self.find_parent_of(blockdevice, os.path.basename(self.path))):
return f"/dev/{parent}"
# raise DiskError(f'Could not find appropriate parent for encrypted partition {self}')
diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py
index f2a714e7..ae2501c2 100644
--- a/archinstall/lib/general.py
+++ b/archinstall/lib/general.py
@@ -86,11 +86,19 @@ class sys_command():#Thread):
if kwargs['emulate']:
self.log(f"Starting command '{cmd}' in emulation mode.", level=LOG_LEVELS.Debug)
- self.raw_cmd = cmd
- try:
- self.cmd = shlex.split(cmd)
- except Exception as e:
- raise ValueError(f'Incorrect string to split: {cmd}\n{e}')
+ if type(cmd) is list:
+ # if we get a list of arguments
+ self.raw_cmd = shlex.join(cmd)
+ self.cmd = cmd
+ else:
+ # else consider it a single shell string
+ # this should only be used if really necessary
+ self.raw_cmd = cmd
+ try:
+ self.cmd = shlex.split(cmd)
+ except Exception as e:
+ raise ValueError(f'Incorrect string to split: {cmd}\n{e}')
+
self.args = args
self.kwargs = kwargs