ScriptCollection 4.2.104__py3-none-any.whl → 4.2.105__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.
@@ -863,6 +863,16 @@ def CleanToolsCache()->int:
863
863
  return 0
864
864
 
865
865
 
866
+ def DownloadCachableTools()->int:
867
+ parser = argparse.ArgumentParser(description="Downloads all tools that are stored in the global ScriptCollection-cache (for example CycloneDX-CLI, PlantUML, 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.")
868
+ parser.add_argument('-v', '--verbose', action='store_true', required=False, default=False, help="Enables verbose (debug) output.")
869
+ 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.")
870
+ args = parser.parse_args()
871
+ sc: ScriptCollectionCore = ScriptCollectionCore()
872
+ TFCPS_Tools_General(sc).download_all_cachable_tools(args.enforceupdate, args.verbose)
873
+ return 0
874
+
875
+
866
876
  def EnsureDockerNetworkIsAvailable()->int:
867
877
  sc = ScriptCollectionCore()
868
878
  parser = argparse.ArgumentParser()
@@ -39,7 +39,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
39
39
  from .ProgramRunnerPopen import ProgramRunnerPopen
40
40
  from .SCLog import SCLog, LogLevel
41
41
 
42
- version = "4.2.104"
42
+ version = "4.2.105"
43
43
  __version__ = version
44
44
 
45
45
  class VSCodeWorkspaceShellTask:
@@ -66,6 +66,56 @@ class TFCPS_Tools_General:
66
66
  else:
67
67
  raise ValueError("Unsupported operating system for cyclonedx-cli.")
68
68
 
69
+ @GeneralUtilities.check_arguments
70
+ def download_all_cachable_tools(self, enforce_update: bool = False, verbose: bool = False) -> None:
71
+ """Downloads all tools that are stored in the global ScriptCollection-cache.
72
+ Running this (for example in a build-image) lets repeated pipeline-runs avoid
73
+ rate-limits and run faster, because the tools are already present when a later
74
+ ensure_*_is_available-call needs them. Each tool is downloaded for all platforms,
75
+ so the warmed cache can be reused independent of the executing platform.
76
+ When verbose is set, the loglevel is set to debug so the per-tool log-output becomes visible."""
77
+ if verbose:
78
+ self.__sc.log.loglevel = LogLevel.Debug
79
+ self.download_cyclonedx(enforce_update)
80
+ self.download_plantuml(enforce_update)
81
+ self.download_mediamtx(enforce_update)
82
+ self.download_trufflehog(enforce_update)
83
+ self.download_openapigenerator(enforce_update)
84
+ self.download_androidappbundletool(enforce_update)
85
+
86
+ @GeneralUtilities.check_arguments
87
+ def download_cyclonedx(self, enforce_update: bool = False) -> None:
88
+ self.__sc.log.log("Download cachable tool \"CycloneDX-CLI\" into global cache...", LogLevel.Debug)
89
+ self.ensure_cyclonedxcli_is_available(enforce_update)
90
+
91
+ @GeneralUtilities.check_arguments
92
+ def download_plantuml(self, enforce_update: bool = False) -> None:
93
+ self.__sc.log.log("Download cachable tool \"PlantUML\" into global cache...", LogLevel.Debug)
94
+ self.ensure_plantuml_is_available(enforce_update)
95
+
96
+ @GeneralUtilities.check_arguments
97
+ def download_mediamtx(self, enforce_update: bool = False) -> None:
98
+ self.__sc.log.log("Download cachable tool \"MediaMTX\" into global cache...", LogLevel.Debug)
99
+ for architecture in [Platform.Windows_AMD64, Platform.Linux_AMD64, Platform.Linux_ARM64, Platform.MacOS_ARM64]:
100
+ self.__ensure_mediamtx_archive_in_global_cache(architecture, enforce_update)
101
+
102
+ @GeneralUtilities.check_arguments
103
+ def download_trufflehog(self, enforce_update: bool = False) -> None:
104
+ self.__sc.log.log("Download cachable tool \"TruffleHog\" into global cache...", LogLevel.Debug)
105
+ self.ensure_trufflehog_is_available(enforce_update)
106
+
107
+ @GeneralUtilities.check_arguments
108
+ def download_openapigenerator(self, enforce_update: bool = False) -> None:
109
+ self.__sc.log.log("Download cachable tool \"OpenAPIGenerator\" into global cache...", LogLevel.Debug)
110
+ self.ensure_openapigenerator_is_available(not enforce_update)
111
+
112
+ @GeneralUtilities.check_arguments
113
+ def download_androidappbundletool(self, enforce_update: bool = False) -> None:
114
+ self.__sc.log.log("Download cachable tool \"AndroidAppBundleTool\" into global cache...", LogLevel.Debug)
115
+ # target_folder is not used by ensure_androidappbundletool_is_available (the jar is
116
+ # always stored in the global cache); pass the cache folder as a harmless value.
117
+ self.ensure_androidappbundletool_is_available(self.__sc.get_global_cache_folder(), enforce_update)
118
+
69
119
  @GeneralUtilities.check_arguments
70
120
  def ensure_file_from_github_assets_is_available_with_retry(self, githubuser: str, githubprojectname: str, local_resource_name: str, local_filename: str, get_filename_on_github, amount_of_attempts: int = 5,enforce_update:bool=False) -> str:
71
121
  return GeneralUtilities.retry_action(lambda: self.ensure_file_from_github_assets_is_available(githubuser, githubprojectname, local_resource_name, local_filename, get_filename_on_github,enforce_update), amount_of_attempts)
@@ -683,46 +733,55 @@ class TFCPS_Tools_General:
683
733
 
684
734
  @GeneralUtilities.check_arguments
685
735
  def ensure_mediamtx_is_available(self, target_folder: str,enforce_update:bool) -> None:
686
- def download_and_extract(osname: str, osname_in_github_asset: str, extension: str,architecture:Platform):
736
+ for architecture in [Platform.Windows_AMD64, Platform.Linux_AMD64, Platform.Linux_ARM64, Platform.MacOS_ARM64]:
687
737
  resource_name: str = f"MediaMTX_{GeneralUtilities.platform_to_dash_str(architecture)}"
688
738
  resource_folder: str = os.path.join(target_folder, "Other", "Resources", resource_name)
689
739
  target_folder_extracted = os.path.join(resource_folder, "MediaMTX")
690
740
  update:bool=not os.path.isdir(target_folder_extracted) or GeneralUtilities.folder_is_empty(target_folder_extracted) or enforce_update
691
741
  if update:
692
- platform_str:str=None
693
- match architecture:
694
- case Platform.Windows_AMD64:
695
- platform_str = "windows_amd64"
696
- case Platform.Linux_ARM64:
697
- platform_str = "linux_arm64"
698
- case Platform.Linux_AMD64:
699
- platform_str = "linux_amd64"
700
- case Platform.MacOS_ARM64:
701
- platform_str = "darwin_arm64"
702
- case _:
703
- raise ValueError(f"Unknown platform: {str(architecture)}")
704
-
705
- resource_filename_name_remote:str=f"mediamtx_{platform_str}.{extension}"
706
- resource_name_local:str=f"MediaMTCX_{platform_str}"
707
- global_cache_file=os.path.join( self.__sc.get_global_cache_folder(),"Tools",resource_name_local,resource_filename_name_remote)
708
- if (not os.path.isfile( global_cache_file )) or enforce_update:
709
- self.ensure_file_from_github_assets_is_available_with_retry( "bluenviron", "mediamtx", resource_name_local, resource_filename_name_remote, lambda latest_version: f"mediamtx_{latest_version}_{platform_str}.{extension}",enforce_update=enforce_update)
710
- GeneralUtilities.assert_file_exists(global_cache_file)
711
- GeneralUtilities.assert_file_exists(global_cache_file)
742
+ global_cache_file = self.__ensure_mediamtx_archive_in_global_cache(architecture, enforce_update)
743
+ extension: str = self.__get_mediamtx_archive_extension(architecture)
712
744
  GeneralUtilities.ensure_folder_exists_and_is_empty(target_folder_extracted)
713
745
  if extension == "zip":
714
746
  with zipfile.ZipFile(global_cache_file, 'r') as zip_ref:
715
747
  zip_ref.extractall(target_folder_extracted)
716
- elif extension == "tar.gz":
748
+ elif extension == "tar.gz":
717
749
  with tarfile.open(global_cache_file, "r:gz") as tar:
718
750
  tar.extractall(path=target_folder_extracted)
719
751
  else:
720
752
  raise ValueError(f"Unknown extension: \"{extension}\"")
721
753
 
722
- download_and_extract("Windows", "windows", "zip",Platform.Windows_AMD64)
723
- download_and_extract("Linux", "linux", "tar.gz",Platform.Linux_AMD64)
724
- download_and_extract("Linux", "linux", "tar.gz",Platform.Linux_ARM64)
725
- download_and_extract("MacOS", "darwin", "tar.gz",Platform.MacOS_ARM64)
754
+ @GeneralUtilities.check_arguments
755
+ def __get_mediamtx_platform_str(self, architecture: Platform) -> str:
756
+ match architecture:
757
+ case Platform.Windows_AMD64:
758
+ return "windows_amd64"
759
+ case Platform.Linux_ARM64:
760
+ return "linux_arm64"
761
+ case Platform.Linux_AMD64:
762
+ return "linux_amd64"
763
+ case Platform.MacOS_ARM64:
764
+ return "darwin_arm64"
765
+ case _:
766
+ raise ValueError(f"Unknown platform: {str(architecture)}")
767
+
768
+ @GeneralUtilities.check_arguments
769
+ def __get_mediamtx_archive_extension(self, architecture: Platform) -> str:
770
+ if architecture == Platform.Windows_AMD64:
771
+ return "zip"
772
+ return "tar.gz"
773
+
774
+ @GeneralUtilities.check_arguments
775
+ def __ensure_mediamtx_archive_in_global_cache(self, architecture: Platform, enforce_update: bool) -> str:
776
+ platform_str: str = self.__get_mediamtx_platform_str(architecture)
777
+ extension: str = self.__get_mediamtx_archive_extension(architecture)
778
+ resource_filename_name_remote: str = f"mediamtx_{platform_str}.{extension}"
779
+ resource_name_local: str = f"MediaMTCX_{platform_str}"
780
+ global_cache_file = os.path.join(self.__sc.get_global_cache_folder(), "Tools", resource_name_local, resource_filename_name_remote)
781
+ if (not os.path.isfile(global_cache_file)) or enforce_update:
782
+ self.ensure_file_from_github_assets_is_available_with_retry("bluenviron", "mediamtx", resource_name_local, resource_filename_name_remote, lambda latest_version: f"mediamtx_{latest_version}_{platform_str}.{extension}", enforce_update=enforce_update)
783
+ GeneralUtilities.assert_file_exists(global_cache_file)
784
+ return global_cache_file
726
785
 
727
786
  @GeneralUtilities.check_arguments
728
787
  def clone_repository_as_resource(self, local_repository_folder: str, remote_repository_link: str, resource_name: str, repository_subname: str = None,use_cache:bool=True) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.2.104
3
+ Version: 4.2.105
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
@@ -6,7 +6,7 @@ Other/QualityCheck/RunTestcases.py,sha256=3vJBquOr9q1DhF4648FhY_sXS-DV_l193mE_O9
6
6
  Other/Reference/GenerateReference.py,sha256=MFzu7U1OHxgecYDi7WSulO8XRGBsgkdqV_r_jkyVF7c,369
7
7
  ScriptCollection/AnionBuildPlatform.py,sha256=OnL0V0jFGrT3ZbCRamy4LBmeGUu-cBFMbk1bhs_S64k,11781
8
8
  ScriptCollection/CertificateUpdater.py,sha256=dR5JpJDlZdjD4_pgMz7zCrt1IM7VfatmK6pULSczxQw,9693
9
- ScriptCollection/Executables.py,sha256=yWKA8yn7G3ZaNgnUjSGVTF_yAQl-NBVBxEMipWfq3YY,46799
9
+ ScriptCollection/Executables.py,sha256=YtNmvkz1ASf1VLwo6B38BMm49mGV6IpRcVV0zjvfCOo,47711
10
10
  ScriptCollection/GeneralUtilities.py,sha256=4BmzJhTPAZmKQd5YlMuX0E5Dl6fhuVkmVaCpST0WzRk,67654
11
11
  ScriptCollection/HTTPMaintenanceOverheadHelper.py,sha256=TToNtyO1XzsMbBsTBf3o0xgOK0v4Jf03qw2Z0xb2nCk,2007
12
12
  ScriptCollection/ProcessesRunner.py,sha256=o5raxIt3lknNPoPrjNzJ2bprRPJ3SnL0rrR7crraD7E,1523
@@ -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=OjaX-610PHu_SdLs1unvSKRCgr7YkJeYb5e1px8y2i8,188793
18
+ ScriptCollection/ScriptCollectionCore.py,sha256=AO24YBlf78Uz8YdQNt-LgPKxwy6PDmmhaGrjNmzaK28,188793
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
@@ -38,7 +38,7 @@ ScriptCollection/TFCPS/TFCPS_Generic.py,sha256=Tpzgiz6m3-cYCkObZOG5Uu7oM-EMoWFzz
38
38
  ScriptCollection/TFCPS/TFCPS_MergeToMain.py,sha256=Vwj7IWmvwIICXiv7I-c6MkxbqlRWCEwzaKW6dgEUjCM,7480
39
39
  ScriptCollection/TFCPS/TFCPS_MergeToStable.py,sha256=xVPer8EGH5vhTT3_mpTMJJxWLB3aLxIcyTxKHODMbYg,22201
40
40
  ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py,sha256=f0Uq1cA_4LvmL72cal0crrbKF6PcxL13D9wBKuQ1YBw,2328
41
- ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=h2goAG1BYSdtJq_9olyOm_nyt1UNxZxUXss-2MddRB0,101968
41
+ ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=l42hYiDwcafEGIUCXmeyxr7XMzQ01MUEpElVvB1zhKY,105372
42
42
  ScriptCollection/TFCPS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py,sha256=TU9An7feBsSMardrtr0byYijQfYWxA_LB27yVNsOqy8,12762
44
44
  ScriptCollection/TFCPS/Docker/__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.104.dist-info/METADATA,sha256=k7vUxTicHpbYJ9UonUXyaJy7cf_a_bZ7oW8ndQUVAM0,7697
295
- scriptcollection-4.2.104.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
296
- scriptcollection-4.2.104.dist-info/entry_points.txt,sha256=wzcO3R2IXAbYjDCev4cF8q1Yn-2ZCNJhiud_NzzJ9RM,4901
297
- scriptcollection-4.2.104.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
298
- scriptcollection-4.2.104.dist-info/RECORD,,
294
+ scriptcollection-4.2.105.dist-info/METADATA,sha256=FwJgtaMYwy4d9adTu8devQa6Cd6SLpLGiauglhE2q4o,7697
295
+ scriptcollection-4.2.105.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
296
+ scriptcollection-4.2.105.dist-info/entry_points.txt,sha256=_vnVTrGJc_z-DTPLvaYyyOpDEQLz0bdO2OLN3_ZmeR8,4978
297
+ scriptcollection-4.2.105.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
298
+ scriptcollection-4.2.105.dist-info/RECORD,,
@@ -18,6 +18,7 @@ sccreateisofilewithobfuscatedfiles = ScriptCollection.Executables:CreateISOFileW
18
18
  sccreaterelease = ScriptCollection.Executables:CreateRelease
19
19
  sccreatesimplemergewithoutrelease = ScriptCollection.Executables:CreateSimpleMergeWithoutRelease
20
20
  sccurrentuserhaselevatedprivileges = ScriptCollection.Executables:CurrentUserHasElevatedPrivileges
21
+ scdownloadcachabletools = ScriptCollection.Executables:DownloadCachableTools
21
22
  scensuredockernetworkisavailable = ScriptCollection.Executables:EnsureDockerNetworkIsAvailable
22
23
  scespoc = ScriptCollection.Executables:Espoc
23
24
  scextractpdfpages = ScriptCollection.Executables:ExtractPDFPages