ScriptCollection 4.3.45__py3-none-any.whl → 4.3.46__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.
@@ -257,18 +257,18 @@ def BuildCodeUnits() -> int:
257
257
  parser.add_argument('-p','--ispremerge', required=False, default=False, action='store_true')
258
258
  parser.add_argument('-u','--assertnonewchanges', required=False, default=False, action='store_true')
259
259
  parser.add_argument('-m','--addreadytomergeflag', required=False, default=False, action='store_true')
260
-
260
+ parser.add_argument('-c','--runincontainer', required=False, default=False, action='store_true')
261
261
  args = parser.parse_args()
262
262
 
263
263
  verbosity=LogLevel(int(args.verbosity))
264
-
265
264
  repo:str=GeneralUtilities.resolve_relative_path(args.repositoryfolder,os.getcwd())
266
-
267
265
  t:TFCPS_CodeUnit_BuildCodeUnits=TFCPS_CodeUnit_BuildCodeUnits(repo,verbosity,args.targetenvironment,args.additionalargumentsfile,not args.nocache,args.ispremerge,args.assertnonewchanges,args.addreadytomergeflag)
268
- t.build_codeunits()
266
+ if args.runincontainer:
267
+ t.build_codeunits_in_container(repo)
268
+ else:
269
+ t.build_codeunits()
269
270
  return 0
270
271
 
271
-
272
272
  def BuildCodeUnitsC() -> int:
273
273
  parser = argparse.ArgumentParser()
274
274
  parser.add_argument('-r','--repositoryfolder', required=False, default=".")
@@ -283,6 +283,7 @@ def BuildCodeUnitsC() -> int:
283
283
  parser.add_argument('-u','--assertnonewchanges', required=False, default=False, action='store_true')
284
284
  parser.add_argument('-m','--addreadytomergeflag', required=False, default=False, action='store_true')
285
285
  args = parser.parse_args()
286
+
286
287
  GeneralUtilities.reconfigure_standard_input_and_outputs()
287
288
  repo:str=GeneralUtilities.resolve_relative_path(args.repositoryfolder,os.getcwd())
288
289
  verbosity=LogLevel(int(args.verbosity))
@@ -302,6 +303,7 @@ def UpdateDependencies() -> int:
302
303
  parser.add_argument('--additionalargumentsfile', required=False, default=None)
303
304
  parser.add_argument("-c",'--nocache', required=False, default=False, action='store_true')
304
305
  args = parser.parse_args()
306
+
305
307
  verbosity=LogLevel(int(args.verbosity))
306
308
  repo:str=GeneralUtilities.resolve_relative_path(args.repositoryfolder,os.getcwd())
307
309
  t:TFCPS_CodeUnit_BuildCodeUnits=TFCPS_CodeUnit_BuildCodeUnits(repo,verbosity,args.targetenvironment,args.additionalargumentsfile,not args.nocache,False,False)
@@ -320,6 +322,7 @@ def GenerateCertificateAuthority() -> int:
320
322
  parser.add_argument('--days_until_expire', required=False, default=None, type=int)
321
323
  parser.add_argument('--password', required=False, default=None)
322
324
  args = parser.parse_args()
325
+
323
326
  ScriptCollectionCore().generate_certificate_authority(os.getcwd(), args.name, args.subj_c, args.subj_st, args.subj_l, args.subj_o, args.subj_ou, args.days_until_expire, args.password)
324
327
  return 0
325
328
 
@@ -1167,26 +1170,14 @@ def SearchForSecrets() -> int:
1167
1170
  t.search_for_secrets()
1168
1171
  return 0
1169
1172
 
1170
-
1171
- def __prepare_build_pipeline(verbosity: int) -> None:
1172
- # Common preparation for the build-pipeline. The actual buildx-build (see TFCPS_CodeUnitSpecific_Docker.build)
1173
- # exports the image via "--output type=docker,dest=...tar". The default "docker"-driver can not do that unless
1174
- # the containerd-image-store is enabled on the daemon, so a "docker-container"-builder is created and selected
1175
- # here. This is required for GitLab and GitHub (and any other CI) alike, so both entry-points share this logic.
1176
- sc: ScriptCollectionCore = ScriptCollectionCore()
1177
- sc.log.loglevel = LogLevel(verbosity)
1178
- GeneralUtilities.assert_condition(sc.is_running_in_build_container(), "This function should only be run in the build container.")
1179
- sc.run_program("update-ca-certificates")
1180
- sc.run_program_argsasarray("sh",["-c","docker buildx create --name ci-builder --driver docker-container --use 2>/dev/null || docker buildx use ci-builder"])
1181
- sc.run_program("docker","buildx inspect --bootstrap")
1182
-
1183
-
1184
1173
  def PrepareBuildPipelineForGitlab() -> int:
1185
1174
  parser = argparse.ArgumentParser(description="Prepares the build-pipeline-configuration for GitLab.")
1186
1175
  verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
1187
1176
  parser.add_argument('-v', '--verbosity', required=False, default=3, help=f"Sets the loglevel. Possible values: {verbosity_values}")
1188
1177
  args = parser.parse_args()
1189
- __prepare_build_pipeline(int(args.verbosity))
1178
+ sc=ScriptCollectionCore()
1179
+ sc.log.loglevel=LogLevel(int(args.verbosity))
1180
+ sc.prepare_build_pipeline_for_gitlab()
1190
1181
  return 0
1191
1182
 
1192
1183
 
@@ -1195,7 +1186,9 @@ def PrepareBuildPipelineForGithub() -> int:
1195
1186
  verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
1196
1187
  parser.add_argument('-v', '--verbosity', required=False, default=3, help=f"Sets the loglevel. Possible values: {verbosity_values}")
1197
1188
  args = parser.parse_args()
1198
- __prepare_build_pipeline(int(args.verbosity))
1189
+ sc=ScriptCollectionCore()
1190
+ sc.log.loglevel=LogLevel(int(args.verbosity))
1191
+ sc.prepare_build_pipeline_for_github()
1199
1192
  return 0
1200
1193
 
1201
1194
 
@@ -33,12 +33,13 @@ import qrcode
33
33
  import pycdlib
34
34
  import send2trash
35
35
  from pypdf import PdfReader, PdfWriter
36
+ from packaging.version import Version
36
37
  from .GeneralUtilities import GeneralUtilities,Platform
37
38
  from .ProgramRunnerBase import ProgramRunnerBase
38
39
  from .ProgramRunnerPopen import ProgramRunnerPopen
39
40
  from .SCLog import SCLog, LogLevel
40
41
 
41
- version = "4.3.45"
42
+ version = "4.3.46"
42
43
  __version__ = version
43
44
 
44
45
  class VSCodeWorkspaceShellTask:
@@ -4163,3 +4164,52 @@ OCR-content:
4163
4164
  def is_running_in_build_container(self) ->bool:
4164
4165
  """this function is based on a convention and does not do a real check."""
4165
4166
  return os.environ.get("ISRUNNINGINBUILDCONTAINER") == "true"
4167
+
4168
+ def prepare_build_pipeline_for_gitlab(self):
4169
+ repository_folder:str=os.getcwd()
4170
+ self.__prepare_build_pipeline(repository_folder)
4171
+
4172
+ def prepare_build_pipeline_for_github(self):
4173
+ repository_folder:str=os.getcwd()
4174
+ self.assert_scbuilder_image_in_github_workflow_matches_image_definition(repository_folder)
4175
+ self.__prepare_build_pipeline(repository_folder)
4176
+
4177
+ def __prepare_build_pipeline(self,repository_folder:str) -> None:
4178
+ GeneralUtilities.assert_condition(self.is_running_in_build_container(), "This function should only be run in the build container.")
4179
+
4180
+ expected_image = self.__get_scbuilder_image_from_image_definition_file(repository_folder)
4181
+ minimal_required_scbuilder_version = Version("1.2.5")#the preparation-steps below require at least this SCBuilder-version
4182
+ defined_scbuilder_version = self.__get_version_of_scbuilder_image(expected_image)#TODO remove this check after 2026-12-31
4183
+ GeneralUtilities.assert_condition(defined_scbuilder_version >= minimal_required_scbuilder_version, f"The SCBuilder-version {defined_scbuilder_version} defined in the image-definition-file of the repository is older than the minimal required version {minimal_required_scbuilder_version}. Please update the SCBuilder-image.")
4184
+
4185
+ self.run_program("update-ca-certificates")
4186
+ self.run_program_argsasarray("sh",["-c","docker buildx create --name ci-builder --driver docker-container --use 2>/dev/null || docker buildx use ci-builder"])
4187
+ self.run_program("docker","buildx inspect --bootstrap")
4188
+
4189
+ @GeneralUtilities.check_arguments
4190
+ def assert_scbuilder_image_in_github_workflow_matches_image_definition(self, repository: str) -> None:
4191
+ """Asserts that the SCBuilder-image used in the GitHub-buildpipeline is the same as the one defined in the image-definition-file of the repository."""
4192
+ workflow_file = os.path.join(repository, ".github", "workflows", "buildpipeline.yml")
4193
+ GeneralUtilities.assert_file_exists(workflow_file, f"The file '{workflow_file}' does not exist.")
4194
+ expected_image = self.__get_scbuilder_image_from_image_definition_file(repository)
4195
+ used_images = re.findall(r"^\s*image:\s*[\"']?(\S*scbuilder:\S+?)[\"']?\s*$", GeneralUtilities.read_text_from_file(workflow_file), re.IGNORECASE | re.MULTILINE)
4196
+ GeneralUtilities.assert_condition(1==len(used_images), f"No SCBuilder-image found in '{workflow_file}'.")
4197
+ used_image = used_images[0]
4198
+ GeneralUtilities.assert_condition(used_image == expected_image, f"The SCBuilder-image '{used_image}' used in '{workflow_file}' does not match the image '{expected_image}' defined in the image-definition-file of the repository.")
4199
+
4200
+ @GeneralUtilities.check_arguments
4201
+ def __get_version_of_scbuilder_image(self, image: str) -> Version:
4202
+ """Returns the version of a SCBuilder-image-address including tag (example: "aniondev/scbuilder:v1.2.5" results in the version 1.2.5)."""
4203
+ version_match = re.search(r"\d+(\.\d+)+", image.split(":")[-1])
4204
+ GeneralUtilities.assert_condition(version_match is not None, f"The SCBuilder-image '{image}' does not contain a version-string.")
4205
+ return Version(version_match.group(0))
4206
+
4207
+ @GeneralUtilities.check_arguments
4208
+ def __get_scbuilder_image_from_image_definition_file(self, repository: str) -> str:
4209
+ """Returns the SCBuilder-image (address including tag) as defined in the image-definition-file of the repository."""
4210
+ image_definition_file = os.path.join(repository, ".ScriptCollection", "OCIImages", "ImageDefinition.csv")
4211
+ GeneralUtilities.assert_file_exists(image_definition_file, f"The file '{image_definition_file}' does not exist.")
4212
+ for line in [line.split(";") for line in GeneralUtilities.read_nonempty_lines_from_file(image_definition_file)[1:]]:#the first line is the header-line
4213
+ if line[0].lower() == "scbuilder":
4214
+ return f"{line[1]}:{line[2]}"
4215
+ raise ValueError(f"No SCBuilder-image defined in '{image_definition_file}'.")
@@ -347,6 +347,7 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
347
347
  @GeneralUtilities.check_arguments
348
348
  def do_common_tasks(self,current_codeunit_version:str,certificateGeneratorInformation:CertificateGeneratorInformationBase)-> None:
349
349
  self.do_common_tasks_base(current_codeunit_version)
350
+ self.update_year_for_dotnet_codeunit()
350
351
  codeunit_name =self.get_codeunit_name()
351
352
  codeunit_version = self.tfcps_Tools_General.get_version_of_project(self.get_repository_folder()) # Should always be the same as the project-version #TODO make this configurable from outside
352
353
  folder_of_current_file =os.path.join(self.get_codeunit_folder(),"Other")
@@ -680,7 +681,6 @@ class TFCPS_CodeUnitSpecific_DotNet_Functions(TFCPS_CodeUnitSpecific_Base):
680
681
 
681
682
  def set_dependency_version(self,name:str,new_version:str)->None:
682
683
  raise ValueError(f"Operation is not implemented.")
683
- #self.update_year_for_dotnet_codeunit()
684
684
  #csproj_file:str=os.path.join(self.get_codeunit_folder(), self.get_codeunit_name(), self.get_codeunit_name() + ".csproj")
685
685
  #self._protected_sc.update_dependencies_of_dotnet_project(csproj_file,[])#TODO set ignored codeunits
686
686
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.3.45
3
+ Version: 4.3.46
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
@@ -1,6 +1,6 @@
1
1
  ScriptCollection/AnionBuildPlatform.py,sha256=GP-jnb1GbvT8jzlH-cqnxgOzBzeUdiaWnDXtKNjsxiA,12153
2
2
  ScriptCollection/CertificateUpdater.py,sha256=dR5JpJDlZdjD4_pgMz7zCrt1IM7VfatmK6pULSczxQw,9693
3
- ScriptCollection/Executables.py,sha256=Kb4w9R1FELEj0c_ASX32Ls9qyjm3IV_5gyQkW1ENToY,67738
3
+ ScriptCollection/Executables.py,sha256=7HPkyAqil8G0WO7kukInq0ineI9Gq3PnV4BYfVlOsQA,67063
4
4
  ScriptCollection/GeneralUtilities.py,sha256=qYhrKkwbEewGIppuxYRmGhLP50C443tw7sBlwH7Mkbc,71606
5
5
  ScriptCollection/HTTPMaintenanceOverheadHelper.py,sha256=TToNtyO1XzsMbBsTBf3o0xgOK0v4Jf03qw2Z0xb2nCk,2007
6
6
  ScriptCollection/ProcessesRunner.py,sha256=yYaC95h40uszuZPggn2kK3qXIN2ZjGMCavo-NQ53ElQ,1537
@@ -9,7 +9,7 @@ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrR
9
9
  ScriptCollection/ProgramRunnerPopen.py,sha256=zVD-gZY85o8wiGFcpYAGNDl-tXaKzipl1Bkhqy2ois4,4681
10
10
  ScriptCollection/ProgramRunnerSudo.py,sha256=RXsiceQ8W6a8YDk_2BPscVbIAmDIpIxqe9WHBy2r4CM,5233
11
11
  ScriptCollection/SCLog.py,sha256=LdzSJy3NnnwYCCefz2h4tiTy4BjT8lOz3IBG_bMOg9E,4821
12
- ScriptCollection/ScriptCollectionCore.py,sha256=nVHnWHjJypfFvTmTEJSmsxQpkBMKv68xy8-Dhu5pOBI,242335
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=vHxXBcT-LKI00_N54OK4wWMsNm7T84Zsrp5ENTkEvqM,246508
13
13
  ScriptCollection/UnassignedVariablesCheck.py,sha256=v59qLQ5RRvx31ouuCW7NWZj3McWENvGBPkV5ZGBmqJE,4344
14
14
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  ScriptCollection/OCIImages/AbstractImageHandler.py,sha256=WO2M28c2tUwsXFNa2L9zqMhdlyObWm3qpPE0LdIs7SE,2315
@@ -49,7 +49,7 @@ ScriptCollection/TFCPS/Docker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
49
49
  ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationBase.py,sha256=bT6Gd5pQpZCw4OQz6HWkPCSn5z__eUUEisABLDSxd0o,200
50
50
  ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationGenerate.py,sha256=QyjOfMY22JWCvKjMelHiDWbJiWqotOfebpJpgDUaoO4,237
51
51
  ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationNoGenerate.py,sha256=i0zEGehj0sttxjjZtoq2KFSKp_ulxVyWp_ZgAhIY_So,241
52
- ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=7A1KacqFXZKGWq3p8wW3OfxRNSiSQ0L7K4gLOajinuY,46588
52
+ ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=X-yrZJBE3EvN4hciPeWZ9jkLs8dOXzNyriMUT1-GFk8,46587
53
53
  ScriptCollection/TFCPS/DotNet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
54
  ScriptCollection/TFCPS/Flutter/TFCPS_CodeUnitSpecific_Flutter.py,sha256=d8U-sIhsneMplYkG73BJRQQZh4uLoX7QiOhbnZNuOM8,8540
55
55
  ScriptCollection/TFCPS/Flutter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -63,8 +63,8 @@ ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py,sha256=Bd1gxCk9Fb
63
63
  ScriptCollection/TFCPS/Python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
64
  ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=WhOsMpJxNGqnQGA3nJ99ruyqymxBeJxCcpK98zJduTo,1680
65
65
  ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
66
- scriptcollection-4.3.45.dist-info/METADATA,sha256=0Td9MA6qKnHyygnHdCy2emQTpxI1B0zMua19eEn9YjE,7648
67
- scriptcollection-4.3.45.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
68
- scriptcollection-4.3.45.dist-info/entry_points.txt,sha256=xWOFHGufgef8jsKQ3c2pFBfM_hjweFXuxfKmghQs-VI,5814
69
- scriptcollection-4.3.45.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
70
- scriptcollection-4.3.45.dist-info/RECORD,,
66
+ scriptcollection-4.3.46.dist-info/METADATA,sha256=CEzicWf-ylGhyuAkBXLTWkLRHpcWMg0tRpeCmzBagRQ,7648
67
+ scriptcollection-4.3.46.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
68
+ scriptcollection-4.3.46.dist-info/entry_points.txt,sha256=xWOFHGufgef8jsKQ3c2pFBfM_hjweFXuxfKmghQs-VI,5814
69
+ scriptcollection-4.3.46.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
70
+ scriptcollection-4.3.46.dist-info/RECORD,,