Ruff format and sort imports
This commit is contained in:
parent
889f4791d3
commit
00fb155c74
|
@ -19,7 +19,6 @@ import sys
|
|||
|
||||
from cli import main
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
sys.exit(main())
|
||||
|
|
|
@ -5,30 +5,30 @@
|
|||
import contextlib
|
||||
import os
|
||||
import sys
|
||||
|
||||
from inspect import cleandoc
|
||||
from pathlib import Path, PurePath
|
||||
from textwrap import dedent
|
||||
|
||||
from actions.start import start_jail
|
||||
from cli import DISCLAIMER
|
||||
from paths import COMMAND_NAME, JAILS_DIR_PATH, SCRIPT_NAME, SCRIPT_DIR_PATH
|
||||
from paths import COMMAND_NAME, JAILS_DIR_PATH, SCRIPT_DIR_PATH, SCRIPT_NAME
|
||||
from utils.chroot import Chroot
|
||||
from utils.config_parser import KeyValueParser, DEFAULT_CONFIG
|
||||
from utils.console import YELLOW, BOLD, NORMAL, eprint
|
||||
from utils.config_parser import DEFAULT_CONFIG, KeyValueParser
|
||||
from utils.console import BOLD, NORMAL, YELLOW, eprint
|
||||
from utils.dataset import create_zfs_dataset, get_zfs_dataset
|
||||
from utils.download import run_lxc_download_script
|
||||
from utils.files import stat_chmod, get_mount_point
|
||||
from utils.files import get_mount_point, stat_chmod
|
||||
from utils.jail import (
|
||||
check_jail_name_valid,
|
||||
check_jail_name_available,
|
||||
check_jail_name_valid,
|
||||
cleanup,
|
||||
get_jail_config_path,
|
||||
get_jail_rootfs_path,
|
||||
get_jail_path,
|
||||
get_jail_rootfs_path,
|
||||
)
|
||||
from utils.dataset import get_zfs_dataset, create_zfs_dataset
|
||||
from utils.jail import cleanup
|
||||
from utils.os_release import parse_os_release
|
||||
|
||||
from actions.start import start_jail
|
||||
|
||||
|
||||
def create_jail(**kwargs):
|
||||
print(DISCLAIMER)
|
||||
|
|
|
@ -5,9 +5,13 @@
|
|||
import subprocess
|
||||
|
||||
from utils.console import eprint
|
||||
from utils.jail import check_jail_name_valid, check_jail_name_available
|
||||
from utils.jail import get_jail_config_path, jail_is_running
|
||||
from utils.editor import get_text_editor
|
||||
from utils.jail import (
|
||||
check_jail_name_available,
|
||||
check_jail_name_valid,
|
||||
get_jail_config_path,
|
||||
jail_is_running,
|
||||
)
|
||||
|
||||
|
||||
def edit_jail(jail_name):
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
from utils.config_parser import parse_config_file
|
||||
from utils.console import eprint, NORMAL, UNDERLINE
|
||||
from utils.console import NORMAL, UNDERLINE, eprint
|
||||
from utils.jail import get_all_jail_names, get_jail_config_path, get_jail_rootfs_path
|
||||
from utils.os_release import parse_os_release
|
||||
|
||||
|
|
|
@ -2,15 +2,16 @@
|
|||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-only
|
||||
|
||||
from actions.stop import stop_jail
|
||||
from utils.console import eprint
|
||||
from utils.jail import (
|
||||
check_jail_name_valid,
|
||||
check_jail_name_available,
|
||||
get_jail_path,
|
||||
check_jail_name_valid,
|
||||
cleanup,
|
||||
get_jail_path,
|
||||
)
|
||||
|
||||
from actions.stop import stop_jail
|
||||
|
||||
|
||||
def remove_jail(jail_name):
|
||||
"""
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-only
|
||||
|
||||
from utils.console import eprint
|
||||
|
||||
from actions.start import start_jail
|
||||
from actions.stop import stop_jail
|
||||
from utils.console import eprint
|
||||
|
||||
|
||||
def restart_jail(jail_name):
|
||||
|
|
|
@ -6,22 +6,22 @@ import os.path
|
|||
import shlex
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
from pathlib import Path
|
||||
from textwrap import dedent
|
||||
|
||||
from actions.exec import exec_jail
|
||||
from paths import COMMAND_NAME, SHORTNAME, JAIL_ROOTFS_NAME
|
||||
from paths import COMMAND_NAME, JAIL_ROOTFS_NAME, SHORTNAME
|
||||
from utils.config_parser import parse_config_file
|
||||
from utils.console import eprint, RED, BOLD, NORMAL
|
||||
from utils.jail import (
|
||||
get_jail_path,
|
||||
jail_is_running,
|
||||
get_jail_config_path,
|
||||
get_jail_rootfs_path,
|
||||
)
|
||||
from utils.console import BOLD, NORMAL, RED, eprint
|
||||
from utils.files import stat_chmod
|
||||
from utils.gpu import passthrough_intel, passthrough_nvidia
|
||||
from utils.jail import (
|
||||
get_jail_config_path,
|
||||
get_jail_path,
|
||||
get_jail_rootfs_path,
|
||||
jail_is_running,
|
||||
)
|
||||
|
||||
from actions.exec import exec_jail
|
||||
|
||||
|
||||
def start_jail(jail_name):
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-only
|
||||
|
||||
from actions.start import start_jail
|
||||
from utils.config_parser import parse_config_file
|
||||
from utils.jail import get_all_jail_names, get_jail_config_path
|
||||
|
||||
from actions.start import start_jail
|
||||
|
||||
|
||||
def startup_jails():
|
||||
start_failure = False
|
||||
|
|
|
@ -6,14 +6,6 @@ import argparse
|
|||
import os
|
||||
import sys
|
||||
|
||||
from __main__ import __version__
|
||||
from data import DISCLAIMER
|
||||
from paths import SCRIPT_PATH, COMMAND_NAME, SCRIPT_NAME
|
||||
from utils.config_parser import ExceptionWithParser
|
||||
from utils.console import fail
|
||||
from utils.editor import get_text_editor
|
||||
from utils.files import stat_chmod
|
||||
|
||||
from actions.create import create_jail
|
||||
from actions.edit import edit_jail
|
||||
from actions.exec import exec_jail
|
||||
|
@ -27,14 +19,22 @@ from actions.start import start_jail
|
|||
from actions.startup import startup_jails
|
||||
from actions.status import status_jail
|
||||
from actions.stop import stop_jail
|
||||
from data import DISCLAIMER
|
||||
from paths import COMMAND_NAME, SCRIPT_NAME, SCRIPT_PATH
|
||||
from utils.config_parser import ExceptionWithParser
|
||||
from utils.console import fail
|
||||
from utils.editor import get_text_editor
|
||||
from utils.files import stat_chmod
|
||||
|
||||
from __main__ import __version__
|
||||
|
||||
|
||||
def main():
|
||||
if os.stat(SCRIPT_PATH).st_uid != 0:
|
||||
if os.environ.get('JLMKR_DEBUG') is None:
|
||||
fail(
|
||||
f"This script should be owned by the root user... Fix it manually with: `chown root {SCRIPT_PATH}`."
|
||||
)
|
||||
if os.environ.get("JLMKR_DEBUG") is None:
|
||||
fail(
|
||||
f"This script should be owned by the root user... Fix it manually with: `chown root {SCRIPT_PATH}`."
|
||||
)
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description=__doc__,
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-only
|
||||
|
||||
from __main__ import __disclaimer__
|
||||
from utils.console import YELLOW, BOLD, NORMAL
|
||||
from utils.console import BOLD, NORMAL, YELLOW
|
||||
|
||||
from __main__ import __disclaimer__
|
||||
|
||||
DISCLAIMER = f"""{YELLOW}{BOLD}{__disclaimer__}{NORMAL}"""
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
import os.path
|
||||
|
||||
|
||||
# When running as a zipapp, the script file is a parent
|
||||
ZIPAPP_PATH = os.path.realpath(__file__)
|
||||
while not os.path.exists(ZIPAPP_PATH):
|
||||
|
|
|
@ -7,8 +7,8 @@ import io
|
|||
import re
|
||||
|
||||
from data import DEFAULT_CONFIG
|
||||
from utils.console import eprint
|
||||
|
||||
from utils.console import eprint
|
||||
|
||||
# Used in parser getters to indicate the default behavior when a specific
|
||||
# option is not found. Created to enable `None` as a valid fallback value.
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
import sys
|
||||
|
||||
|
||||
# Only set a color if we have an interactive tty
|
||||
if sys.stdout.isatty():
|
||||
BOLD = "\033[1m"
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-only
|
||||
|
||||
from pathlib import PurePath
|
||||
from paths import SCRIPT_DIR_PATH
|
||||
from utils.console import eprint, fail
|
||||
import os.path
|
||||
import subprocess
|
||||
from pathlib import PurePath
|
||||
|
||||
from paths import SCRIPT_DIR_PATH
|
||||
|
||||
from utils.console import eprint, fail
|
||||
|
||||
|
||||
def _get_relative_path_in_jailmaker_dir(absolute_path):
|
||||
|
|
|
@ -11,7 +11,6 @@ import urllib.request
|
|||
from utils.console import eprint
|
||||
from utils.files import stat_chmod
|
||||
|
||||
|
||||
DOWNLOAD_SCRIPT_DIGEST = (
|
||||
"cfcb5d08b24187d108f2ab0d21a6cc4b73dcd7f5d7dfc80803bfd7f1642d638d"
|
||||
)
|
||||
|
|
|
@ -4,15 +4,14 @@
|
|||
|
||||
import os.path
|
||||
import subprocess
|
||||
|
||||
from pathlib import Path
|
||||
from textwrap import dedent
|
||||
|
||||
from paths import SHORTNAME
|
||||
|
||||
from utils.console import eprint
|
||||
from utils.jail import get_jail_rootfs_path
|
||||
|
||||
|
||||
# Test intel GPU by decoding mp4 file (output is discarded)
|
||||
# Run the commands below in the jail:
|
||||
# curl -o bunny.mp4 https://www.w3schools.com/html/mov_bbb.mp4
|
||||
|
|
|
@ -9,6 +9,7 @@ from utils.chroot import Chroot
|
|||
|
||||
def parse_os_release(new_root):
|
||||
result = {}
|
||||
|
||||
with Chroot(new_root):
|
||||
# Use chroot to correctly resolve os-release symlink (for nixos)
|
||||
for candidate in ["/etc/os-release", "/usr/lib/os-release"]:
|
||||
|
|
Loading…
Reference in New Issue