ScriptCollection 4.4.37__py3-none-any.whl → 4.4.39__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/GeneralUtilities.py +10 -0
- ScriptCollection/ScriptCollectionCore.py +58 -8
- {scriptcollection-4.4.37.dist-info → scriptcollection-4.4.39.dist-info}/METADATA +1 -1
- {scriptcollection-4.4.37.dist-info → scriptcollection-4.4.39.dist-info}/RECORD +7 -7
- {scriptcollection-4.4.37.dist-info → scriptcollection-4.4.39.dist-info}/WHEEL +0 -0
- {scriptcollection-4.4.37.dist-info → scriptcollection-4.4.39.dist-info}/entry_points.txt +0 -0
- {scriptcollection-4.4.37.dist-info → scriptcollection-4.4.39.dist-info}/top_level.txt +0 -0
|
@@ -1375,6 +1375,14 @@ class GeneralUtilities:
|
|
|
1375
1375
|
@staticmethod
|
|
1376
1376
|
@check_arguments
|
|
1377
1377
|
def retry_action(action, amount_of_attempts: int, action_name: str = None,delay_in_seconds:int=2) -> None:
|
|
1378
|
+
return GeneralUtilities.retry_action_if(action, lambda exception: True, amount_of_attempts, action_name, delay_in_seconds)
|
|
1379
|
+
|
|
1380
|
+
@staticmethod
|
|
1381
|
+
@check_arguments
|
|
1382
|
+
def retry_action_if(action, exception_is_retryable, amount_of_attempts: int, action_name: str = None,delay_in_seconds:int=2) -> None:
|
|
1383
|
+
"""Executes action and retries it if it throws an exception for which exception_is_retryable returns True.
|
|
1384
|
+
An exception for which exception_is_retryable returns False is propagated immediately without any further attempt,
|
|
1385
|
+
because retrying an action which failed for a permanent reason can not succeed."""
|
|
1378
1386
|
amount_of_fails = 0
|
|
1379
1387
|
last_exception:Exception=None
|
|
1380
1388
|
GeneralUtilities.assert_condition(0<amount_of_attempts,"amount_of_attempts must be greater than 0.")
|
|
@@ -1383,6 +1391,8 @@ class GeneralUtilities:
|
|
|
1383
1391
|
result = action()
|
|
1384
1392
|
return result
|
|
1385
1393
|
except Exception as e:
|
|
1394
|
+
if not exception_is_retryable(e):
|
|
1395
|
+
raise
|
|
1386
1396
|
time.sleep(delay_in_seconds)
|
|
1387
1397
|
amount_of_fails = amount_of_fails+1
|
|
1388
1398
|
last_exception=e
|
|
@@ -40,7 +40,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
|
|
|
40
40
|
from .ProgramRunnerPopen import ProgramRunnerPopen
|
|
41
41
|
from .SCLog import SCLog, LogLevel
|
|
42
42
|
|
|
43
|
-
version = "4.4.
|
|
43
|
+
version = "4.4.39"
|
|
44
44
|
__version__ = version
|
|
45
45
|
|
|
46
46
|
class VSCodeWorkspaceShellTask:
|
|
@@ -223,6 +223,9 @@ class ScriptCollectionCore:
|
|
|
223
223
|
# Kinds which are allowed in the environment-variables-configuration-file (see get_environment_variables_configuration_file).
|
|
224
224
|
__allowed_environment_variable_kinds: list[str] = ["literal", "hostenvvariable", "file"]
|
|
225
225
|
|
|
226
|
+
# Indicators which occur in the error-message of a failed program-call when the call failed because an operation ran into a timeout. See __error_is_timeout_error.
|
|
227
|
+
__timeout_error_indicators: list[str] = ["timeout", "timed out", "context deadline exceeded"]
|
|
228
|
+
|
|
226
229
|
def __init__(self):
|
|
227
230
|
self.program_runner = ProgramRunnerPopen()
|
|
228
231
|
self.call_program_runner_directly = None
|
|
@@ -508,6 +511,28 @@ class ScriptCollectionCore:
|
|
|
508
511
|
result = tag in tags
|
|
509
512
|
return result
|
|
510
513
|
|
|
514
|
+
@staticmethod
|
|
515
|
+
@GeneralUtilities.check_arguments
|
|
516
|
+
def __error_is_timeout_error(exception: Exception) -> bool:
|
|
517
|
+
"""Returns True if and only if the message of the given exception indicates that the failed operation ran into a timeout."""
|
|
518
|
+
message = str(exception).lower()
|
|
519
|
+
return any(indicator in message for indicator in ScriptCollectionCore.__timeout_error_indicators)
|
|
520
|
+
|
|
521
|
+
@GeneralUtilities.check_arguments
|
|
522
|
+
def docker_login(self, registry: str, username: str, password: str) -> None:
|
|
523
|
+
"""Logs in to the given docker-registry."""
|
|
524
|
+
arg = f"login {registry} -u {username} -p {password}"
|
|
525
|
+
arg_for_log = f"login {registry} -u {username} -p ***"
|
|
526
|
+
self.run_program("docker", arg, arguments_for_log=arg_for_log, print_live_output=self.log.loglevel == LogLevel.Debug)
|
|
527
|
+
|
|
528
|
+
@GeneralUtilities.check_arguments
|
|
529
|
+
def docker_login_with_retry(self, registry: str, username: str, password: str, amount_of_attempts: int = 5) -> None:
|
|
530
|
+
"""Does the same as docker_login but retries the login if it failed due to a timeout.
|
|
531
|
+
A timeout (for example a tls-handshake-timeout, whose duration is hardcoded in the docker-daemon and therefore not configurable) occurs
|
|
532
|
+
sporadically when the registry or the connection to it is temporarily slow, so in this case a further attempt can succeed. Errors with a
|
|
533
|
+
permanent cause like wrong credentials would fail again in every further attempt, so only timeout-errors are retried."""
|
|
534
|
+
GeneralUtilities.retry_action_if(lambda: self.docker_login(registry, username, password), ScriptCollectionCore.__error_is_timeout_error, amount_of_attempts)
|
|
535
|
+
|
|
511
536
|
def login_to_defined_docker_registries(self)->None:
|
|
512
537
|
"""Logs in to every registry for which credentials are available on this machine (see get_docker_registry_credentials_from_environment_variables).
|
|
513
538
|
The login is only executed once per instance: the credentials do not change while a process runs, and the login has to be
|
|
@@ -520,9 +545,7 @@ class ScriptCollectionCore:
|
|
|
520
545
|
self.log.log("No docker registry credentials defined. Skipping docker login.",LogLevel.Debug)
|
|
521
546
|
else:
|
|
522
547
|
for registry,username,password in registries:
|
|
523
|
-
|
|
524
|
-
arg_for_log=f"login {registry} -u {username} -p ***"
|
|
525
|
-
self.run_program("docker",arg,arguments_for_log=arg_for_log,print_live_output=self.log.loglevel==LogLevel.Debug)
|
|
548
|
+
self.docker_login_with_retry(registry,username,password)
|
|
526
549
|
|
|
527
550
|
@staticmethod
|
|
528
551
|
@GeneralUtilities.check_arguments
|
|
@@ -3593,7 +3616,7 @@ TXDX
|
|
|
3593
3616
|
"link", "meta", "param", "source", "track", "wbr"}
|
|
3594
3617
|
|
|
3595
3618
|
class _Node:
|
|
3596
|
-
__slots__ = ("tag", "attrs", "children", "text", "is_void", "raw")
|
|
3619
|
+
__slots__ = ("tag", "attrs", "children", "text", "is_void", "raw", "text_ends_with_whitespace")
|
|
3597
3620
|
def __init__(self, tag=None, attrs=(), text=None, is_void=False, raw=None):
|
|
3598
3621
|
self.tag = tag
|
|
3599
3622
|
self.attrs = list(attrs)
|
|
@@ -3601,6 +3624,9 @@ TXDX
|
|
|
3601
3624
|
self.text = text
|
|
3602
3625
|
self.is_void = is_void
|
|
3603
3626
|
self.raw = raw
|
|
3627
|
+
# Whether the text of this node was followed by whitespace in the input. It is needed to append
|
|
3628
|
+
# further text to this node with the whitespace which was between both, see _Builder._append_text.
|
|
3629
|
+
self.text_ends_with_whitespace = False
|
|
3604
3630
|
|
|
3605
3631
|
class _Builder(HTMLParser):
|
|
3606
3632
|
def __init__(self):
|
|
@@ -3629,16 +3655,40 @@ TXDX
|
|
|
3629
3655
|
if len(self.stack) > 1 and self.stack[-1].tag == tag:
|
|
3630
3656
|
self.stack.pop()
|
|
3631
3657
|
|
|
3658
|
+
def _append_text(self, text, whitespace_before, whitespace_after):
|
|
3659
|
+
# Text which belongs together has to end up in one node, because the serializer writes every node
|
|
3660
|
+
# into a line of its own. The parser hands out the text of an element in several pieces: it reports
|
|
3661
|
+
# an ampersand which does not begin a character-reference separately (which is what happens to the
|
|
3662
|
+
# "&&" of an angular-expression) and it reports every character-reference separately. Without joining
|
|
3663
|
+
# them here, "@if (a && b) {" would become three lines and would not be parsable anymore, and
|
|
3664
|
+
# "Tom & Jerry" would lose the spaces around the ampersand.
|
|
3665
|
+
children = self._top().children
|
|
3666
|
+
if children and children[-1].text is not None:
|
|
3667
|
+
previous = children[-1]
|
|
3668
|
+
separator = " " if previous.text_ends_with_whitespace or whitespace_before else ""
|
|
3669
|
+
previous.text = previous.text + separator + text
|
|
3670
|
+
previous.text_ends_with_whitespace = whitespace_after
|
|
3671
|
+
else:
|
|
3672
|
+
node = _Node(text=text)
|
|
3673
|
+
node.text_ends_with_whitespace = whitespace_after
|
|
3674
|
+
children.append(node)
|
|
3675
|
+
|
|
3632
3676
|
def handle_data(self, data):
|
|
3633
3677
|
t = " ".join(data.split())
|
|
3634
3678
|
if t:
|
|
3635
|
-
self.
|
|
3679
|
+
self._append_text(t, data[:1].isspace(), data[-1:].isspace())
|
|
3680
|
+
else:
|
|
3681
|
+
# The piece consists of whitespace only. It carries no text, but it separates the text before it
|
|
3682
|
+
# from the text after it, which has to be kept.
|
|
3683
|
+
children = self._top().children
|
|
3684
|
+
if data and children and children[-1].text is not None:
|
|
3685
|
+
children[-1].text_ends_with_whitespace = True
|
|
3636
3686
|
|
|
3637
3687
|
def handle_entityref(self, name):
|
|
3638
|
-
self.
|
|
3688
|
+
self._append_text(f"&{name};", False, False)
|
|
3639
3689
|
|
|
3640
3690
|
def handle_charref(self, name):
|
|
3641
|
-
self.
|
|
3691
|
+
self._append_text(f"&#{name};", False, False)
|
|
3642
3692
|
|
|
3643
3693
|
def handle_comment(self, data):
|
|
3644
3694
|
self._top().children.append(_Node(raw=f"<!--{data}-->"))
|
|
@@ -2,7 +2,7 @@ ScriptCollection/AnionBuildPlatform.py,sha256=LF9b4f4iqgsjgXZjS0RHiEBw73tQANfu0O
|
|
|
2
2
|
ScriptCollection/ArbTranslationsOrganizer.py,sha256=FLJcNP6qFTQOkxL7es0Sq3O7kb_TgoRreqH-uogR4xA,12201
|
|
3
3
|
ScriptCollection/CertificateUpdater.py,sha256=bD0VhKQsD2cNRTG1kzMkhgpd0BZw7igbG30goKw5p1A,9749
|
|
4
4
|
ScriptCollection/Executables.py,sha256=Ovq6LVhtP6mqCPmBxch9WgTmePBk7F8MLyZUBkQloAE,74171
|
|
5
|
-
ScriptCollection/GeneralUtilities.py,sha256=
|
|
5
|
+
ScriptCollection/GeneralUtilities.py,sha256=znIrHp9wV3yPwLHb5300LjxQ2MTj0NJC6Z0my3LY0Mk,72759
|
|
6
6
|
ScriptCollection/HTTPMaintenanceOverheadHelper.py,sha256=TToNtyO1XzsMbBsTBf3o0xgOK0v4Jf03qw2Z0xb2nCk,2007
|
|
7
7
|
ScriptCollection/ProcessesRunner.py,sha256=Va9O-ohWoRfe4pO2gPBzc940gkM5BpP4Txcu1CmLOvg,1494
|
|
8
8
|
ScriptCollection/ProgramRunnerBase.py,sha256=eZenpiIFW1dhvSVCG7cfBs5hO4_KLlOxR7oXoSxUDmk,2286
|
|
@@ -12,7 +12,7 @@ ScriptCollection/ProgramRunnerSudo.py,sha256=ot9Ib-plQ8wejR9M2XXfnx6GR-va9k8SH1g
|
|
|
12
12
|
ScriptCollection/RepositoryDiagramGenerator.py,sha256=K_u2NW_p4ozdWD50irJEkkcDVa70TcUJpZN63TeXSLw,7092
|
|
13
13
|
ScriptCollection/RepositoryHistoryAnalyzer.py,sha256=rD8eC5lMUe5MHmCBHfYft_G-N9IbvtsFGkU7EMwPjrY,5779
|
|
14
14
|
ScriptCollection/SCLog.py,sha256=Fjf8Pdi63cXHGMxL_aI6A0dwGm7QIfrv3czjvpSUlaM,4705
|
|
15
|
-
ScriptCollection/ScriptCollectionCore.py,sha256=
|
|
15
|
+
ScriptCollection/ScriptCollectionCore.py,sha256=joDUQBVE6y_XiNwlg1sQIiRChHOObsrq1nVS9E4_2cU,305107
|
|
16
16
|
ScriptCollection/TestKind.py,sha256=jqLJwNvQeyea7SZf-UFzMC9pM0znv4do7FIC1xq8u9M,1672
|
|
17
17
|
ScriptCollection/UnassignedVariablesCheck.py,sha256=8xNcp1D5HeOLO1a1NEerq2TsnpFhw7yzYPkaay-oisY,3804
|
|
18
18
|
ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -73,8 +73,8 @@ ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=yyjWPMHQjPLkML
|
|
|
73
73
|
ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
74
74
|
ScriptCollection/TFCPS/TypeScript/TFCPS_CodeUnitSpecific_TypeScript.py,sha256=ILVhJHvwG5TvPBBqSvyACYb7W9QnWrJpxKgHu8IQu4g,9249
|
|
75
75
|
ScriptCollection/TFCPS/TypeScript/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
76
|
-
scriptcollection-4.4.
|
|
77
|
-
scriptcollection-4.4.
|
|
78
|
-
scriptcollection-4.4.
|
|
79
|
-
scriptcollection-4.4.
|
|
80
|
-
scriptcollection-4.4.
|
|
76
|
+
scriptcollection-4.4.39.dist-info/METADATA,sha256=3iHU6lrrha6CFIGnpA1QtC3Tu-rgY9F3Y1rQkD7VpPU,7646
|
|
77
|
+
scriptcollection-4.4.39.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
78
|
+
scriptcollection-4.4.39.dist-info/entry_points.txt,sha256=GNma7tN0J59EvK71su-G1w22RnZ05bXcPrELyLx3AL0,6151
|
|
79
|
+
scriptcollection-4.4.39.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
|
|
80
|
+
scriptcollection-4.4.39.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|