ScriptCollection 4.4.73__py3-none-any.whl → 5.0.0__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.
Files changed (31) hide show
  1. ScriptCollection/Executables.py +14 -14
  2. ScriptCollection/GeneralUtilities.py +11 -11
  3. ScriptCollection/OCIImages/AbstractImageHandler.py +3 -3
  4. ScriptCollection/OCIImages/ConcreteImageHandlers/ImageHandlerDebian.py +3 -3
  5. ScriptCollection/OCIImages/ConcreteImageHandlers/ImageHandlerDebianSlim.py +3 -3
  6. ScriptCollection/OCIImages/ConcreteImageHandlers/ImageHandlerGeneric.py +3 -3
  7. ScriptCollection/OCIImages/ConcreteImageHandlers/ImageHandlerGenericV.py +3 -3
  8. ScriptCollection/OCIImages/ConcreteImageHandlers/ImageHandlerGitlabCE.py +3 -3
  9. ScriptCollection/OCIImages/ConcreteImageHandlers/ImageHandlerGitlabEE.py +3 -3
  10. ScriptCollection/OCIImages/OCIImageManager.py +24 -24
  11. ScriptCollection/ProgramRunnerPopen.py +4 -2
  12. ScriptCollection/ProgramRunnerSudo.py +11 -5
  13. ScriptCollection/Resources/CultureChooser/CultureChooser.js +0 -0
  14. ScriptCollection/Resources/CultureChooser/index.html +0 -0
  15. ScriptCollection/Resources/Dependencies/JRE/Version.txt +0 -0
  16. ScriptCollection/Resources/Dependencies/OpenAPIGenerator/Version.txt +0 -0
  17. ScriptCollection/Resources/MaintenanceSite/MaintenanceSite.html +0 -0
  18. ScriptCollection/ScriptCollectionCore.py +40 -28
  19. ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py +3 -3
  20. ScriptCollection/TFCPS/Flutter/TFCPS_CodeUnitSpecific_Flutter.py +6 -6
  21. ScriptCollection/TFCPS/NodeJS/TFCPS_CodeUnitSpecific_NodeJS.py +3 -3
  22. ScriptCollection/TFCPS/PlantUMLRenderer.py +1 -1
  23. ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py +13 -13
  24. ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py +172 -7
  25. ScriptCollection/TFCPS/TFCPS_Tools_General.py +34 -16
  26. ScriptCollection/TFCPS/TFCPS_VisualRegressionTests.py +1 -1
  27. {scriptcollection-4.4.73.dist-info → scriptcollection-5.0.0.dist-info}/METADATA +3 -1
  28. {scriptcollection-4.4.73.dist-info → scriptcollection-5.0.0.dist-info}/RECORD +26 -26
  29. {scriptcollection-4.4.73.dist-info → scriptcollection-5.0.0.dist-info}/entry_points.txt +2 -2
  30. {scriptcollection-4.4.73.dist-info → scriptcollection-5.0.0.dist-info}/WHEEL +0 -0
  31. {scriptcollection-4.4.73.dist-info → scriptcollection-5.0.0.dist-info}/top_level.txt +0 -0
@@ -9,7 +9,7 @@ import traceback
9
9
  import shutil
10
10
  import keyboard
11
11
  from .ScriptCollectionCore import ScriptCollectionCore
12
- from .GeneralUtilities import GeneralUtilities, VersionEcholon
12
+ from .GeneralUtilities import GeneralUtilities, VersionEchelon
13
13
  from .SCLog import LogLevel, SCLog
14
14
  from .TFCPS.TFCPS_CodeUnit_BuildCodeUnits import TFCPS_CodeUnit_BuildCodeUnits
15
15
  from .TFCPS.TFCPS_OCIImageSecretScan import TFCPS_OCIImageSecretScan
@@ -822,7 +822,7 @@ def PrintOSName() -> int:
822
822
  return 0
823
823
 
824
824
 
825
- def PrintCurrecntWorkingDirectory() -> int:
825
+ def PrintCurrentWorkingDirectory() -> int:
826
826
  GeneralUtilities.write_message_to_stdout(os.getcwd())
827
827
  return 0
828
828
 
@@ -1064,7 +1064,7 @@ def OCRAnalysisOfRepository() -> int:
1064
1064
 
1065
1065
 
1066
1066
  def UpdateImagesInDockerComposeFile() -> int:
1067
- echolon_values = ", ".join(f"{e.value}={e.name}" for e in VersionEcholon)
1067
+ echelon_values = ", ".join(f"{e.value}={e.name}" for e in VersionEchelon)
1068
1068
  parser = argparse.ArgumentParser(
1069
1069
  description=(
1070
1070
  "This function updates images in a Docker Compose file.\n"
@@ -1078,20 +1078,20 @@ def UpdateImagesInDockerComposeFile() -> int:
1078
1078
  formatter_class=argparse.RawDescriptionHelpFormatter,
1079
1079
  )
1080
1080
  parser.add_argument('-f', '--file', required=False, default="./docker-compose.yml")
1081
- parser.add_argument('-e', '--echolon', type=int, required=False, default=None, help=f"Default version-echolon applied to all images that have no specific override. Possible values: {echolon_values}. If not set, the image-handler default is used.")
1082
- parser.add_argument('-i', '--image-echolon', action='append', default=[], help="Per-image echolon override in the format 'imagename=echolon' (e.g. 'Debian=3'). Can be specified multiple times.")
1081
+ parser.add_argument('-e', '--echelon', type=int, required=False, default=None, help=f"Default version-echelon applied to all images that have no specific override. Possible values: {echelon_values}. If not set, the image-handler default is used.")
1082
+ parser.add_argument('-i', '--image-echelon', action='append', default=[], help="Per-image echelon override in the format 'imagename=echelon' (e.g. 'Debian=3'). Can be specified multiple times.")
1083
1083
  args = parser.parse_args()
1084
1084
  sc = ScriptCollectionCore()
1085
1085
  file = GeneralUtilities.resolve_relative_path(args.file, os.getcwd())
1086
- default_echolon: VersionEcholon = VersionEcholon(args.echolon) if args.echolon is not None else None
1087
- per_image_echolons: dict[str, VersionEcholon] = {}
1088
- for item in args.image_echolon:
1086
+ default_echelon: VersionEchelon = VersionEchelon(args.echelon) if args.echelon is not None else None
1087
+ per_image_echelons: dict[str, VersionEchelon] = {}
1088
+ for item in args.image_echelon:
1089
1089
  if "=" not in item:
1090
- raise ValueError(f"Invalid value for --image-echolon: '{item}'. Expected format: 'imagename=echolon'.")
1091
- name_part, echolon_part = item.split("=", 1)
1092
- per_image_echolons[name_part.strip()] = VersionEcholon(int(echolon_part.strip()))
1090
+ raise ValueError(f"Invalid value for --image-echelon: '{item}'. Expected format: 'imagename=echelon'.")
1091
+ name_part, echelon_part = item.split("=", 1)
1092
+ per_image_echelons[name_part.strip()] = VersionEchelon(int(echelon_part.strip()))
1093
1093
  oci = OCIImageManager(sc)
1094
- oci.update_image_in_docker_compose_file(file, default_echolon, per_image_echolons)
1094
+ oci.update_image_in_docker_compose_file(file, default_echelon, per_image_echelons)
1095
1095
  return 0
1096
1096
 
1097
1097
 
@@ -1205,14 +1205,14 @@ def CleanToolsCache()->int:
1205
1205
  return 0
1206
1206
 
1207
1207
 
1208
- def DownloadCachableTools()->int:
1208
+ def DownloadCacheableTools()->int:
1209
1209
  parser = argparse.ArgumentParser(description="Downloads all tools that are stored in the global ScriptCollection-cache (for example CycloneDX-CLI, MediaMTX, TruffleHog, OpenAPIGenerator and AndroidAppBundleTool). Running this - for example in a build-image - lets repeated pipeline-runs avoid rate-limits and run faster because the tools are already present.")
1210
1210
  parser.add_argument('-v', '--verbose', action='store_true', required=False, default=False, help="Enables verbose (debug) output.")
1211
1211
  parser.add_argument('-e', '--enforceupdate', action='store_true', required=False, default=False, help="Re-download the tools even if they are already present in the cache.")
1212
1212
  #TODO for each tool which will be installed allow to specify a specific version number
1213
1213
  args = parser.parse_args()
1214
1214
  sc: ScriptCollectionCore = ScriptCollectionCore()
1215
- TFCPS_Tools_General(sc).download_all_cachable_tools(args.enforceupdate, args.verbose)
1215
+ TFCPS_Tools_General(sc).download_all_cacheable_tools(args.enforceupdate, args.verbose)
1216
1216
  return 0
1217
1217
 
1218
1218
 
@@ -30,7 +30,7 @@ import psutil
30
30
  from defusedxml.minidom import parse
31
31
  from OpenSSL import crypto
32
32
 
33
- class VersionEcholon(Enum):
33
+ class VersionEchelon(Enum):
34
34
  LatestPatch = 0
35
35
  LatestPatchOrLatestMinor = 1
36
36
  LatestPatchOrLatestMinorOrNextMajor = 2
@@ -230,20 +230,20 @@ class GeneralUtilities:
230
230
 
231
231
  @staticmethod
232
232
  @check_arguments
233
- def choose_version(available_versions:list[str],current_version:str,echolon:VersionEcholon) -> str:
234
- match echolon:
235
- case VersionEcholon.LatestPatch:
233
+ def choose_version(available_versions:list[str],current_version:str,echelon:VersionEchelon) -> str:
234
+ match echelon:
235
+ case VersionEchelon.LatestPatch:
236
236
  return GeneralUtilities.get_latest_version(GeneralUtilities.filter_versions_by_prefix(available_versions,f"{GeneralUtilities.get_major_part_of_version(current_version)}.{GeneralUtilities.get_minor_part_of_version(current_version)}."))
237
- case VersionEcholon.LatestPatchOrLatestMinor:
237
+ case VersionEchelon.LatestPatchOrLatestMinor:
238
238
  return GeneralUtilities.get_latest_version(GeneralUtilities.filter_versions_by_prefix(available_versions,f"{GeneralUtilities.get_major_part_of_version(current_version)}."))
239
- case VersionEcholon.LatestPatchOrLatestMinorOrNextMajor:
239
+ case VersionEchelon.LatestPatchOrLatestMinorOrNextMajor:
240
240
  raise ValueError("not implemented")#TODO
241
- case VersionEcholon.LatestVersion:
241
+ case VersionEchelon.LatestVersion:
242
242
  return GeneralUtilities.get_latest_version(available_versions)
243
- case VersionEcholon.NoUpdate:
243
+ case VersionEchelon.NoUpdate:
244
244
  return current_version
245
245
  case _:
246
- raise ValueError("Unknown echolon-value: "+str(echolon))
246
+ raise ValueError("Unknown echelon-value: "+str(echelon))
247
247
 
248
248
  @staticmethod
249
249
  @check_arguments
@@ -1711,14 +1711,14 @@ class GeneralUtilities:
1711
1711
  def escape_yaml_string_value(str_value: str) -> str:
1712
1712
  """For input 'a"b\\c' this function returns 'a\\"b\\\\c'. This function does not add surrounding quotes. It only escapes the characters inside the string."""
1713
1713
  result= GeneralUtilities.escape_json_string_value(str_value)
1714
- #do other adaptions here if desired/required
1714
+ #do other adaptations here if desired/required
1715
1715
  return result
1716
1716
 
1717
1717
  @staticmethod
1718
1718
  @check_arguments
1719
1719
  def escape_yaml_property_value(str_value: str) -> str:
1720
1720
  result= GeneralUtilities.escape_json_property_value(str_value)
1721
- #do other adaptions here if desired/required
1721
+ #do other adaptations here if desired/required
1722
1722
  return result
1723
1723
 
1724
1724
 
@@ -1,6 +1,6 @@
1
1
  from abc import ABC, abstractmethod
2
2
  from packaging.version import Version
3
- from ..GeneralUtilities import VersionEcholon
3
+ from ..GeneralUtilities import VersionEchelon
4
4
 
5
5
  class AbstractImageHandler(ABC):
6
6
  """An image-handler knows the format of the tags of certain images: which tags of a registry are candidates for an update of a
@@ -22,12 +22,12 @@ class AbstractImageHandler(ABC):
22
22
  raise NotImplementedError()#because it is abstract
23
23
 
24
24
  @abstractmethod
25
- def get_default_echolon_for_update(self,image_name:str)->VersionEcholon:
25
+ def get_default_echelon_for_update(self,image_name:str)->VersionEchelon:
26
26
  raise NotImplementedError()#because it is abstract
27
27
 
28
28
  def get_latest_tag_custom(self,image_name:str,current_tag:str,candidate_tags:list[str])->str:
29
29
  """Determines the tag the image should be updated to using an image-specific custom algorithm.
30
30
  candidate_tags contains the current tag and all available tags which have the same format as the current tag.
31
- This is used when the echolon VersionEcholon.CustomAlgorithm is selected.
31
+ This is used when the echelon VersionEchelon.CustomAlgorithm is selected.
32
32
  Image-handlers which want to support a custom algorithm must override this method."""
33
33
  raise ValueError(f"Image-handler \"{type(self).__name__}\" does not define a custom algorithm for determining the latest version of image \"{image_name}\".")
@@ -1,4 +1,4 @@
1
- from ...GeneralUtilities import VersionEcholon
1
+ from ...GeneralUtilities import VersionEchelon
2
2
  from ..AbstractTagPatternImageHandler import AbstractTagPatternImageHandler
3
3
 
4
4
  class ImageHandlerDebian(AbstractTagPatternImageHandler):
@@ -7,5 +7,5 @@ class ImageHandlerDebian(AbstractTagPatternImageHandler):
7
7
  def _protected_accepts_tag_parts(self,image_name:str,prefix:str,suffix:str)->bool:
8
8
  return image_name.lower()=="debian" and prefix=="" and suffix==""
9
9
 
10
- def get_default_echolon_for_update(self,image_name:str)->VersionEcholon:
11
- return VersionEcholon.LatestPatch
10
+ def get_default_echelon_for_update(self,image_name:str)->VersionEchelon:
11
+ return VersionEchelon.LatestPatch
@@ -1,4 +1,4 @@
1
- from ...GeneralUtilities import VersionEcholon
1
+ from ...GeneralUtilities import VersionEchelon
2
2
  from ..AbstractTagPatternImageHandler import AbstractTagPatternImageHandler
3
3
 
4
4
  class ImageHandlerDebianSlim(AbstractTagPatternImageHandler):
@@ -7,5 +7,5 @@ class ImageHandlerDebianSlim(AbstractTagPatternImageHandler):
7
7
  def _protected_accepts_tag_parts(self,image_name:str,prefix:str,suffix:str)->bool:
8
8
  return image_name.lower()=="debian" and prefix=="" and suffix=="-slim"
9
9
 
10
- def get_default_echolon_for_update(self,image_name:str)->VersionEcholon:
11
- return VersionEcholon.LatestPatch
10
+ def get_default_echelon_for_update(self,image_name:str)->VersionEchelon:
11
+ return VersionEchelon.LatestPatch
@@ -1,4 +1,4 @@
1
- from ...GeneralUtilities import VersionEcholon
1
+ from ...GeneralUtilities import VersionEchelon
2
2
  from ..AbstractTagPatternImageHandler import AbstractTagPatternImageHandler
3
3
 
4
4
  class ImageHandlerGeneric(AbstractTagPatternImageHandler):
@@ -7,5 +7,5 @@ class ImageHandlerGeneric(AbstractTagPatternImageHandler):
7
7
  def _protected_accepts_tag_parts(self,image_name:str,prefix:str,suffix:str)->bool:
8
8
  return prefix==""
9
9
 
10
- def get_default_echolon_for_update(self,image_name:str)->VersionEcholon:
11
- return VersionEcholon.LatestVersion
10
+ def get_default_echelon_for_update(self,image_name:str)->VersionEchelon:
11
+ return VersionEchelon.LatestVersion
@@ -1,4 +1,4 @@
1
- from ...GeneralUtilities import VersionEcholon
1
+ from ...GeneralUtilities import VersionEchelon
2
2
  from ..AbstractTagPatternImageHandler import AbstractTagPatternImageHandler
3
3
 
4
4
  class ImageHandlerGenericV(AbstractTagPatternImageHandler):
@@ -7,5 +7,5 @@ class ImageHandlerGenericV(AbstractTagPatternImageHandler):
7
7
  def _protected_accepts_tag_parts(self,image_name:str,prefix:str,suffix:str)->bool:
8
8
  return prefix=="v"
9
9
 
10
- def get_default_echolon_for_update(self,image_name:str)->VersionEcholon:
11
- return VersionEcholon.LatestVersion
10
+ def get_default_echelon_for_update(self,image_name:str)->VersionEchelon:
11
+ return VersionEchelon.LatestVersion
@@ -1,5 +1,5 @@
1
1
  from packaging.version import Version
2
- from ...GeneralUtilities import VersionEcholon
2
+ from ...GeneralUtilities import VersionEchelon
3
3
  from ..AbstractImageHandler import AbstractImageHandler
4
4
 
5
5
  class ImageHandlerGitlabCE(AbstractImageHandler):
@@ -15,5 +15,5 @@ class ImageHandlerGitlabCE(AbstractImageHandler):
15
15
  def tag_to_version(self,image_name:str,tag:str)->Version:
16
16
  raise NotImplementedError(f"Updating the tag of image \"{image_name}\" (GitLab ce) is not implemented yet.")
17
17
 
18
- def get_default_echolon_for_update(self,image_name:str)->VersionEcholon:
19
- return VersionEcholon.CustomAlgorithm
18
+ def get_default_echelon_for_update(self,image_name:str)->VersionEchelon:
19
+ return VersionEchelon.CustomAlgorithm
@@ -1,5 +1,5 @@
1
1
  from packaging.version import Version
2
- from ...GeneralUtilities import VersionEcholon
2
+ from ...GeneralUtilities import VersionEchelon
3
3
  from ..AbstractImageHandler import AbstractImageHandler
4
4
 
5
5
  class ImageHandlerGitlabEE(AbstractImageHandler):
@@ -15,5 +15,5 @@ class ImageHandlerGitlabEE(AbstractImageHandler):
15
15
  def tag_to_version(self,image_name:str,tag:str)->Version:
16
16
  raise NotImplementedError(f"Updating the tag of image \"{image_name}\" (GitLab ee) is not implemented yet.")
17
17
 
18
- def get_default_echolon_for_update(self,image_name:str)->VersionEcholon:
19
- return VersionEcholon.CustomAlgorithm
18
+ def get_default_echelon_for_update(self,image_name:str)->VersionEchelon:
19
+ return VersionEchelon.CustomAlgorithm
@@ -3,7 +3,7 @@ import yaml
3
3
  from packaging.version import Version
4
4
  from ..GeneralUtilities import GeneralUtilities
5
5
  from ..ScriptCollectionCore import ScriptCollectionCore
6
- from ..GeneralUtilities import VersionEcholon
6
+ from ..GeneralUtilities import VersionEchelon
7
7
  from ..SCLog import LogLevel
8
8
  from .AbstractImageHandler import AbstractImageHandler
9
9
  from .OCIRegistryClient import OCIRegistryClient
@@ -217,7 +217,7 @@ class OCIImageManager:
217
217
  self.__sc.log.log(f"The tag of image \"{image_name}\" is not updated because no custom registry is defined for it in \"{self.get_global_docker_image_registries_file()}\".",LogLevel.Warning)
218
218
  else:
219
219
  try:
220
- tag=self.get_latest_tag_of_image(image_name,addresses_to_check,default_tag,VersionEcholon.LatestVersion)
220
+ tag=self.get_latest_tag_of_image(image_name,addresses_to_check,default_tag,VersionEchelon.LatestVersion)
221
221
  except Exception as e:
222
222
  self.__sc.log.log(f"Could not determine the latest tag of image \"{image_name}\" using the registries {', '.join(addresses_to_check)}. Reason: {type(e).__name__}: {str(e)}",LogLevel.Warning)
223
223
  if tag!=default_tag:
@@ -238,44 +238,44 @@ class OCIImageManager:
238
238
  return result
239
239
 
240
240
  @GeneralUtilities.check_arguments
241
- def get_latest_tag_of_image(self,image_name:str,registry_addresses:list[str],current_tag:str,echolon:VersionEcholon)->str:
242
- """Returns the tag the image should be updated to according to the echolon, considering the tags of all given registry-addresses
241
+ def get_latest_tag_of_image(self,image_name:str,registry_addresses:list[str],current_tag:str,echelon:VersionEchelon)->str:
242
+ """Returns the tag the image should be updated to according to the echelon, considering the tags of all given registry-addresses
243
243
  (always without tag, for example "docker.io/library/debian").
244
244
  Only tags with the same format as the current tag are candidates (see AbstractImageHandler.tag_has_same_format). The current tag is
245
245
  always a candidate, so the result is never a downgrade."""
246
246
  image_handler=self.get_image_handler(image_name,current_tag)
247
- if echolon==VersionEcholon.NoUpdate:
247
+ if echelon==VersionEchelon.NoUpdate:
248
248
  return current_tag
249
249
  candidate_tags:list[str]=[current_tag]
250
250
  for registry_address in registry_addresses:
251
251
  for tag in self.registry_client.get_tags(registry_address):
252
252
  if tag not in candidate_tags and image_handler.tag_has_same_format(image_name,tag,current_tag):
253
253
  candidate_tags.append(tag)
254
- if echolon==VersionEcholon.CustomAlgorithm:
254
+ if echelon==VersionEchelon.CustomAlgorithm:
255
255
  return image_handler.get_latest_tag_custom(image_name,current_tag,candidate_tags)
256
256
  tags_by_version:dict[Version,str]={}
257
257
  for tag in candidate_tags:
258
258
  #setdefault, because different tags can represent the same version (like "13.4" and "13.04"); then the first one (the current tag if affected) is used.
259
259
  tags_by_version.setdefault(image_handler.tag_to_version(image_name,tag),tag)
260
260
  current_version=image_handler.tag_to_version(image_name,current_tag)
261
- return tags_by_version[self.choose_version(set(tags_by_version.keys()),current_version,echolon)]
261
+ return tags_by_version[self.choose_version(set(tags_by_version.keys()),current_version,echelon)]
262
262
 
263
263
  @GeneralUtilities.check_arguments
264
- def choose_version(self,available_versions:set[Version],current_version:Version,echolon:VersionEcholon)->Version:
265
- """Returns the version out of the available versions which should be used according to the echolon.
266
- available_versions must contain current_version. The echolons NoUpdate and CustomAlgorithm are not handled here because they do
264
+ def choose_version(self,available_versions:set[Version],current_version:Version,echelon:VersionEchelon)->Version:
265
+ """Returns the version out of the available versions which should be used according to the echelon.
266
+ available_versions must contain current_version. The echelons NoUpdate and CustomAlgorithm are not handled here because they do
267
267
  not choose out of the available versions."""
268
268
  GeneralUtilities.assert_condition(current_version in available_versions,f"The available versions do not contain the current version {current_version}.")
269
269
  result:Version=None
270
- match echolon:
271
- case VersionEcholon.LatestPatch:#caution: this never updates the minor or major version
270
+ match echelon:
271
+ case VersionEchelon.LatestPatch:#caution: this never updates the minor or major version
272
272
  #take the latest available patch-version for the current minor-version of the image.
273
273
  result=self.__get_latest_patch(available_versions,current_version.major,current_version.minor)
274
- case VersionEcholon.LatestPatchOrLatestMinor:#caution: this never updates the major version
274
+ case VersionEchelon.LatestPatchOrLatestMinor:#caution: this never updates the major version
275
275
  #take the latest available patch-version for the current minor-version of the image if there is a newer patch version available.
276
276
  #otherwise take the latest available patch-version of the next available minor-version within the current major-version.
277
277
  result=self.__get_latest_patch_or_next_minor(available_versions,current_version)
278
- case VersionEcholon.LatestPatchOrLatestMinorOrNextMajor:#usual case for images which have complex migrations sometimes, like GitLab or NextCloud
278
+ case VersionEchelon.LatestPatchOrLatestMinorOrNextMajor:#usual case for images which have complex migrations sometimes, like GitLab or NextCloud
279
279
  #like LatestPatchOrLatestMinor, but if there is neither a newer patch nor a newer minor-version available within the current major-version
280
280
  #then take the latest available patch-version of the lowest minor-version of the next available major-version.
281
281
  result=self.__get_latest_patch_or_next_minor(available_versions,current_version)
@@ -284,11 +284,11 @@ class OCIImageManager:
284
284
  if next_major is not None:
285
285
  lowest_minor=min({v.minor for v in available_versions if v.major==next_major})
286
286
  result=self.__get_latest_patch(available_versions,next_major,lowest_minor)
287
- case VersionEcholon.LatestVersion:#usual case for most images
287
+ case VersionEchelon.LatestVersion:#usual case for most images
288
288
  #take the latest available version of the image.
289
289
  result=max(available_versions)
290
290
  case _:
291
- raise ValueError(f"Echolon \"{echolon.name}\" does not choose a version out of the available versions.")
291
+ raise ValueError(f"Echelon \"{echelon.name}\" does not choose a version out of the available versions.")
292
292
  return result
293
293
 
294
294
  @GeneralUtilities.check_arguments
@@ -343,9 +343,9 @@ class OCIImageManager:
343
343
  return result
344
344
 
345
345
  @GeneralUtilities.check_arguments
346
- def update_image_in_docker_compose_file(self,docker_compose_file:str,default_echolon:VersionEcholon=None,per_image_echolons:dict[str,VersionEcholon]=None,verbose:bool=False)->None:
347
- if per_image_echolons is None:
348
- per_image_echolons = {}
346
+ def update_image_in_docker_compose_file(self,docker_compose_file:str,default_echelon:VersionEchelon=None,per_image_echelons:dict[str,VersionEchelon]=None,verbose:bool=False)->None:
347
+ if per_image_echelons is None:
348
+ per_image_echelons = {}
349
349
  if verbose:
350
350
  self.__sc.log.log(f"Checking images in docker-compose-file \"{docker_compose_file}\" for updates.",LogLevel.Information)
351
351
  for service,service_information in self.get_images_used_in_docker_compose_file(docker_compose_file).items():
@@ -353,12 +353,12 @@ class OCIImageManager:
353
353
  image_address=service_information[1]
354
354
  current_tag=service_information[2]
355
355
  image_handler=self.get_image_handler(image_name,current_tag)
356
- effective_echolon=per_image_echolons.get(image_name,default_echolon)
357
- if effective_echolon is None:
358
- effective_echolon=image_handler.get_default_echolon_for_update(image_name)
356
+ effective_echelon=per_image_echelons.get(image_name,default_echelon)
357
+ if effective_echelon is None:
358
+ effective_echelon=image_handler.get_default_echelon_for_update(image_name)
359
359
  if verbose:
360
- self.__sc.log.log(f"Service \"{service}\": checking image \"{image_address}:{current_tag}\" using echolon \"{effective_echolon.name}\".",LogLevel.Information)
361
- new_tag=self.get_latest_tag_of_image(image_name,[image_address],current_tag,effective_echolon)
360
+ self.__sc.log.log(f"Service \"{service}\": checking image \"{image_address}:{current_tag}\" using echelon \"{effective_echelon.name}\".",LogLevel.Information)
361
+ new_tag=self.get_latest_tag_of_image(image_name,[image_address],current_tag,effective_echelon)
362
362
  if new_tag != current_tag:
363
363
  new_image_reference = f"{image_address}:{new_tag}"
364
364
  if verbose:
@@ -26,10 +26,12 @@ class ProgramRunnerPopen(ProgramRunnerBase):
26
26
  def run_program_argsasarray_async_helper(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive: bool = False, env_vars: dict = None) -> Popen:
27
27
  arguments_for_process, env = self.__get_process_start_information(program, arguments_as_array, env_vars)
28
28
  try:
29
+ # errors="replace": a program can write bytes which are not valid in the used encoding (for example gpgv writes a name with
30
+ # an umlaut in latin-1). Without replacing them, reading the output would fail at the first such byte and the output would be lost.
29
31
  if interactive:
30
- result = Popen(arguments_for_process, cwd=working_directory, stdout=PIPE, stderr=PIPE, shell=False, text=True, stdin=sys.stdin, env=env) # pylint: disable=consider-using-with
32
+ result = Popen(arguments_for_process, cwd=working_directory, stdout=PIPE, stderr=PIPE, shell=False, text=True, errors="replace", stdin=sys.stdin, env=env) # pylint: disable=consider-using-with
31
33
  else:
32
- result = Popen(arguments_for_process, cwd=working_directory, stdout=PIPE, stderr=PIPE, shell=False, text=True, env=env) # pylint: disable=consider-using-with
34
+ result = Popen(arguments_for_process, cwd=working_directory, stdout=PIPE, stderr=PIPE, shell=False, text=True, errors="replace", env=env) # pylint: disable=consider-using-with
33
35
  except FileNotFoundError as fileNotFoundError:
34
36
  raise FileNotFoundError(f"Starting '{program}' in '{working_directory}' resulted in a FileNotFoundError: '{str(fileNotFoundError)}'")
35
37
  except NotADirectoryError as notADirectoryError:
@@ -1,3 +1,4 @@
1
+ import io
1
2
  from subprocess import Popen
2
3
  from .GeneralUtilities import GeneralUtilities
3
4
  from .ProgramRunnerBase import ProgramRunnerBase
@@ -18,23 +19,25 @@ class SudoPopenReader:
18
19
 
19
20
 
20
21
  class SudoPopen:
22
+ """Represents an already terminated program-run with the interface of a subprocess.Popen which was created with text=True.
23
+ stdout and stderr are text-streams (and not bytes), because ScriptCollectionCore reads them line by line with readline until it gets an empty string."""
21
24
  returncode: int = None
22
25
  stdout_str: str = None
23
26
  stderr_str: str = None
24
27
  pid: int = None
25
- stdout: bytes = None
26
- stderr: bytes = None
28
+ stdout: io.StringIO = None
29
+ stderr: io.StringIO = None
27
30
 
28
31
  def __init__(self, exitcode: int, stdout: str, stderr: str, pid: int):
29
32
  self.returncode: int = exitcode
30
33
  self.stdout_str: str = stdout
31
- self.stdout = str.encode(self.stdout_str)
34
+ self.stdout = io.StringIO(self.stdout_str)
32
35
  self.stderr_str: str = stderr
33
- self.stderr = str.encode(self.stderr_str)
36
+ self.stderr = io.StringIO(self.stderr_str)
34
37
  self.pid = pid
35
38
 
36
39
  def communicate(self):
37
- return (self.stdout, self.stderr)
40
+ return (self.stdout_str, self.stderr_str)
38
41
 
39
42
  def wait(self):
40
43
  return self.returncode
@@ -42,6 +45,9 @@ class SudoPopen:
42
45
  def poll(self) -> object:
43
46
  return self.returncode
44
47
 
48
+ def kill(self) -> None:
49
+ pass # the program-run is already terminated when this object is created, so there is nothing to kill.
50
+
45
51
  def __enter__(self):
46
52
  return self
47
53
 
File without changes
File without changes