fixed symlinc resolving
This commit is contained in:
parent
d968795628
commit
8036dc33b3
@ -8,6 +8,7 @@ import argparse
|
|||||||
|
|
||||||
from .responses import compile_config
|
from .responses import compile_config
|
||||||
from .static import IS_VENV, VENV_DIRECTORY, CONFIG_DIRECTORY, COMPILED_CONFIG_FILE_NAME
|
from .static import IS_VENV, VENV_DIRECTORY, CONFIG_DIRECTORY, COMPILED_CONFIG_FILE_NAME
|
||||||
|
from ntpath import devnull
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format='%(message)s',
|
format='%(message)s',
|
||||||
@ -108,12 +109,11 @@ def write_compile_config(local: bool):
|
|||||||
(VENV_DIRECTORY / COMPILED_CONFIG_FILE_NAME).unlink(missing_ok=True)
|
(VENV_DIRECTORY / COMPILED_CONFIG_FILE_NAME).unlink(missing_ok=True)
|
||||||
|
|
||||||
|
|
||||||
def wrap_interpreter(path: Path):
|
def wrap_interpreter(path: Path, symlink_target: Path):
|
||||||
mommy_logger.info("mommy found a symlink to an interpreter~ %s", str(path))
|
mommy_logger.info("mommy found a symlink to an interpreter~ %s", str(path))
|
||||||
serious_logger.info("interpreter symlink found at %s", str(path))
|
serious_logger.info("interpreter symlink found at %s", str(path))
|
||||||
|
|
||||||
inner_symlink = path.parent / ("inner_" + path.name)
|
inner_symlink = path.parent / ("inner_" + path.name)
|
||||||
symlink_target = path.resolve()
|
|
||||||
|
|
||||||
if inner_symlink.exists():
|
if inner_symlink.exists():
|
||||||
raise Exception("inner symlink somehow already exists. This shouldn't happen because of prior checks")
|
raise Exception("inner symlink somehow already exists. This shouldn't happen because of prior checks")
|
||||||
@ -204,6 +204,11 @@ def mommify_venv():
|
|||||||
mommy_logger.info("mommy looks in %s to mess your system up~ <33", str(bin_path))
|
mommy_logger.info("mommy looks in %s to mess your system up~ <33", str(bin_path))
|
||||||
serious_logger.info("scanning binary directory of venv at %s", str(bin_path))
|
serious_logger.info("scanning binary directory of venv at %s", str(bin_path))
|
||||||
|
|
||||||
|
resolved_symlinks = {}
|
||||||
|
for path in list(bin_path.iterdir()):
|
||||||
|
if path.is_symlink():
|
||||||
|
resolved_symlinks[path.name] = path.resolve()
|
||||||
|
|
||||||
for path in list(bin_path.iterdir()):
|
for path in list(bin_path.iterdir()):
|
||||||
name = path.name
|
name = path.name
|
||||||
|
|
||||||
@ -213,10 +218,10 @@ def mommify_venv():
|
|||||||
if name.startswith("inner_"):
|
if name.startswith("inner_"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if subprocess.run([str(path), '-c', '"exit(0)"']).returncode != 0:
|
if subprocess.run([str(path), '-c', '"exit(0)"'], stdout=sys.devnull).returncode != 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
wrap_interpreter(path)
|
wrap_interpreter(path, resolved_symlinks[path.name])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# could be pip
|
# could be pip
|
||||||
|
@ -71,8 +71,12 @@ def compile_config(disable_requests: bool = False) -> dict:
|
|||||||
if not disable_requests:
|
if not disable_requests:
|
||||||
mommy_logger.info("mommy downloads newest responses for her girl~ %s", RESPONSES_URL)
|
mommy_logger.info("mommy downloads newest responses for her girl~ %s", RESPONSES_URL)
|
||||||
serious_logger.info("downloading cargo mommy responses: %s", RESPONSES_URL)
|
serious_logger.info("downloading cargo mommy responses: %s", RESPONSES_URL)
|
||||||
|
try:
|
||||||
r = requests.get(RESPONSES_URL)
|
r = requests.get(RESPONSES_URL)
|
||||||
data = r.json()
|
data = r.json()
|
||||||
|
except requests.exceptions.ConnectionError:
|
||||||
|
mommy_logger.info("mommy couldn't fetch the url~")
|
||||||
|
serious_logger.info("couldnt fetch the url")
|
||||||
|
|
||||||
config_definition: Dict[str, dict] = data["vars"]
|
config_definition: Dict[str, dict] = data["vars"]
|
||||||
mood_definitions: Dict[str, dict] = data["moods"]
|
mood_definitions: Dict[str, dict] = data["moods"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user