Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jip-Hop committed Jul 9, 2024
1 parent 29cb1ee commit 414df22
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions jlmkr.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ def __init__(self, *args, **kwargs):
# Template to store comments as key value pair
self._comment_template = "#{0} " + delimiter + " {1}"
# Regex to match the comment prefix
self._comment_regex = re.compile(r"^#\d+\s*" + re.escape(delimiter) + r"[^\S\n]*")
self._comment_regex = re.compile(
r"^#\d+\s*" + re.escape(delimiter) + r"[^\S\n]*"
)
# Regex to match cosmetic newlines (skips newlines in multiline values):
# consecutive whitespace from start of line followed by a line not starting with whitespace
self._cosmetic_newlines_regex = re.compile(r"^(\s+)(?=^\S)", re.MULTILINE)
Expand Down Expand Up @@ -538,7 +540,8 @@ def systemd_escape_path(path):
"""
return "".join(
map(
lambda char: r"\s" if char == " " else "\\\\" if char == "\\" else char, path
lambda char: r"\s" if char == " " else "\\\\" if char == "\\" else char,
path,
)
)

Expand Down Expand Up @@ -881,7 +884,6 @@ def run_lxc_download_script(
f"--release={release}",
]


if rc := subprocess.run(cmd, env={"LXC_CACHE_PATH": lxc_cache}).returncode != 0:
eprint("Aborting...")
return rc
Expand All @@ -902,7 +904,7 @@ def run_lxc_download_script(
line,
):
print(line)

rc = p1.wait()
# Currently --list will always return a non-zero exit code, even when listing the images was successful
# https://github.com/lxc/lxc/pull/4462
Expand Down Expand Up @@ -945,9 +947,11 @@ def get_mount_point(path):
path = os.path.dirname(path)
return path

def get_relative_path_in_jailmaker_dir(absolute_path):

def get_relative_path_in_jailmaker_dir(absolute_path):
return PurePath(absolute_path).relative_to(SCRIPT_DIR_PATH)


def get_zfs_dataset(path):
"""
Get ZFS dataset path.
Expand Down Expand Up @@ -1285,10 +1289,14 @@ def create_jail(**kwargs):
if jail_config_path:
# TODO: fallback to default values for e.g. distro and release if they are not in the config file
if jail_config_path == "-":
print(f"Creating jail {jail_name} from config template passed via stdin.")
print(
f"Creating jail {jail_name} from config template passed via stdin."
)
config.read_string(sys.stdin.read())
else:
print(f"Creating jail {jail_name} from config template {jail_config_path}.")
print(
f"Creating jail {jail_name} from config template {jail_config_path}."
)
if jail_config_path not in config.read(jail_config_path):
eprint(f"Failed to read config template {jail_config_path}.")
return 1
Expand Down Expand Up @@ -1362,9 +1370,12 @@ def create_jail(**kwargs):
# but we don't need it so we will remove it later
open(jail_config_path, "a").close()

if returncode := run_lxc_download_script(
jail_name, jail_path, jail_rootfs_path, distro, release
) != 0:
if (
returncode := run_lxc_download_script(
jail_name, jail_path, jail_rootfs_path, distro, release
)
!= 0
):
cleanup(jail_path)
return returncode

Expand Down

0 comments on commit 414df22

Please sign in to comment.