ScriptCollection 4.2.115__py3-none-any.whl → 4.2.117__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.
@@ -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.115"
41
+ version = "4.2.117"
42
42
  __version__ = version
43
43
 
44
44
  class VSCodeWorkspaceShellTask:
@@ -3047,10 +3047,21 @@ OCR-content:
3047
3047
 
3048
3048
  @GeneralUtilities.check_arguments
3049
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})")
3050
+ # Determines the id of the container this process currently runs in. The hostname usually equals the short container-id, but a runner can override
3051
+ # the hostname, so the id is derived from the mountinfo-/cgroup-entries instead. Docker bind-mounts files like /etc/hostname, /etc/hosts and
3052
+ # /etc/resolv.conf from /var/lib/docker/containers/<full-id>/..., so the OWN full container-id appears in a "docker/containers/<id>"-path-segment.
3053
+ # A plain 64-hex-search is NOT sufficient because mountinfo can also contain other 64-hex-ids (most notably anonymous-volume-ids under
3054
+ # /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
3055
+ # "docker network connect". Therefore container-id-specific patterns are collected first and (where the docker-daemon is reachable) each candidate
3056
+ # is verified to actually be a known container; only then a broader 64-hex-search and finally the hostname are used as fallbacks.
3057
+ specific_container_id_patterns = [
3058
+ re.compile(r"docker/containers/([0-9a-f]{64})"), # own id via the bind-mounted /etc/*-files (most reliable)
3059
+ re.compile(r"docker[-/]([0-9a-f]{64})"), # cgroup-style: /docker/<id> (cgroup v1) or docker-<id>.scope (systemd-cgroup)
3060
+ re.compile(r"kubepods[^\n]*?([0-9a-f]{64})"), # kubernetes-pods
3061
+ ]
3062
+ broad_container_id_pattern = re.compile(r"([0-9a-f]{64})")
3063
+ specific_candidate_ids: list[str] = []
3064
+ broad_candidate_ids: list[str] = []
3054
3065
  for proc_file in ["/proc/self/mountinfo", "/proc/self/cgroup"]:
3055
3066
  if not os.path.isfile(proc_file):
3056
3067
  continue
@@ -3058,15 +3069,27 @@ OCR-content:
3058
3069
  content = GeneralUtilities.read_text_from_file(proc_file)
3059
3070
  except Exception:
3060
3071
  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)
3072
+ for pattern in specific_container_id_patterns:
3073
+ for match in pattern.finditer(content):
3074
+ if match.group(1) not in specific_candidate_ids:
3075
+ specific_candidate_ids.append(match.group(1))
3076
+ for match in broad_container_id_pattern.finditer(content):
3077
+ if match.group(1) not in broad_candidate_ids:
3078
+ broad_candidate_ids.append(match.group(1))
3079
+ # Prefer a specific candidate that the docker-daemon actually knows (this reliably filters out volume-/layer-ids); fall back to the first specific
3080
+ # candidate if the daemon is not reachable here at all.
3081
+ for candidate_id in specific_candidate_ids:
3082
+ inspect_result = self.run_program_argsasarray("docker", ["inspect", "-f", "{{.Id}}", candidate_id], throw_exception_if_exitcode_is_not_zero=False)
3083
+ if inspect_result[0] == 0:
3084
+ return candidate_id
3085
+ if 0 < len(specific_candidate_ids):
3086
+ return specific_candidate_ids[0]
3087
+ for candidate_id in broad_candidate_ids:
3088
+ inspect_result = self.run_program_argsasarray("docker", ["inspect", "-f", "{{.Id}}", candidate_id], throw_exception_if_exitcode_is_not_zero=False)
3089
+ if inspect_result[0] == 0:
3090
+ return candidate_id
3091
+ if 0 < len(broad_candidate_ids):
3092
+ return broad_candidate_ids[0]
3070
3093
  if os.path.isfile("/etc/hostname"):
3071
3094
  return GeneralUtilities.read_text_from_file_without_linebreak("/etc/hostname").strip()
3072
3095
  return GeneralUtilities.empty_string
@@ -3092,7 +3115,11 @@ OCR-content:
3092
3115
  connected_container_ids = [line.strip() for line in inspect_result[1].splitlines() if GeneralUtilities.string_has_content(line)]
3093
3116
  already_connected = any(connected_container_id.startswith(own_container_id) for connected_container_id in connected_container_ids)
3094
3117
  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)
3118
+ # Attaching this build-container to the compose-network is REQUIRED for the test-process to reach the test-service-containers. If it fails,
3119
+ # the tests would otherwise resolve the container-name (via /etc/hosts) but have no network-route to the container-IP and only fail later
3120
+ # with a misleading connection-timeout. Therefore the attach must fail loudly here with the actual docker-error (e.g. "No such container"
3121
+ # or "network not found") instead of being swallowed.
3122
+ self.run_program_argsasarray("docker", ["network", "connect", network_name, own_container_id], throw_exception_if_exitcode_is_not_zero=True)
3096
3123
 
3097
3124
  @GeneralUtilities.check_arguments
3098
3125
  def __register_test_service_containers_in_etc_hosts(self, docker_compose_file: str) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.2.115
3
+ Version: 4.2.117
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=dG2gsn8DMLy9DJg5QzFkcvmQbk4p8j7VCoRLiK6Gfx0,198356
18
+ ScriptCollection/ScriptCollectionCore.py,sha256=5Ob4uPt36MjhngzSwyH9cSKfrHBx-lDCN8vixQ1uk_E,200854
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.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,,
294
+ scriptcollection-4.2.117.dist-info/METADATA,sha256=dao8pkyRfOxpo17BWk-fe_n1Z13Gz8wSrnRUSGckgDU,7697
295
+ scriptcollection-4.2.117.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
296
+ scriptcollection-4.2.117.dist-info/entry_points.txt,sha256=_vnVTrGJc_z-DTPLvaYyyOpDEQLz0bdO2OLN3_ZmeR8,4978
297
+ scriptcollection-4.2.117.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
298
+ scriptcollection-4.2.117.dist-info/RECORD,,