Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorWerner Llácer <wllacer@gmail.com>2022-02-05 13:52:14 +0100
committerGitHub <noreply@github.com>2022-02-05 13:52:14 +0100
commitec73bdab4cf124aba16e10293e5e75a3bc89afb8 (patch)
tree1863b408806c853d92c2553e46f3f303bbc01338 /examples
parent0ec9549dc49a05c5059e34926d366dadfb3aa5b8 (diff)
Routine to properly print and save config data (#888)
* Created a standard function to show/save the config parameters * flake8 complains * Correct definition of btrfs standard layout * Solve issue #936 * Moved output_configs to lib/configuration.py
Diffstat (limited to 'examples')
-rw-r--r--examples/guided.py55
-rw-r--r--examples/only_hd.py51
2 files changed, 11 insertions, 95 deletions
diff --git a/examples/guided.py b/examples/guided.py
index e14e58cf..a775da84 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -1,4 +1,3 @@
-import json
import logging
import os
import time
@@ -91,52 +90,7 @@ def ask_user_questions():
global_menu.run()
-def save_user_configurations():
- user_credentials = {}
- if archinstall.arguments.get('!users'):
- user_credentials["!users"] = archinstall.arguments['!users']
- if archinstall.arguments.get('!superusers'):
- user_credentials["!superusers"] = archinstall.arguments['!superusers']
- if archinstall.arguments.get('!encryption-password'):
- user_credentials["!encryption-password"] = archinstall.arguments['!encryption-password']
-
- user_configuration = json.dumps({
- 'config_version': archinstall.__version__, # Tells us what version was used to generate the config
- **archinstall.arguments, # __version__ will be overwritten by old version definition found in config
- 'version': archinstall.__version__
- } , indent=4, sort_keys=True, cls=archinstall.JSON)
-
- with open("/var/log/archinstall/user_credentials.json", "w") as config_file:
- config_file.write(json.dumps(user_credentials, indent=4, sort_keys=True, cls=archinstall.UNSAFE_JSON))
-
- with open("/var/log/archinstall/user_configuration.json", "w") as config_file:
- config_file.write(user_configuration)
-
- if archinstall.arguments.get('disk_layouts'):
- user_disk_layout = json.dumps(archinstall.arguments['disk_layouts'], indent=4, sort_keys=True, cls=archinstall.JSON)
- with open("/var/log/archinstall/user_disk_layout.json", "w") as disk_layout_file:
- disk_layout_file.write(user_disk_layout)
-
def perform_filesystem_operations():
- print()
- print('This is your chosen configuration:')
- archinstall.log("-- Guided template chosen (with below config) --", level=logging.DEBUG)
-
- user_configuration = json.dumps({**archinstall.arguments, 'version' : archinstall.__version__} , indent=4, sort_keys=True, cls=archinstall.JSON)
- archinstall.log(user_configuration, level=logging.INFO)
-
- if archinstall.arguments.get('disk_layouts'):
- user_disk_layout = json.dumps(archinstall.arguments['disk_layouts'], indent=4, sort_keys=True, cls=archinstall.JSON)
- archinstall.log(user_disk_layout, level=logging.INFO)
-
- print()
-
- if archinstall.arguments.get('dry_run'):
- exit(0)
-
- if not archinstall.arguments.get('silent'):
- input('Press Enter to continue.')
-
"""
Issue a final warning before we continue with something un-revertable.
We mention the drive one last time, and count from 5 to 0.
@@ -300,6 +254,13 @@ if not archinstall.arguments.get('offline', False):
if not archinstall.arguments.get('silent'):
ask_user_questions()
-save_user_configurations()
+archinstall.output_configs(archinstall.arguments,show=False if archinstall.arguments.get('silent') else True)
+
+if archinstall.arguments.get('dry_run'):
+ exit(0)
+
+if not archinstall.arguments.get('silent'):
+ input('Press Enter to continue.')
+
perform_filesystem_operations()
perform_installation(archinstall.storage.get('MOUNT_POINT', '/mnt'))
diff --git a/examples/only_hd.py b/examples/only_hd.py
index f1bddbb2..7195d810 100644
--- a/examples/only_hd.py
+++ b/examples/only_hd.py
@@ -1,4 +1,3 @@
-import json
import logging
import os
import pathlib
@@ -49,52 +48,6 @@ def ask_user_questions():
"""
ask_harddrives()
-def save_user_configurations():
- user_credentials = {}
- if archinstall.arguments.get('!users'):
- user_credentials["!users"] = archinstall.arguments['!users']
- if archinstall.arguments.get('!superusers'):
- user_credentials["!superusers"] = archinstall.arguments['!superusers']
- if archinstall.arguments.get('!encryption-password'):
- user_credentials["!encryption-password"] = archinstall.arguments['!encryption-password']
-
- user_configuration = json.dumps({
- 'config_version': archinstall.__version__, # Tells us what version was used to generate the config
- **archinstall.arguments, # __version__ will be overwritten by old version definition found in config
- 'version': archinstall.__version__
- } , indent=4, sort_keys=True, cls=archinstall.JSON)
-
- with open("/var/log/archinstall/user_credentials.json", "w") as config_file:
- config_file.write(json.dumps(user_credentials, indent=4, sort_keys=True, cls=archinstall.UNSAFE_JSON))
-
- with open("/var/log/archinstall/user_configuration.json", "w") as config_file:
- config_file.write(user_configuration)
-
- if archinstall.arguments.get('disk_layouts'):
- user_disk_layout = json.dumps(archinstall.arguments['disk_layouts'], indent=4, sort_keys=True, cls=archinstall.JSON)
- with open("/var/log/archinstall/user_disk_layout.json", "w") as disk_layout_file:
- disk_layout_file.write(user_disk_layout)
-
-
-def write_config_files():
- print()
- print('This is your chosen configuration:')
- archinstall.log("-- Guided template chosen (with below config) --", level=logging.DEBUG)
-
- user_configuration = json.dumps({**archinstall.arguments, 'version' : archinstall.__version__} , indent=4, sort_keys=True, cls=archinstall.JSON)
- archinstall.log(user_configuration, level=logging.INFO)
-
- if archinstall.arguments.get('disk_layouts'):
- user_disk_layout = json.dumps(archinstall.arguments['disk_layouts'], indent=4, sort_keys=True, cls=archinstall.JSON)
- archinstall.log(user_disk_layout, level=logging.INFO)
-
- print()
-
- save_user_configurations()
- if archinstall.arguments.get('dry_run'):
- exit(0)
-
-
def perform_disk_operations():
"""
Issue a final warning before we continue with something un-revertable.
@@ -170,9 +123,11 @@ if not archinstall.check_mirror_reachable():
if not archinstall.arguments.get('silent'):
ask_user_questions()
+archinstall.output_configs(archinstall.arguments,show=False if archinstall.arguments.get('silent') else True)
+if archinstall.arguments.get('dry_run'):
+ exit(0)
if not archinstall.arguments.get('silent'):
- write_config_files()
input('Press Enter to continue.')
perform_disk_operations()