Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2021-09-15 19:01:14 +0200
committerAnton Hvornum <anton@hvornum.se>2021-09-15 19:01:14 +0200
commitd6acfec799280b764bf50e1623fb4608cc9a7742 (patch)
tree8bf9c2653e79b60911954988aff5f0cca9150a84
parent8dd097da0524d8a3e2d784ab7821a08e051b82cf (diff)
Updating support for --disk_layouts. It now supports file paths as well as JSON in string format via --disk_layouts=<json>
-rw-r--r--examples/guided.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/examples/guided.py b/examples/guided.py
index 0813e2ef..a3c0db2d 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -1,6 +1,7 @@
import json
import logging
import os
+import pathlib
import time
import archinstall
@@ -52,6 +53,14 @@ def load_config():
if archinstall.arguments.get('servers', None) is not None:
archinstall.storage['_selected_servers'] = archinstall.arguments.get('servers', None)
if archinstall.arguments.get('disk_layouts', None) is not None:
+ if (dl_path := pathlib.Path(archinstall.arguments['disk_layouts'])).exists() and str(dl_path).endswith('.json'):
+ with open(dl_path) as fh:
+ archinstall.arguments['disk_layouts'] = json.load(fh)
+ else:
+ try:
+ archinstall.arguments['disk_layouts'] = json.loads(archinstall.arguments['disk_layouts'])
+ except:
+ raise ValueError("--disk_layouts=<json> needs either a JSON file or a JSON string given with a valid disk layout.")
archinstall.storage['disk_layouts'] = {archinstall.BlockDevice(disk) : struct for disk, struct in archinstall.arguments['disk_layouts']}