source code improvement
This commit is contained in:
parent
5ec690da93
commit
91d030a09c
|
|
@ -136,7 +136,7 @@ class Partition:
|
||||||
@property
|
@property
|
||||||
def partition_type(self):
|
def partition_type(self):
|
||||||
lsblk = json.loads(SysCommand(f"lsblk --json -o+PTTYPE {self.path}").decode('UTF-8'))
|
lsblk = json.loads(SysCommand(f"lsblk --json -o+PTTYPE {self.path}").decode('UTF-8'))
|
||||||
|
|
||||||
for device in lsblk['blockdevices']:
|
for device in lsblk['blockdevices']:
|
||||||
return device['pttype']
|
return device['pttype']
|
||||||
|
|
||||||
|
|
@ -153,7 +153,7 @@ class Partition:
|
||||||
partuuid_struct = SysCommand(f'lsblk -J -o+PARTUUID {self.path}')
|
partuuid_struct = SysCommand(f'lsblk -J -o+PARTUUID {self.path}')
|
||||||
if partuuid_struct.exit_code == 0:
|
if partuuid_struct.exit_code == 0:
|
||||||
if partition_information := next(iter(json.loads(partuuid_struct.decode('UTF-8'))['blockdevices']), None):
|
if partition_information := next(iter(json.loads(partuuid_struct.decode('UTF-8'))['blockdevices']), None):
|
||||||
if (partuuid := partition_information.get('partuuid', None)):
|
if partuuid := partition_information.get('partuuid', None):
|
||||||
return partuuid
|
return partuuid
|
||||||
|
|
||||||
time.sleep(storage['DISK_TIMEOUTS'])
|
time.sleep(storage['DISK_TIMEOUTS'])
|
||||||
|
|
@ -172,7 +172,7 @@ class Partition:
|
||||||
partuuid_struct = SysCommand(f'lsblk -J -o+PARTUUID {self.path}')
|
partuuid_struct = SysCommand(f'lsblk -J -o+PARTUUID {self.path}')
|
||||||
if partuuid_struct.exit_code == 0:
|
if partuuid_struct.exit_code == 0:
|
||||||
if partition_information := next(iter(json.loads(partuuid_struct.decode('UTF-8'))['blockdevices']), None):
|
if partition_information := next(iter(json.loads(partuuid_struct.decode('UTF-8'))['blockdevices']), None):
|
||||||
if (partuuid := partition_information.get('partuuid', None)):
|
if partuuid := partition_information.get('partuuid', None):
|
||||||
return partuuid
|
return partuuid
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
@ -296,7 +296,7 @@ class Partition:
|
||||||
|
|
||||||
elif filesystem == 'f2fs':
|
elif filesystem == 'f2fs':
|
||||||
options = ['-f'] + options
|
options = ['-f'] + options
|
||||||
|
|
||||||
if (handle := SysCommand(f"/usr/bin/mkfs.f2fs {' '.join(options)} {path}")).exit_code != 0:
|
if (handle := SysCommand(f"/usr/bin/mkfs.f2fs {' '.join(options)} {path}")).exit_code != 0:
|
||||||
raise DiskError(f"Could not format {path} with {filesystem} because: {handle.decode('UTF-8')}")
|
raise DiskError(f"Could not format {path} with {filesystem} because: {handle.decode('UTF-8')}")
|
||||||
self.filesystem = filesystem
|
self.filesystem = filesystem
|
||||||
|
|
@ -378,7 +378,7 @@ class Partition:
|
||||||
try:
|
try:
|
||||||
self.format(self.filesystem, '/dev/null', log_formatting=False, allow_formatting=True)
|
self.format(self.filesystem, '/dev/null', log_formatting=False, allow_formatting=True)
|
||||||
except (SysCallError, DiskError):
|
except (SysCallError, DiskError):
|
||||||
pass # We supported it, but /dev/null is not formatable as expected so the mkfs call exited with an error code
|
pass # We supported it, but /dev/null is not formattable as expected so the mkfs call exited with an error code
|
||||||
except UnknownFilesystemFormat as err:
|
except UnknownFilesystemFormat as err:
|
||||||
raise err
|
raise err
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ def json_dumps(*args, **kwargs):
|
||||||
return json.dumps(*args, **{**kwargs, 'cls': JSON})
|
return json.dumps(*args, **{**kwargs, 'cls': JSON})
|
||||||
|
|
||||||
class JsonEncoder:
|
class JsonEncoder:
|
||||||
|
@staticmethod
|
||||||
def _encode(obj):
|
def _encode(obj):
|
||||||
"""
|
"""
|
||||||
This JSON encoder function will try it's best to convert
|
This JSON encoder function will try it's best to convert
|
||||||
|
|
@ -112,6 +113,7 @@ class JsonEncoder:
|
||||||
else:
|
else:
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def _unsafe_encode(obj):
|
def _unsafe_encode(obj):
|
||||||
"""
|
"""
|
||||||
Same as _encode() but it keeps dictionary keys starting with !
|
Same as _encode() but it keeps dictionary keys starting with !
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ class LogLevels:
|
||||||
|
|
||||||
|
|
||||||
class Journald(dict):
|
class Journald(dict):
|
||||||
|
@staticmethod
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def log(message, level=logging.DEBUG):
|
def log(message, level=logging.DEBUG):
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ def ask_user_questions():
|
||||||
|
|
||||||
# Get disk encryption password (or skip if blank)
|
# Get disk encryption password (or skip if blank)
|
||||||
if archinstall.arguments['harddrives'] and archinstall.arguments.get('!encryption-password', None) is None:
|
if archinstall.arguments['harddrives'] and archinstall.arguments.get('!encryption-password', None) is None:
|
||||||
if (passwd := archinstall.get_password(prompt='Enter disk encryption password (leave blank for no encryption): ')):
|
if passwd := archinstall.get_password(prompt='Enter disk encryption password (leave blank for no encryption): '):
|
||||||
archinstall.arguments['!encryption-password'] = passwd
|
archinstall.arguments['!encryption-password'] = passwd
|
||||||
|
|
||||||
if archinstall.arguments['harddrives'] and archinstall.arguments.get('!encryption-password', None):
|
if archinstall.arguments['harddrives'] and archinstall.arguments.get('!encryption-password', None):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue