Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/examples/guided.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds+github@gmail.com>2020-11-04 22:41:50 +0100
committerAnton Hvornum <anton.feeds+github@gmail.com>2020-11-04 22:41:50 +0100
commitb98850819bdbdb23e354bb5bf5d5383cf807d22d (patch)
tree8c2f5138612e532837dedfefc2832bd14b519abe /examples/guided.py
parente06ca749a4382c37350d36cf08aa3fa5369ce9e2 (diff)
Added multiple log features.
* [Reintroduced](https://github.com/Torxed/archinstall/blob/f64a605449f59c677dff39962f1cb46616d893b7/archinstall.py#L57-L71) log levels * Created a global log file definition * Optional support for `python-systemd`'s journald handler. * Optional file output that has a globally configurable definition, that archinstall will honor in `archinstall.storage['logfile']`.
Diffstat (limited to 'examples/guided.py')
-rw-r--r--examples/guided.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/examples/guided.py b/examples/guided.py
index 70c2050d..ee57e2b5 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -1,5 +1,13 @@
+import getpass, time, json, sys, signal, os
import archinstall
-import getpass, time, json, sys, signal
+
+# Setup a global log file.
+# Archinstall will honor storage['logfile'] in most of it's functions log handle.
+log_root = os.path.join(os.path.expanduser('~/'), '.cache/archinstall')
+if not os.path.isdir(log_root):
+ os.makedirs(log_root)
+
+archinstall.storage['logfile'] = f"{log_root}/install-session_{self.init_time}.{self.milliseconds}.log"
"""
This signal-handler chain (and global variable)
@@ -29,7 +37,7 @@ def perform_installation(device, boot_partition, language, mirrors):
# Certain services might be running that affects the system during installation.
# Currently, only one such service is "reflector.service" which updates /etc/pacman.d/mirrorlist
# We need to wait for it before we continue since we opted in to use a custom mirror/region.
- archinstall.log(f'Waiting for automatic mirror selection has completed before using custom mirrors.')
+ installation.log(f'Waiting for automatic mirror selection has completed before using custom mirrors.')
while 'dead' not in (status := archinstall.service_state('reflector')):
time.sleep(1)
@@ -136,6 +144,9 @@ while 1:
if type(profile) != str: # Got a imported profile
archinstall.storage['_guided']['profile'] = profile[0] # The second return is a module, and not a handle/object.
if not profile[1]._prep_function():
+ # TODO: See how we can incorporate this into
+ # the general log flow. As this is pre-installation
+ # session setup. Which creates the installation.log file.
archinstall.log(
' * Profile\'s preparation requirements was not fulfilled.',
bg='black',