ScriptCollection 4.2.123__py3-none-any.whl → 4.2.124__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.
@@ -1,6 +1,7 @@
1
1
  import argparse
2
2
  import os
3
3
  from .TFCPS.TFCPS_CodeUnit_BuildCodeUnits import TFCPS_CodeUnit_BuildCodeUnits
4
+ from .TFCPS.TFCPS_Tools_General import TFCPS_Tools_General
4
5
  from .SCLog import LogLevel
5
6
  from .GeneralUtilities import GeneralUtilities
6
7
  from .ScriptCollectionCore import ScriptCollectionCore
@@ -55,7 +56,7 @@ class AnionBuildPlatform:
55
56
  build_repo_folder:str=self.__configuration.build_repositories_folder
56
57
  GeneralUtilities.assert_condition(build_repo_folder.endswith("Build"),f"buildrepositoriesfolder {build_repo_folder} must end with 'Build'")
57
58
  self.__sc.assert_is_git_repository(build_repo_folder)
58
- product_name=os.path.basename(build_repo_folder)[:-len("Build")]
59
+ product_name = TFCPS_Tools_General(self.__sc).get_product_name(build_repo_folder)
59
60
  repository:str=os.path.join(build_repo_folder,"Submodules",product_name)
60
61
  self.__sc.assert_is_git_repository(repository)
61
62
  reference_repo:str=os.path.join(build_repo_folder,"Submodules",product_name+"Reference")
@@ -289,7 +289,7 @@ def BuildCodeUnitsC() -> int:
289
289
  verbosity=LogLevel(int(args.verbosity))
290
290
  t:TFCPS_CodeUnit_BuildCodeUnits=TFCPS_CodeUnit_BuildCodeUnits(repo,verbosity,args.targetenvironment,args.additionalargumentsfile,not args.nocache,args.ispremerge,args.assertnonewchanges)
291
291
  t.build_codeunits_in_container()
292
- return 1#TODO
292
+ return 0
293
293
 
294
294
  def UpdateDependencies() -> int:
295
295
  parser = argparse.ArgumentParser()
@@ -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.123"
41
+ version = "4.2.124"
42
42
  __version__ = version
43
43
 
44
44
  class VSCodeWorkspaceShellTask:
@@ -256,7 +256,18 @@ class TFCPS_CodeUnitSpecific_Base(ABC):
256
256
 
257
257
  @GeneralUtilities.check_arguments
258
258
  def get_product_name(self)->str:
259
- return os.path.basename(self.get_repository_folder())
259
+ return self.__read_product_information_property("producttitle")
260
+
261
+ @GeneralUtilities.check_arguments
262
+ def get_remote_address(self)->str:
263
+ return self.__read_product_information_property("remoteaddress")
264
+
265
+ @GeneralUtilities.check_arguments
266
+ def __read_product_information_property(self, property_name: str) -> str:
267
+ product_information_file = os.path.join(self.get_repository_folder(), ".ScriptCollection", "ProductInformation.xml")
268
+ GeneralUtilities.assert_file_exists(product_information_file)
269
+ root: etree._ElementTree = etree.parse(product_information_file)
270
+ return str(root.xpath(f'/cps:productinformation/cps:{property_name}/text()', namespaces={'cps': 'https://projects.aniondev.de/PublicProjects/Common/ProjectTemplates/-/tree/main/Conventions/RepositoryStructure/CommonProjectStructure'})[0])
260
271
 
261
272
  @GeneralUtilities.check_arguments
262
273
  def get_current_folder(self)->str:
@@ -1,6 +1,7 @@
1
1
  import os
2
2
  import json
3
3
  from datetime import datetime, timedelta,timezone
4
+ import xmlschema
4
5
  import yaml
5
6
  from ..GeneralUtilities import GeneralUtilities
6
7
  from ..ScriptCollectionCore import ScriptCollectionCore
@@ -40,6 +41,12 @@ class TFCPS_CodeUnit_BuildCodeUnits:
40
41
  if self.__assert_no_new_changes:
41
42
  self.sc.assert_no_uncommitted_changes(self.repository,"Can not build codeunit: There are uncommitted changes in the repository.")
42
43
 
44
+ product_information_file = os.path.join(self.repository, ".ScriptCollection", "ProductInformation.xml")
45
+ try:
46
+ xmlschema.validate(product_information_file, "https://projects.aniondev.de/PublicProjects/Common/ProjectTemplates/-/raw/main/Conventions/RepositoryStructure/CommonProjectStructure/projectinformation.xsd")
47
+ except Exception as exception:
48
+ self.sc.log.log_exception(f"'{product_information_file}' could not be validated against the XSD:", exception, LogLevel.Warning)
49
+
43
50
  #check if changelog exists
44
51
  changelog_file=os.path.join(self.repository,"Other","Resources","Changelog",f"v{self.tfcps_tools_general.get_version_of_project(self.repository)}.md")
45
52
  GeneralUtilities.assert_file_exists(changelog_file,f"Changelogfile \"{changelog_file}\" does not exist. Try to create it for example using \"sccreatechangelogentry -m ...\".")
@@ -105,7 +112,40 @@ class TFCPS_CodeUnit_BuildCodeUnits:
105
112
 
106
113
  @GeneralUtilities.check_arguments
107
114
  def build_codeunits_in_container(self) -> None:
108
- raise ValueError("Not implemented.")
115
+ container_repository_folder = "/Workspace/Repository"
116
+ image = self.tfcps_tools_general.oci_image_manager.get_registry_address_for_image_with_default_tag(self.repository, "SCBuilder")
117
+
118
+ #build the scbuildcodeunits-arguments based on the current state (analogous to the arguments accepted by the scbuildcodeunits-executable)
119
+ scbuildcodeunits_arguments = ["-r", container_repository_folder, "-v", str(int(self.sc.log.loglevel)), "-e", self.target_environment_type]
120
+ if not self.__use_cache:
121
+ scbuildcodeunits_arguments.append("-c")
122
+ if self.__is_pre_merge:
123
+ scbuildcodeunits_arguments.append("-p")
124
+ if self.__assert_no_new_changes:
125
+ scbuildcodeunits_arguments.append("-u")
126
+ if GeneralUtilities.string_has_content(self.additionalargumentsfile):
127
+ scbuildcodeunits_arguments = scbuildcodeunits_arguments + ["-a", self.__translate_path_into_container(self.additionalargumentsfile, container_repository_folder)]
128
+
129
+ #run scbuildcodeunits inside the SCBuilder-image. the repository is mounted into the container and the docker-socket is forwarded because codeunit-builds often start containers (for example local test-services).
130
+ docker_arguments = [
131
+ "run", "--rm",
132
+ "-v", f"{self.repository}:{container_repository_folder}",
133
+ "-v", "/var/run/docker.sock:/var/run/docker.sock",
134
+ "-w", container_repository_folder,
135
+ image,
136
+ "scbuildcodeunits",
137
+ ] + scbuildcodeunits_arguments
138
+ self.sc.log.log(f"Build codeunits in container using image \"{image}\"...")
139
+ self.sc.run_program_argsasarray("docker", docker_arguments, print_live_output=True)
140
+
141
+ @GeneralUtilities.check_arguments
142
+ def __translate_path_into_container(self, host_path: str, container_repository_folder: str) -> str:
143
+ normalized_repository = os.path.normpath(self.repository)
144
+ normalized_path = os.path.normpath(host_path)
145
+ if normalized_path.startswith(normalized_repository):
146
+ relative_path = os.path.relpath(normalized_path, normalized_repository).replace(os.sep, "/")
147
+ return f"{container_repository_folder}/{relative_path}"
148
+ return host_path
109
149
 
110
150
  @GeneralUtilities.check_arguments
111
151
  def __translate(self) -> None:
@@ -101,7 +101,7 @@ class TFCPS_MergeToMain_CLI:
101
101
  build_repo=GeneralUtilities.resolve_relative_path("../../..",file)
102
102
  sc.assert_is_git_repository(build_repo)
103
103
 
104
- default_product_name=os.path.basename(build_repo)[:-len("Build")]
104
+ default_product_name=TFCPS_Tools_General(sc).get_product_name(build_repo)
105
105
 
106
106
  if args.mergesourcebranch is not None:
107
107
  default_merge_source_branch=args.mergesourcebranch#other/next-release
@@ -55,8 +55,7 @@ class TFCPS_MergeToStable:
55
55
  def merge_to_stable_branch(self):
56
56
  self.sc.log.loglevel=self.createRelease_configuration.log_level
57
57
  self.sc.log.log("Merge to stable-branch...")
58
- product_name:str=os.path.basename(self.createRelease_configuration.repository)
59
-
58
+ product_name:str=self.tFCPS_Tools_General.get_product_name(self.createRelease_configuration.repository)
60
59
  if self.sc.git_get_commit_id(self.createRelease_configuration.repository,self.createRelease_configuration.source_branch)==self.sc.git_get_commit_id(self.createRelease_configuration.repository,self.createRelease_configuration.target_branch):
61
60
  self.sc.log.log("Source- and target-branch are on the same commit.")
62
61
  return
@@ -306,7 +305,7 @@ class TFCPS_MergeToStable_CLI:
306
305
  build_repo=GeneralUtilities.resolve_relative_path("../../..",file)
307
306
  sc.assert_is_git_repository(build_repo)
308
307
 
309
- default_product_name=os.path.basename(build_repo)[:-len("Build")]
308
+ default_product_name=TFCPS_Tools_General(sc).get_product_name(build_repo)
310
309
 
311
310
  if args.verbosity is not None:
312
311
  default_loglevel=LogLevel(int( args.verbosity))
@@ -395,6 +395,13 @@ class TFCPS_Tools_General:
395
395
  root: etree._ElementTree = etree.parse(codeunit_file)
396
396
  return str(root.xpath('//cps:properties/@description', namespaces={'cps': 'https://projects.aniondev.de/PublicProjects/Common/ProjectTemplates/-/tree/main/Conventions/RepositoryStructure/CommonProjectStructure'})[0])
397
397
 
398
+ @GeneralUtilities.check_arguments
399
+ def get_product_name(self, repository_folder: str) -> str:
400
+ product_information_file = os.path.join(repository_folder, ".ScriptCollection", "ProductInformation.xml")
401
+ GeneralUtilities.assert_file_exists(product_information_file)
402
+ root: etree._ElementTree = etree.parse(product_information_file)
403
+ return str(root.xpath('/cps:productinformation/cps:producttitle/text()', namespaces={'cps': 'https://projects.aniondev.de/PublicProjects/Common/ProjectTemplates/-/tree/main/Conventions/RepositoryStructure/CommonProjectStructure'})[0])
404
+
398
405
  @GeneralUtilities.check_arguments
399
406
  def set_constant(self, codeunit_folder: str, constantname: str, constant_value: str, documentationsummary: str = None, constants_valuefile: str = None) -> None:
400
407
  self.assert_is_codeunit_folder(codeunit_folder)
@@ -828,7 +835,7 @@ class TFCPS_Tools_General:
828
835
 
829
836
  @GeneralUtilities.check_arguments
830
837
  def ensure_certificate_authority_for_development_purposes_is_generated(self, product_folder: str):
831
- product_name: str = os.path.basename(product_folder)
838
+ product_name: str = self.get_product_name(product_folder)
832
839
  now = GeneralUtilities.get_now()
833
840
  ca_name = f"{product_name}CA_{now.year:04}{now.month:02}{now.day:02}{now.hour:02}{now.min:02}{now.second:02}"
834
841
  ca_folder = os.path.join(product_folder, "Other", "Resources", "CA")
@@ -848,7 +855,7 @@ class TFCPS_Tools_General:
848
855
  @GeneralUtilities.check_arguments
849
856
  def generate_certificate_for_development_purposes_for_product(self, repository_folder: str):
850
857
  self.__sc.assert_is_git_repository(repository_folder)
851
- product_name = os.path.basename(repository_folder)
858
+ product_name = self.get_product_name(repository_folder)
852
859
  ca_folder: str = os.path.join(repository_folder, "Other", "Resources", "CA")
853
860
  self.__generate_certificate_for_development_purposes(product_name, os.path.join(repository_folder, "Other", "Resources"), ca_folder, None)
854
861
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.2.123
3
+ Version: 4.2.124
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
- ScriptCollection/AnionBuildPlatform.py,sha256=OnL0V0jFGrT3ZbCRamy4LBmeGUu-cBFMbk1bhs_S64k,11781
1
+ ScriptCollection/AnionBuildPlatform.py,sha256=Ug9bUMJObWZXGFUX0SyiNFc1dNTwUkWp2vxdCBA7ag8,11858
2
2
  ScriptCollection/CertificateUpdater.py,sha256=dR5JpJDlZdjD4_pgMz7zCrt1IM7VfatmK6pULSczxQw,9693
3
- ScriptCollection/Executables.py,sha256=WGzo5IB3hcd8EB9O5uK_34dxrsm8tlk9CR6vUy3YKWA,48615
3
+ ScriptCollection/Executables.py,sha256=HaqvT6W3LAT2UOAqDPqPK-R6cT3x6d_2T24OQPyz9Zg,48610
4
4
  ScriptCollection/GeneralUtilities.py,sha256=4BmzJhTPAZmKQd5YlMuX0E5Dl6fhuVkmVaCpST0WzRk,67654
5
5
  ScriptCollection/HTTPMaintenanceOverheadHelper.py,sha256=TToNtyO1XzsMbBsTBf3o0xgOK0v4Jf03qw2Z0xb2nCk,2007
6
6
  ScriptCollection/ProcessesRunner.py,sha256=o5raxIt3lknNPoPrjNzJ2bprRPJ3SnL0rrR7crraD7E,1523
@@ -9,7 +9,7 @@ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrR
9
9
  ScriptCollection/ProgramRunnerPopen.py,sha256=8tP0xWKeRYoGlaNB3iUh4o61O-tKtcxrS7IUqtU85C4,4091
10
10
  ScriptCollection/ProgramRunnerSudo.py,sha256=4lxbUFMIWMbthM5Q_QaFjvZfAsNpKlXeqfEbiofg_DI,5109
11
11
  ScriptCollection/SCLog.py,sha256=8TRy1LeYMsPOIuWUcnUNNbO5pd-cNBS-3cn-kdzP8FU,4768
12
- ScriptCollection/ScriptCollectionCore.py,sha256=jcdW3vlDqBGbXWL6apkEyLDhl2E9vSaxZElWCEH6tAE,205530
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=yMt73V_E_uK_KN9Y6QD0uaG6PdFe9fbbpPDcS_NItHE,205530
13
13
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  ScriptCollection/OCIImages/AbstractImageHandler.py,sha256=o129UYDtLymCRjMZBP9Puaj19ueMHoNt6UTLspfnaRc,1758
15
15
  ScriptCollection/OCIImages/OCIImageManager.py,sha256=TaSGXaDH4KWxN8Iv30m9zyitcaDYhEZVEPdKO3C3zfs,10712
@@ -24,15 +24,15 @@ ScriptCollection/OCIImages/ConcreteImageHandlers/__init__.py,sha256=47DEQpj8HBSa
24
24
  ScriptCollection/Resources/CultureChooser/CultureChooser.js,sha256=5-4pwGDq5j1UnpTZy850ZMoxlM9tYPeu781QpZBtCWM,951
25
25
  ScriptCollection/Resources/CultureChooser/index.html,sha256=gxQzbrSp4WU52TqN-gcBEtz2gJXmmM14OwTSFtFVRvw,276
26
26
  ScriptCollection/Resources/MaintenanceSite/MaintenanceSite.html,sha256=CX9S1bdOz6xU2aGfr03tJRGczQrlpn-IeODc15d5kc0,232
27
- ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=EMNDgkUem87aH1csz7eoSBBEKkiZMLZqZhnxKSPQWe0,27845
27
+ ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=he_UT4-WeHMjoMghwFVBfAHFeV_kNzALhGCvi5kTqTU,28649
28
28
  ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py,sha256=wLOCoMJVkhqKilJrYA_8KYesh68oUPQQnGwhxBSwZbA,9217
29
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=sviIDzCIooaCRRH9wAw2fS9DjjpZmUDrA4NGsQK1Gqs,17027
29
+ ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=884wbxBvYIIqx-5pT0AMDZXYodWuLBETEpvSX-ci5lk,19774
30
30
  ScriptCollection/TFCPS/TFCPS_CreateRelease.py,sha256=yqGstRjRfVVGbqrcBgtYStqth2x2SvBb3y2Ht8GsuMQ,6554
31
31
  ScriptCollection/TFCPS/TFCPS_Generic.py,sha256=Tpzgiz6m3-cYCkObZOG5Uu7oM-EMoWFzzRpLl3Lblqo,2023
32
- ScriptCollection/TFCPS/TFCPS_MergeToMain.py,sha256=Vwj7IWmvwIICXiv7I-c6MkxbqlRWCEwzaKW6dgEUjCM,7480
33
- ScriptCollection/TFCPS/TFCPS_MergeToStable.py,sha256=xVPer8EGH5vhTT3_mpTMJJxWLB3aLxIcyTxKHODMbYg,22201
32
+ ScriptCollection/TFCPS/TFCPS_MergeToMain.py,sha256=WgQ8V5T5gOmzJGP6J1NRH5wfQno5zO5I8ZhSVm72C6g,7488
33
+ ScriptCollection/TFCPS/TFCPS_MergeToStable.py,sha256=mgGDXzphexHPjsrFvf_tx_wueLoOXi42j0AhjQ9S7Y4,22233
34
34
  ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py,sha256=f0Uq1cA_4LvmL72cal0crrbKF6PcxL13D9wBKuQ1YBw,2328
35
- ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=PtYjrIDUtOIM7k6G5V-4DYqVNGNLw44y0u-4owDZbAY,106842
35
+ ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=j0erTZMbLKj50pXOEAxkqi9fXEWN3o6YwhLJdfCki2o,107454
36
36
  ScriptCollection/TFCPS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py,sha256=wS2yzYUmJ4m0cf6cBYVTHsiXSXfYhHoLFFy8x6yEQvY,19573
38
38
  ScriptCollection/TFCPS/Docker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -53,8 +53,8 @@ ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py,sha256=fqGhXNx8tK
53
53
  ScriptCollection/TFCPS/Python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
54
  ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=WhOsMpJxNGqnQGA3nJ99ruyqymxBeJxCcpK98zJduTo,1680
55
55
  ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
56
- scriptcollection-4.2.123.dist-info/METADATA,sha256=qM6SKiEiWbsAiqVekIPRe1Hk9bRzEW_ts-GikpezFW4,7697
57
- scriptcollection-4.2.123.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
58
- scriptcollection-4.2.123.dist-info/entry_points.txt,sha256=ySZ09rptnBxyfpU-K62zmoUFH-0xWZUxzoPScoXubrg,5045
59
- scriptcollection-4.2.123.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
60
- scriptcollection-4.2.123.dist-info/RECORD,,
56
+ scriptcollection-4.2.124.dist-info/METADATA,sha256=b8JhjgFrmzeT7EDO_r4qAae0bG2AJwQZu5u05ocgbQg,7697
57
+ scriptcollection-4.2.124.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
58
+ scriptcollection-4.2.124.dist-info/entry_points.txt,sha256=ySZ09rptnBxyfpU-K62zmoUFH-0xWZUxzoPScoXubrg,5045
59
+ scriptcollection-4.2.124.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
60
+ scriptcollection-4.2.124.dist-info/RECORD,,