ScriptCollection 4.2.105__py3-none-any.whl → 4.2.107__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 +1 -2
- ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py +91 -0
- ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py +0 -6
- {scriptcollection-4.2.105.dist-info → scriptcollection-4.2.107.dist-info}/METADATA +1 -1
- {scriptcollection-4.2.105.dist-info → scriptcollection-4.2.107.dist-info}/RECORD +8 -8
- {scriptcollection-4.2.105.dist-info → scriptcollection-4.2.107.dist-info}/WHEEL +0 -0
- {scriptcollection-4.2.105.dist-info → scriptcollection-4.2.107.dist-info}/entry_points.txt +0 -0
- {scriptcollection-4.2.105.dist-info → scriptcollection-4.2.107.dist-info}/top_level.txt +0 -0
|
@@ -13,7 +13,6 @@ import zipfile
|
|
|
13
13
|
import math
|
|
14
14
|
import base64
|
|
15
15
|
import os
|
|
16
|
-
import sys
|
|
17
16
|
from html.parser import HTMLParser
|
|
18
17
|
from queue import Queue, Empty
|
|
19
18
|
from concurrent.futures import ThreadPoolExecutor
|
|
@@ -39,7 +38,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
|
|
|
39
38
|
from .ProgramRunnerPopen import ProgramRunnerPopen
|
|
40
39
|
from .SCLog import SCLog, LogLevel
|
|
41
40
|
|
|
42
|
-
version = "4.2.
|
|
41
|
+
version = "4.2.107"
|
|
43
42
|
__version__ = version
|
|
44
43
|
|
|
45
44
|
class VSCodeWorkspaceShellTask:
|
|
@@ -105,6 +105,7 @@ class TFCPS_CodeUnitSpecific_Docker_Functions(TFCPS_CodeUnitSpecific_Base):
|
|
|
105
105
|
raise ValueError(f"Operation is not implemented.")
|
|
106
106
|
|
|
107
107
|
@GeneralUtilities.check_arguments
|
|
108
|
+
@GeneralUtilities.deprecated("Use image_is_working_via_network instead, which tests the image over a user-defined docker-network without publishing a host-port.")
|
|
108
109
|
def image_is_working(self,timeout:timedelta,environment_variables:dict[str,str],test_port:int,http_test_route:str,use_https_for_test:bool)->tuple[bool,str]:
|
|
109
110
|
if timeout is None:
|
|
110
111
|
timeout=timedelta(seconds=120)
|
|
@@ -182,11 +183,101 @@ class TFCPS_CodeUnitSpecific_Docker_Functions(TFCPS_CodeUnitSpecific_Base):
|
|
|
182
183
|
self.tfcps_Tools_General.ensure_containers_are_not_running([container_name])
|
|
183
184
|
|
|
184
185
|
@GeneralUtilities.check_arguments
|
|
186
|
+
@GeneralUtilities.deprecated("Use verify_image_is_working_via_network instead, which tests the image over a user-defined docker-network without publishing a host-port.")
|
|
185
187
|
def verify_image_is_working(self,timeout:timedelta,environment_variables:dict[str,str],test_port:int,http_test_route:str,use_https_for_test:bool):
|
|
186
188
|
check_result:tuple[bool,str]= self.image_is_working(timeout,environment_variables,test_port,http_test_route,use_https_for_test)
|
|
187
189
|
if not check_result[0]:
|
|
188
190
|
raise ValueError("Image not working: "+check_result[1])
|
|
189
191
|
|
|
192
|
+
@GeneralUtilities.check_arguments
|
|
193
|
+
def image_is_working_via_network(self,timeout:timedelta,environment_variables:dict[str,str],container_port:int,http_test_route:str,use_https_for_test:bool,network_name:str)->tuple[bool,str]:
|
|
194
|
+
"""Tests the built image without publishing a host-port: the container is attached to a
|
|
195
|
+
user-defined docker-network and the http-test is executed from a sibling-container on the
|
|
196
|
+
same network (addressing the container under test by its name). This avoids opening a port
|
|
197
|
+
on the docker-host - which, when the daemon is the host-daemon (mounted socket), would be a
|
|
198
|
+
real port on the host. The http-test is executed from a dedicated minimal curl-image that is
|
|
199
|
+
resolved via the image-manager (registered as "Curl"), so it is pulled from the configured
|
|
200
|
+
registry (no rate-limit) and does not require the image under test to provide curl.
|
|
201
|
+
container_port is the port the application listens on inside the container."""
|
|
202
|
+
if timeout is None:
|
|
203
|
+
timeout=timedelta(seconds=120)
|
|
204
|
+
if environment_variables is None:
|
|
205
|
+
environment_variables={}
|
|
206
|
+
current_platform = GeneralUtilities.get_current_platform()
|
|
207
|
+
platform_for_test:Platform=None
|
|
208
|
+
if current_platform == Platform.Windows_AMD64:
|
|
209
|
+
platform_for_test=Platform.Linux_AMD64
|
|
210
|
+
elif current_platform == Platform.Linux_AMD64:
|
|
211
|
+
platform_for_test=Platform.Linux_AMD64
|
|
212
|
+
elif current_platform == Platform.Linux_ARM64:
|
|
213
|
+
platform_for_test=Platform.Linux_ARM64
|
|
214
|
+
elif current_platform == Platform.MacOS_ARM64:
|
|
215
|
+
platform_for_test=Platform.Linux_ARM64
|
|
216
|
+
else:
|
|
217
|
+
raise ValueError(f"Current platform {current_platform} is not supported for testing.")
|
|
218
|
+
oci_image_artifacts_folder :str= GeneralUtilities.resolve_relative_path("Other/Artifacts/BuildResult_OCIImage", self.get_codeunit_folder())
|
|
219
|
+
container_name:str=f"{self.get_codeunit_name()}finaltest".lower()
|
|
220
|
+
GeneralUtilities.assert_condition(http_test_route is None or http_test_route.startswith("/"),"If a test-route is given then it must start with \"/\".")
|
|
221
|
+
self.tfcps_Tools_General.ensure_containers_are_not_running([container_name])
|
|
222
|
+
self.tfcps_Tools_General.load_docker_image(oci_image_artifacts_folder,platform_for_test)
|
|
223
|
+
codeunit_file:str=os.path.join(self.get_codeunit_folder(),f"{self.get_codeunit_name()}.codeunit.xml")
|
|
224
|
+
image=f"{self.get_codeunit_name()}:{self.tfcps_Tools_General.get_version_of_codeunit(codeunit_file)}".lower()
|
|
225
|
+
self._protected_sc.ensure_local_docker_network_exists(network_name)
|
|
226
|
+
argument=f"run -d --name {container_name} --network {network_name}"
|
|
227
|
+
for k,v in environment_variables.items():
|
|
228
|
+
argument=f"{argument} -e {k}={v}"#TODO switch to argument-array to also allow values with white-space
|
|
229
|
+
argument=f"{argument} {image}"
|
|
230
|
+
curl_image:str=None
|
|
231
|
+
if http_test_route is not None:
|
|
232
|
+
# Use a dedicated minimal curl-image to run the http-test from a sibling-container,
|
|
233
|
+
# so it does not depend on the image under test providing curl. It is resolved via
|
|
234
|
+
# the image-manager (like Syft), so it is pulled from the configured registry and
|
|
235
|
+
# does not hit registry-rate-limits.
|
|
236
|
+
curl_image=self.tfcps_Tools_General.oci_image_manager.get_registry_address_for_image_with_default_tag(self.get_repository_folder(),"Curl",True)
|
|
237
|
+
try:
|
|
238
|
+
last_exception:Exception=None
|
|
239
|
+
self._protected_sc.run_program("docker",argument)
|
|
240
|
+
start:datetime=GeneralUtilities.get_now()
|
|
241
|
+
end:datetime=start+timeout
|
|
242
|
+
while GeneralUtilities.get_now()<end:
|
|
243
|
+
time.sleep(1)
|
|
244
|
+
try:
|
|
245
|
+
if not self._protected_sc.container_is_running_and_healthy(container_name):
|
|
246
|
+
raise ValueError("Container is not running and healthy.")
|
|
247
|
+
if http_test_route is not None:
|
|
248
|
+
scheme="https" if use_https_for_test else "http"
|
|
249
|
+
url=f"{scheme}://{container_name}:{container_port}{http_test_route}"
|
|
250
|
+
curl_arguments="--fail --silent --show-error --max-time 30"
|
|
251
|
+
if use_https_for_test:
|
|
252
|
+
curl_arguments=curl_arguments+" --insecure"
|
|
253
|
+
self._protected_sc.run_program("docker",f"run --rm --network {network_name} --entrypoint curl {curl_image} {curl_arguments} {url}")
|
|
254
|
+
return (True,None)
|
|
255
|
+
except Exception as e:
|
|
256
|
+
last_exception=e
|
|
257
|
+
container_output:str=None
|
|
258
|
+
if not self._protected_sc.container_is_exists(container_name):
|
|
259
|
+
return (False,f"Container \"{container_name}\" does not exist.")
|
|
260
|
+
try:
|
|
261
|
+
container_output="\nContainer-output:\n"+self._protected_sc.get_output_of_container(container_name)
|
|
262
|
+
except Exception:
|
|
263
|
+
container_output="\n(Container-output not retrievable.)"
|
|
264
|
+
exception_message=f"\nContainer was started with \"docker {argument}\"."
|
|
265
|
+
if last_exception is not None:
|
|
266
|
+
exception_message=exception_message+"\nLast exception: "+GeneralUtilities.exception_to_str(last_exception)
|
|
267
|
+
if not self._protected_sc.container_is_running(container_name):
|
|
268
|
+
return (False,f"Container \"{container_name}\" is not running.{exception_message}{container_output}")
|
|
269
|
+
if not self._protected_sc.container_is_healthy(container_name):
|
|
270
|
+
return (False,f"Container \"{container_name}\" is not healthy.{exception_message}{container_output}")
|
|
271
|
+
return (False,f"Container \"{container_name}\" is not working properly.{exception_message}{container_output}")
|
|
272
|
+
finally:
|
|
273
|
+
self.tfcps_Tools_General.ensure_containers_are_not_running([container_name])
|
|
274
|
+
|
|
275
|
+
@GeneralUtilities.check_arguments
|
|
276
|
+
def verify_image_is_working_via_network(self,timeout:timedelta,environment_variables:dict[str,str],container_port:int,http_test_route:str,use_https_for_test:bool,network_name:str):
|
|
277
|
+
check_result:tuple[bool,str]= self.image_is_working_via_network(timeout,environment_variables,container_port,http_test_route,use_https_for_test,network_name)
|
|
278
|
+
if not check_result[0]:
|
|
279
|
+
raise ValueError("Image not working: "+check_result[1])
|
|
280
|
+
|
|
190
281
|
class TFCPS_CodeUnitSpecific_Docker_CLI:
|
|
191
282
|
|
|
192
283
|
@staticmethod
|
|
@@ -579,12 +579,6 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
|
|
|
579
579
|
result = etree.tostring(root).decode("utf-8")
|
|
580
580
|
GeneralUtilities.write_text_to_file(file, result)
|
|
581
581
|
|
|
582
|
-
@GeneralUtilities.check_arguments
|
|
583
|
-
def __coverage_file_contains_sources_and_packages(self, file: str) -> bool:
|
|
584
|
-
root: etree._ElementTree = etree.parse(file)
|
|
585
|
-
sources = root.xpath("//coverage/sources/source/text()")
|
|
586
|
-
packages = root.xpath("//coverage/packages/package")
|
|
587
|
-
return len(sources) > 0 and len(packages) > 0
|
|
588
582
|
|
|
589
583
|
@GeneralUtilities.check_arguments
|
|
590
584
|
def __standardized_tasks_run_testcases_for_dotnet_project_helper(self, source: str, codeunit_folder: str, match: re.Match) -> str:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scriptcollection
|
|
3
|
-
Version: 4.2.
|
|
3
|
+
Version: 4.2.107
|
|
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=BPY7-ZMIlqT7JOKz8qlB5c0laF2Js-ijzqk09GxZC48,3821
|
|
16
16
|
ScriptCollection/ProgramRunnerSudo.py,sha256=_khC3xuTdrPoLluBJZWfldltmmuKltABJPcbjZSFW-4,4835
|
|
17
17
|
ScriptCollection/SCLog.py,sha256=8TRy1LeYMsPOIuWUcnUNNbO5pd-cNBS-3cn-kdzP8FU,4768
|
|
18
|
-
ScriptCollection/ScriptCollectionCore.py,sha256=
|
|
18
|
+
ScriptCollection/ScriptCollectionCore.py,sha256=YWduvTDGYrU6mZJsIRN-y4Uyjr3wmkAYVuNiv_9tocg,188782
|
|
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
|
|
@@ -40,12 +40,12 @@ ScriptCollection/TFCPS/TFCPS_MergeToStable.py,sha256=xVPer8EGH5vhTT3_mpTMJJxWLB3
|
|
|
40
40
|
ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py,sha256=f0Uq1cA_4LvmL72cal0crrbKF6PcxL13D9wBKuQ1YBw,2328
|
|
41
41
|
ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=l42hYiDwcafEGIUCXmeyxr7XMzQ01MUEpElVvB1zhKY,105372
|
|
42
42
|
ScriptCollection/TFCPS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
43
|
-
ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py,sha256=
|
|
43
|
+
ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py,sha256=jFH8IQ2jmgqVV5Zio9vCvw-OuQgI4DxgM1ahNDkupIw,19577
|
|
44
44
|
ScriptCollection/TFCPS/Docker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
45
45
|
ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationBase.py,sha256=bT6Gd5pQpZCw4OQz6HWkPCSn5z__eUUEisABLDSxd0o,200
|
|
46
46
|
ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationGenerate.py,sha256=QyjOfMY22JWCvKjMelHiDWbJiWqotOfebpJpgDUaoO4,237
|
|
47
47
|
ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationNoGenerate.py,sha256=i0zEGehj0sttxjjZtoq2KFSKp_ulxVyWp_ZgAhIY_So,241
|
|
48
|
-
ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=
|
|
48
|
+
ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=v1xfJxMJ6hXmRwuemL8ED3XZkw4sYL3r7B8mLSb0hRA,39959
|
|
49
49
|
ScriptCollection/TFCPS/DotNet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
50
50
|
ScriptCollection/TFCPS/Flutter/TFCPS_CodeUnitSpecific_Flutter.py,sha256=KAjyFyEjpkghsVPskfsHD68k4Z92gRCT_q6BXfikRwE,7660
|
|
51
51
|
ScriptCollection/TFCPS/Flutter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -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.107.dist-info/METADATA,sha256=2Agi7OuYSfAhj0haaPxouUYM_62AgaWIHzE0nPwpL3U,7697
|
|
295
|
+
scriptcollection-4.2.107.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
296
|
+
scriptcollection-4.2.107.dist-info/entry_points.txt,sha256=_vnVTrGJc_z-DTPLvaYyyOpDEQLz0bdO2OLN3_ZmeR8,4978
|
|
297
|
+
scriptcollection-4.2.107.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
|
|
298
|
+
scriptcollection-4.2.107.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|