ScriptCollection 4.2.114__py3-none-any.whl → 4.2.115__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 +59 -5
- {scriptcollection-4.2.114.dist-info → scriptcollection-4.2.115.dist-info}/METADATA +1 -1
- {scriptcollection-4.2.114.dist-info → scriptcollection-4.2.115.dist-info}/RECORD +6 -6
- {scriptcollection-4.2.114.dist-info → scriptcollection-4.2.115.dist-info}/WHEEL +0 -0
- {scriptcollection-4.2.114.dist-info → scriptcollection-4.2.115.dist-info}/entry_points.txt +0 -0
- {scriptcollection-4.2.114.dist-info → scriptcollection-4.2.115.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.115"
|
|
42
42
|
__version__ = version
|
|
43
43
|
|
|
44
44
|
class VSCodeWorkspaceShellTask:
|
|
@@ -3016,10 +3016,15 @@ OCR-content:
|
|
|
3016
3016
|
if generated_ports_override_file != GeneralUtilities.empty_string:
|
|
3017
3017
|
GeneralUtilities.ensure_file_does_not_exist(generated_ports_override_file)
|
|
3018
3018
|
if in_build_container:
|
|
3019
|
-
# Inside the build-container the docker-
|
|
3020
|
-
#
|
|
3021
|
-
#
|
|
3022
|
-
# the container
|
|
3019
|
+
# Inside the build-container the docker-socket points at a daemon on which the test-service-containers are created as SIBLING-containers
|
|
3020
|
+
# attached to the (external) compose-network. The build-container itself is not attached to that network, so without the following step it
|
|
3021
|
+
# could neither route to the container-IPs nor use the docker-DNS (which results in connection-timeouts even though the container-name can
|
|
3022
|
+
# be resolved via /etc/hosts). Therefore the build-container is attached to every (external) network the compose-file uses. No port is
|
|
3023
|
+
# published to the host, so concurrent pipelines on the same host do not conflict on host-ports.
|
|
3024
|
+
self.__connect_build_container_to_compose_networks(docker_compose_file)
|
|
3025
|
+
# In addition the container-names are mapped to their current container-IPs in the /etc/hosts of this build-container so that the
|
|
3026
|
+
# container-names can be used in the connection-strings even if the docker-DNS is not consulted. The managed block is rewritten on each
|
|
3027
|
+
# start because the containers get a new IP every time.
|
|
3023
3028
|
self.__register_test_service_containers_in_etc_hosts(docker_compose_file)
|
|
3024
3029
|
|
|
3025
3030
|
@GeneralUtilities.check_arguments
|
|
@@ -3040,6 +3045,55 @@ OCR-content:
|
|
|
3040
3045
|
yaml.safe_dump({"services": override_services}, stream)
|
|
3041
3046
|
return override_file
|
|
3042
3047
|
|
|
3048
|
+
@GeneralUtilities.check_arguments
|
|
3049
|
+
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
|
+
# override the hostname, so the id is primarily derived from the cgroup-/mountinfo-entries (docker mounts files like /etc/hostname from
|
|
3052
|
+
# /var/lib/docker/containers/<full-id>/... so the full 64-char container-id appears in these paths). The hostname is used as fallback only.
|
|
3053
|
+
full_container_id_pattern = re.compile(r"([0-9a-f]{64})")
|
|
3054
|
+
for proc_file in ["/proc/self/mountinfo", "/proc/self/cgroup"]:
|
|
3055
|
+
if not os.path.isfile(proc_file):
|
|
3056
|
+
continue
|
|
3057
|
+
try:
|
|
3058
|
+
content = GeneralUtilities.read_text_from_file(proc_file)
|
|
3059
|
+
except Exception:
|
|
3060
|
+
continue
|
|
3061
|
+
# Prefer lines which clearly reference a container-id-path to avoid matching unrelated 64-hex-strings.
|
|
3062
|
+
for line in content.splitlines():
|
|
3063
|
+
if "docker/containers/" in line or "/docker/" in line or "kubepods" in line:
|
|
3064
|
+
match = full_container_id_pattern.search(line)
|
|
3065
|
+
if match is not None:
|
|
3066
|
+
return match.group(1)
|
|
3067
|
+
match = full_container_id_pattern.search(content)
|
|
3068
|
+
if match is not None:
|
|
3069
|
+
return match.group(1)
|
|
3070
|
+
if os.path.isfile("/etc/hostname"):
|
|
3071
|
+
return GeneralUtilities.read_text_from_file_without_linebreak("/etc/hostname").strip()
|
|
3072
|
+
return GeneralUtilities.empty_string
|
|
3073
|
+
|
|
3074
|
+
@GeneralUtilities.check_arguments
|
|
3075
|
+
def __connect_build_container_to_compose_networks(self, docker_compose_file: str) -> None:
|
|
3076
|
+
# Attaches THIS build-container to every (external) network used by the compose-file so that the test-service-containers (which are
|
|
3077
|
+
# sibling-containers on the same docker-daemon) become routable and resolvable. The docker-socket is shared with the daemon, but the
|
|
3078
|
+
# network-namespace of the build-container is not, so without attaching there is no network-path to the container-IPs.
|
|
3079
|
+
own_container_id = self.__get_own_container_id()
|
|
3080
|
+
if not GeneralUtilities.string_has_content(own_container_id):
|
|
3081
|
+
return
|
|
3082
|
+
with open(docker_compose_file, encoding="utf-8") as stream:
|
|
3083
|
+
loaded = yaml.safe_load(stream)
|
|
3084
|
+
networks = loaded.get("networks", dict())
|
|
3085
|
+
for network_key, network_definition in networks.items():
|
|
3086
|
+
network_definition = network_definition or dict()
|
|
3087
|
+
network_name = network_definition.get("name", network_key)
|
|
3088
|
+
inspect_result = self.run_program_argsasarray("docker", ["network", "inspect", "-f", "{{range $id, $c := .Containers}}{{$id}}\n{{end}}", network_name], throw_exception_if_exitcode_is_not_zero=False)
|
|
3089
|
+
if inspect_result[0] != 0:
|
|
3090
|
+
continue # The network does not exist (yet); nothing to attach to.
|
|
3091
|
+
# The keys of .Containers are full container-ids; the hostname (own_container_id) is the corresponding short-id (a prefix of it).
|
|
3092
|
+
connected_container_ids = [line.strip() for line in inspect_result[1].splitlines() if GeneralUtilities.string_has_content(line)]
|
|
3093
|
+
already_connected = any(connected_container_id.startswith(own_container_id) for connected_container_id in connected_container_ids)
|
|
3094
|
+
if not already_connected:
|
|
3095
|
+
self.run_program_argsasarray("docker", ["network", "connect", network_name, own_container_id], throw_exception_if_exitcode_is_not_zero=False)
|
|
3096
|
+
|
|
3043
3097
|
@GeneralUtilities.check_arguments
|
|
3044
3098
|
def __register_test_service_containers_in_etc_hosts(self, docker_compose_file: str) -> None:
|
|
3045
3099
|
# Maps the container-names of the test-services to their current container-IPs in the /etc/hosts of THIS build-container (neither the runner-host
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scriptcollection
|
|
3
|
-
Version: 4.2.
|
|
3
|
+
Version: 4.2.115
|
|
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=dG2gsn8DMLy9DJg5QzFkcvmQbk4p8j7VCoRLiK6Gfx0,198356
|
|
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.115.dist-info/METADATA,sha256=gNAKE0IY-WDdqxXYcI12HIl4a2cANKJ2oFscoNUxzoU,7697
|
|
295
|
+
scriptcollection-4.2.115.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
296
|
+
scriptcollection-4.2.115.dist-info/entry_points.txt,sha256=_vnVTrGJc_z-DTPLvaYyyOpDEQLz0bdO2OLN3_ZmeR8,4978
|
|
297
|
+
scriptcollection-4.2.115.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
|
|
298
|
+
scriptcollection-4.2.115.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|