Tweaked logging slightly.
This commit is contained in:
parent
c5694393c6
commit
1ef63147d0
|
|
@ -7,6 +7,7 @@ from .storage import storage
|
||||||
|
|
||||||
ROOT_DIR_PATTERN = re.compile('^.*?/devices')
|
ROOT_DIR_PATTERN = re.compile('^.*?/devices')
|
||||||
GPT = 0b00000001
|
GPT = 0b00000001
|
||||||
|
MBR = 0b00000010
|
||||||
|
|
||||||
#import ctypes
|
#import ctypes
|
||||||
#import ctypes.util
|
#import ctypes.util
|
||||||
|
|
@ -113,6 +114,10 @@ class BlockDevice():
|
||||||
all_partitions = self.partitions
|
all_partitions = self.partitions
|
||||||
return [all_partitions[k] for k in all_partitions]
|
return [all_partitions[k] for k in all_partitions]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def partition_table_type(self):
|
||||||
|
return GPT
|
||||||
|
|
||||||
def has_partitions(self):
|
def has_partitions(self):
|
||||||
return len(self.partitions)
|
return len(self.partitions)
|
||||||
|
|
||||||
|
|
@ -272,15 +277,21 @@ class Filesystem():
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
|
|
||||||
def __enter__(self, *args, **kwargs):
|
def __enter__(self, *args, **kwargs):
|
||||||
#if self.mode == GPT:
|
if self.blockdevice.keep_partitions is False:
|
||||||
# if sys_command(f'/usr/bin/parted -s {self.blockdevice.device} mklabel gpt',).exit_code == 0:
|
log(f'Wiping {self.blockdevice} by using partition format {self.mode}', level=LOG_LEVELS.Debug)
|
||||||
# return self
|
if self.mode == GPT:
|
||||||
# else:
|
if sys_command(f'/usr/bin/parted -s {self.blockdevice.device} mklabel gpt',).exit_code == 0:
|
||||||
# raise DiskError(f'Problem setting the partition format to GPT:', f'/usr/bin/parted -s {self.blockdevice.device} mklabel gpt')
|
return self
|
||||||
#else:
|
else:
|
||||||
# raise DiskError(f'Unknown mode selected to format in: {self.mode}')
|
raise DiskError(f'Problem setting the partition format to GPT:', f'/usr/bin/parted -s {self.blockdevice.device} mklabel gpt')
|
||||||
print(type(self.blockdevice))
|
else:
|
||||||
print('Keep partitions:', self.blockdevice.keep_partitions)
|
raise DiskError(f'Unknown mode selected to format in: {self.mode}')
|
||||||
|
|
||||||
|
# TODO: partition_table_type is hardcoded to GPT at the moment. This has to be changed.
|
||||||
|
elif self.mode == self.blockdevice.partition_table_type:
|
||||||
|
log(f'Kept partition format {self.mode} for {self.blockdevice}', level=LOG_LEVELS.Debug)
|
||||||
|
else:
|
||||||
|
raise DiskError(f'The selected partition table format {self.mode} does not match that of {self.blockdevice}.')
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"Filesystem(blockdevice={self.blockdevice}, mode={self.mode})"
|
return f"Filesystem(blockdevice={self.blockdevice}, mode={self.mode})"
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from .storage import storage
|
from .storage import storage
|
||||||
|
|
||||||
|
# TODO: use logging's built in levels instead.
|
||||||
|
# Altough logging is threaded and I wish to avoid that.
|
||||||
|
# It's more Pythonistic or w/e you want to call it.
|
||||||
class LOG_LEVELS:
|
class LOG_LEVELS:
|
||||||
Critical = 0b001
|
Critical = 0b001
|
||||||
Error = 0b010
|
Error = 0b010
|
||||||
|
|
@ -108,10 +111,10 @@ def log(*args, **kwargs):
|
||||||
# In that case, we'll drop it.
|
# In that case, we'll drop it.
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
journald.log(string, level=kwargs['level'])
|
journald.log(string, level=kwargs.get('level', LOG_LEVELS.Info))
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
pass # Ignore writing to journald
|
pass # Ignore writing to journald
|
||||||
|
|
||||||
# Finally, print the log unless we skipped it based on level.
|
# Finally, print the log unless we skipped it based on level.
|
||||||
# We use sys.stdout.write()+flush() instead of print() to try and
|
# We use sys.stdout.write()+flush() instead of print() to try and
|
||||||
|
|
|
||||||
|
|
@ -271,8 +271,6 @@ signal.signal(signal.SIGINT, original_sigint_handler)
|
||||||
Once that's done, we'll hand over to perform_installation()
|
Once that's done, we'll hand over to perform_installation()
|
||||||
"""
|
"""
|
||||||
with archinstall.Filesystem(archinstall.arguments['harddrive'], archinstall.GPT) as fs:
|
with archinstall.Filesystem(archinstall.arguments['harddrive'], archinstall.GPT) as fs:
|
||||||
print('Debug')
|
|
||||||
exit(0)
|
|
||||||
# Use partitioning helper to set up the disk partitions.
|
# Use partitioning helper to set up the disk partitions.
|
||||||
if disk_password:
|
if disk_password:
|
||||||
fs.use_entire_disk('luks2')
|
fs.use_entire_disk('luks2')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue