ScriptCollection 4.2.116__py3-none-any.whl → 4.2.118__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ScriptCollection/ScriptCollectionCore.py +83 -14
- {scriptcollection-4.2.116.dist-info → scriptcollection-4.2.118.dist-info}/METADATA +1 -1
- {scriptcollection-4.2.116.dist-info → scriptcollection-4.2.118.dist-info}/RECORD +6 -6
- {scriptcollection-4.2.116.dist-info → scriptcollection-4.2.118.dist-info}/WHEEL +0 -0
- {scriptcollection-4.2.116.dist-info → scriptcollection-4.2.118.dist-info}/entry_points.txt +0 -0
- {scriptcollection-4.2.116.dist-info → scriptcollection-4.2.118.dist-info}/top_level.txt +0 -0
|
@@ -38,7 +38,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
|
|
|
38
38
|
from .ProgramRunnerPopen import ProgramRunnerPopen
|
|
39
39
|
from .SCLog import SCLog, LogLevel
|
|
40
40
|
|
|
41
|
-
version = "4.2.
|
|
41
|
+
version = "4.2.118"
|
|
42
42
|
__version__ = version
|
|
43
43
|
|
|
44
44
|
class VSCodeWorkspaceShellTask:
|
|
@@ -3010,6 +3010,12 @@ OCR-content:
|
|
|
3010
3010
|
if os.path.isfile(os.path.join(example_folder,"Parameters.env")):
|
|
3011
3011
|
argument=argument+" --env-file Parameters.env"
|
|
3012
3012
|
argument=argument+" up --detach"
|
|
3013
|
+
if in_build_container:
|
|
3014
|
+
# In a DooD-setup the test-service-containers are siblings on the docker-daemon and resolve their bind-mount-sources against the DAEMON's
|
|
3015
|
+
# filesystem, not against this build-container's filesystem. Clearing the source-folders from within this build-container (as the *Start.py-
|
|
3016
|
+
# scripts do) therefore does not reset what the containers actually mount. Reset them daemon-side first so that e.g. a database starts on a
|
|
3017
|
+
# clean data-directory instead of stale content (which could otherwise keep an outdated pg_hba.conf and reject the build-container's connection).
|
|
3018
|
+
self.__reset_compose_bind_mounted_volumes_daemon_side(docker_compose_file, example_folder, title.lower())
|
|
3013
3019
|
try:
|
|
3014
3020
|
self.run_program("docker", argument, example_folder, title=title,print_live_output=True)
|
|
3015
3021
|
finally:
|
|
@@ -3027,6 +3033,46 @@ OCR-content:
|
|
|
3027
3033
|
# start because the containers get a new IP every time.
|
|
3028
3034
|
self.__register_test_service_containers_in_etc_hosts(docker_compose_file)
|
|
3029
3035
|
|
|
3036
|
+
@GeneralUtilities.check_arguments
|
|
3037
|
+
def __reset_compose_bind_mounted_volumes_daemon_side(self, docker_compose_file: str, example_folder: str, project_name: str) -> None:
|
|
3038
|
+
# Empties the bind-mounted directories of all compose-services on the DAEMON's filesystem, i.e. exactly where the (sibling-)containers will mount
|
|
3039
|
+
# them. In a DooD-setup a bind-mount-source like "./Volumes/..." is resolved by the docker-daemon and not inside this build-container, so deleting
|
|
3040
|
+
# the folder from within this build-container does not reset what e.g. a database-container mounts (which would otherwise start on stale data, like
|
|
3041
|
+
# an outdated pg_hba.conf). The directories are emptied via a throwaway-container of the service's own image (compose resolves the image and mounts
|
|
3042
|
+
# the volumes exactly like for the real container); only the directory-content is removed, not the mount-root itself. Failures are tolerated because
|
|
3043
|
+
# a not-yet existing source-directory simply needs no clearing.
|
|
3044
|
+
env_file_arguments: list[str] = []
|
|
3045
|
+
if os.path.isfile(os.path.join(example_folder, "Parameters.env")):
|
|
3046
|
+
env_file_arguments = ["--env-file", "Parameters.env"]
|
|
3047
|
+
with open(docker_compose_file, encoding="utf-8") as stream:
|
|
3048
|
+
loaded = yaml.safe_load(stream)
|
|
3049
|
+
services = loaded.get("services", dict())
|
|
3050
|
+
for service_name, service_definition in services.items():
|
|
3051
|
+
service_definition = service_definition or dict()
|
|
3052
|
+
for volume in service_definition.get("volumes", list()):
|
|
3053
|
+
source = None
|
|
3054
|
+
target = None
|
|
3055
|
+
if isinstance(volume, str):
|
|
3056
|
+
volume_parts = volume.split(":")
|
|
3057
|
+
if 2 <= len(volume_parts):
|
|
3058
|
+
source = volume_parts[0]
|
|
3059
|
+
target = volume_parts[1]
|
|
3060
|
+
elif isinstance(volume, dict):
|
|
3061
|
+
if volume.get("type", "bind") == "bind":
|
|
3062
|
+
source = volume.get("source")
|
|
3063
|
+
target = volume.get("target")
|
|
3064
|
+
if not GeneralUtilities.string_has_content(source) or not GeneralUtilities.string_has_content(target):
|
|
3065
|
+
continue
|
|
3066
|
+
# Named volumes (a source without a path-indicator) are managed by docker itself and must not be cleared this way.
|
|
3067
|
+
if not (source.startswith(".") or source.startswith("/") or source.startswith("~")):
|
|
3068
|
+
continue
|
|
3069
|
+
# Empty the directory-content using only a POSIX-shell (no dependency on "find"/"-delete", which busybox-based images may not provide). The
|
|
3070
|
+
# three globs cover normal entries, dotfiles and double-dot-prefixed entries (but never "." or ".."); the trailing "; true" keeps the
|
|
3071
|
+
# exitcode at 0 even when a glob does not expand (already-empty directory). This works for any service-image that ships a shell (which all
|
|
3072
|
+
# real stateful images do); images without a shell (distroless/scratch) do not have a resettable bind-mounted data-directory here anyway.
|
|
3073
|
+
clear_command = f"rm -rf \"{target}\"/..?* \"{target}\"/.[!.]* \"{target}\"/* 2>/dev/null; true"
|
|
3074
|
+
self.run_program_argsasarray("docker", ["compose", "-p", project_name] + env_file_arguments + ["run", "--rm", "--no-deps", "--entrypoint", "sh", service_name, "-c", clear_command], example_folder, throw_exception_if_exitcode_is_not_zero=False)
|
|
3075
|
+
|
|
3030
3076
|
@GeneralUtilities.check_arguments
|
|
3031
3077
|
def __generate_localhost_ports_override_file(self, docker_compose_file: str) -> str:
|
|
3032
3078
|
with open(docker_compose_file, encoding="utf-8") as stream:
|
|
@@ -3047,10 +3093,21 @@ OCR-content:
|
|
|
3047
3093
|
|
|
3048
3094
|
@GeneralUtilities.check_arguments
|
|
3049
3095
|
def __get_own_container_id(self) -> str:
|
|
3050
|
-
# Determines the id of the container this process currently runs in. The hostname usually equals the short container-id, but a runner can
|
|
3051
|
-
#
|
|
3052
|
-
# /var/lib/docker/containers/<full-id
|
|
3053
|
-
|
|
3096
|
+
# Determines the id of the container this process currently runs in. The hostname usually equals the short container-id, but a runner can override
|
|
3097
|
+
# the hostname, so the id is derived from the mountinfo-/cgroup-entries instead. Docker bind-mounts files like /etc/hostname, /etc/hosts and
|
|
3098
|
+
# /etc/resolv.conf from /var/lib/docker/containers/<full-id>/..., so the OWN full container-id appears in a "docker/containers/<id>"-path-segment.
|
|
3099
|
+
# A plain 64-hex-search is NOT sufficient because mountinfo can also contain other 64-hex-ids (most notably anonymous-volume-ids under
|
|
3100
|
+
# /var/lib/docker/volumes/<id>/_data, but also layer-ids) which are not container-ids and would cause a "No such container"-error when used for
|
|
3101
|
+
# "docker network connect". Therefore container-id-specific patterns are collected first and (where the docker-daemon is reachable) each candidate
|
|
3102
|
+
# is verified to actually be a known container; only then a broader 64-hex-search and finally the hostname are used as fallbacks.
|
|
3103
|
+
specific_container_id_patterns = [
|
|
3104
|
+
re.compile(r"docker/containers/([0-9a-f]{64})"), # own id via the bind-mounted /etc/*-files (most reliable)
|
|
3105
|
+
re.compile(r"docker[-/]([0-9a-f]{64})"), # cgroup-style: /docker/<id> (cgroup v1) or docker-<id>.scope (systemd-cgroup)
|
|
3106
|
+
re.compile(r"kubepods[^\n]*?([0-9a-f]{64})"), # kubernetes-pods
|
|
3107
|
+
]
|
|
3108
|
+
broad_container_id_pattern = re.compile(r"([0-9a-f]{64})")
|
|
3109
|
+
specific_candidate_ids: list[str] = []
|
|
3110
|
+
broad_candidate_ids: list[str] = []
|
|
3054
3111
|
for proc_file in ["/proc/self/mountinfo", "/proc/self/cgroup"]:
|
|
3055
3112
|
if not os.path.isfile(proc_file):
|
|
3056
3113
|
continue
|
|
@@ -3058,15 +3115,27 @@ OCR-content:
|
|
|
3058
3115
|
content = GeneralUtilities.read_text_from_file(proc_file)
|
|
3059
3116
|
except Exception:
|
|
3060
3117
|
continue
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3118
|
+
for pattern in specific_container_id_patterns:
|
|
3119
|
+
for match in pattern.finditer(content):
|
|
3120
|
+
if match.group(1) not in specific_candidate_ids:
|
|
3121
|
+
specific_candidate_ids.append(match.group(1))
|
|
3122
|
+
for match in broad_container_id_pattern.finditer(content):
|
|
3123
|
+
if match.group(1) not in broad_candidate_ids:
|
|
3124
|
+
broad_candidate_ids.append(match.group(1))
|
|
3125
|
+
# Prefer a specific candidate that the docker-daemon actually knows (this reliably filters out volume-/layer-ids); fall back to the first specific
|
|
3126
|
+
# candidate if the daemon is not reachable here at all.
|
|
3127
|
+
for candidate_id in specific_candidate_ids:
|
|
3128
|
+
inspect_result = self.run_program_argsasarray("docker", ["inspect", "-f", "{{.Id}}", candidate_id], throw_exception_if_exitcode_is_not_zero=False)
|
|
3129
|
+
if inspect_result[0] == 0:
|
|
3130
|
+
return candidate_id
|
|
3131
|
+
if 0 < len(specific_candidate_ids):
|
|
3132
|
+
return specific_candidate_ids[0]
|
|
3133
|
+
for candidate_id in broad_candidate_ids:
|
|
3134
|
+
inspect_result = self.run_program_argsasarray("docker", ["inspect", "-f", "{{.Id}}", candidate_id], throw_exception_if_exitcode_is_not_zero=False)
|
|
3135
|
+
if inspect_result[0] == 0:
|
|
3136
|
+
return candidate_id
|
|
3137
|
+
if 0 < len(broad_candidate_ids):
|
|
3138
|
+
return broad_candidate_ids[0]
|
|
3070
3139
|
if os.path.isfile("/etc/hostname"):
|
|
3071
3140
|
return GeneralUtilities.read_text_from_file_without_linebreak("/etc/hostname").strip()
|
|
3072
3141
|
return GeneralUtilities.empty_string
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scriptcollection
|
|
3
|
-
Version: 4.2.
|
|
3
|
+
Version: 4.2.118
|
|
4
4
|
Summary: The ScriptCollection is the place for reusable scripts.
|
|
5
5
|
Author-email: Marius Göcke <marius.goecke@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/anionDev/ScriptCollection
|
|
@@ -15,7 +15,7 @@ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrR
|
|
|
15
15
|
ScriptCollection/ProgramRunnerPopen.py,sha256=8tP0xWKeRYoGlaNB3iUh4o61O-tKtcxrS7IUqtU85C4,4091
|
|
16
16
|
ScriptCollection/ProgramRunnerSudo.py,sha256=4lxbUFMIWMbthM5Q_QaFjvZfAsNpKlXeqfEbiofg_DI,5109
|
|
17
17
|
ScriptCollection/SCLog.py,sha256=8TRy1LeYMsPOIuWUcnUNNbO5pd-cNBS-3cn-kdzP8FU,4768
|
|
18
|
-
ScriptCollection/ScriptCollectionCore.py,sha256=
|
|
18
|
+
ScriptCollection/ScriptCollectionCore.py,sha256=U_TluWTs0RAaBfb9P2J535ouxlLUzhoxX0o0NMZzWCI,205101
|
|
19
19
|
ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
20
|
ScriptCollection/OCIImages/AbstractImageHandler.py,sha256=o129UYDtLymCRjMZBP9Puaj19ueMHoNt6UTLspfnaRc,1758
|
|
21
21
|
ScriptCollection/OCIImages/OCIImageManager.py,sha256=2muW4hJ_a7EfavY3WVnafqZ0HC87RcZsoTuNvA3c0To,11175
|
|
@@ -291,8 +291,8 @@ build/lib/build/lib/build/lib/build/lib/ScriptCollection/TFCPS/Python/TFCPS_Code
|
|
|
291
291
|
build/lib/build/lib/build/lib/build/lib/ScriptCollection/TFCPS/Python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
292
292
|
build/lib/build/lib/build/lib/build/lib/ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=WhOsMpJxNGqnQGA3nJ99ruyqymxBeJxCcpK98zJduTo,1680
|
|
293
293
|
build/lib/build/lib/build/lib/build/lib/ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
294
|
-
scriptcollection-4.2.
|
|
295
|
-
scriptcollection-4.2.
|
|
296
|
-
scriptcollection-4.2.
|
|
297
|
-
scriptcollection-4.2.
|
|
298
|
-
scriptcollection-4.2.
|
|
294
|
+
scriptcollection-4.2.118.dist-info/METADATA,sha256=TqYnvaXCsp51-firRNfJskpqy_SgVF3zBjI3rBtxVMc,7697
|
|
295
|
+
scriptcollection-4.2.118.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
296
|
+
scriptcollection-4.2.118.dist-info/entry_points.txt,sha256=_vnVTrGJc_z-DTPLvaYyyOpDEQLz0bdO2OLN3_ZmeR8,4978
|
|
297
|
+
scriptcollection-4.2.118.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
|
|
298
|
+
scriptcollection-4.2.118.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|