ScriptCollection 3.5.164__py3-none-any.whl → 4.0.11__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/CertificateUpdater.py +1 -1
- ScriptCollection/Executables.py +69 -21
- ScriptCollection/GeneralUtilities.py +22 -7
- ScriptCollection/ProgramRunnerBase.py +0 -5
- ScriptCollection/ProgramRunnerEpew.py +27 -5
- ScriptCollection/ProgramRunnerMock.py +2 -0
- ScriptCollection/SCLog.py +5 -5
- ScriptCollection/ScriptCollectionCore.py +106 -120
- {scriptcollection-3.5.164.dist-info → scriptcollection-4.0.11.dist-info}/METADATA +1 -1
- scriptcollection-4.0.11.dist-info/RECORD +17 -0
- ScriptCollection/TasksForCommonProjectStructure.py +0 -3626
- scriptcollection-3.5.164.dist-info/RECORD +0 -17
- {scriptcollection-3.5.164.dist-info → scriptcollection-4.0.11.dist-info}/WHEEL +0 -0
- {scriptcollection-3.5.164.dist-info → scriptcollection-4.0.11.dist-info}/entry_points.txt +0 -0
- {scriptcollection-3.5.164.dist-info → scriptcollection-4.0.11.dist-info}/top_level.txt +0 -0
@@ -94,7 +94,7 @@ class CertificateUpdater:
|
|
94
94
|
try:
|
95
95
|
GeneralUtilities.write_message_to_stdout(GeneralUtilities.get_line())
|
96
96
|
GeneralUtilities.write_message_to_stdout(f"Process domain {domain}")
|
97
|
-
self.__sc.run_program("docker", f"container rm {certbot_container_name}", self.__current_folder, throw_exception_if_exitcode_is_not_zero=False
|
97
|
+
self.__sc.run_program("docker", f"container rm {certbot_container_name}", self.__current_folder, throw_exception_if_exitcode_is_not_zero=False)
|
98
98
|
certificate_for_domain_already_exists = os.path.isfile(f"{self.__letsencrypt_folder}/renewal/{domain}.conf")
|
99
99
|
if certificate_for_domain_already_exists:
|
100
100
|
GeneralUtilities.write_message_to_stdout(f"Update certificate for domain {domain}")
|
ScriptCollection/Executables.py
CHANGED
@@ -3,14 +3,15 @@ import os
|
|
3
3
|
import argparse
|
4
4
|
import time
|
5
5
|
import traceback
|
6
|
-
import sys
|
6
|
+
#import sys
|
7
7
|
import shutil
|
8
8
|
import keyboard
|
9
|
-
from .TasksForCommonProjectStructure import TasksForCommonProjectStructure
|
10
9
|
from .ScriptCollectionCore import ScriptCollectionCore
|
11
10
|
from .GeneralUtilities import GeneralUtilities
|
11
|
+
from .SCLog import LogLevel
|
12
12
|
from .ImageUpdater import ImageUpdater, VersionEcholon
|
13
|
-
|
13
|
+
from .TFCPS.TFCPS_CodeUnit_BuildCodeUnits import TFCPS_CodeUnit_BuildCodeUnits
|
14
|
+
from .TFCPS.TFCPS_Tools_General import TFCPS_Tools_General
|
14
15
|
|
15
16
|
def FilenameObfuscator() -> int:
|
16
17
|
parser = argparse.ArgumentParser(description=''''Obfuscates the names of all files in the given folder.
|
@@ -259,37 +260,79 @@ def HealthCheck() -> int:
|
|
259
260
|
def BuildCodeUnit() -> int:
|
260
261
|
parser = argparse.ArgumentParser()
|
261
262
|
parser.add_argument('--codeunitfolder', required=False, default=".")
|
262
|
-
|
263
|
+
verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
|
264
|
+
parser.add_argument('-v', '--verbosity', required=False, default=3, help=f"Sets the loglevel. Possible values: {verbosity_values}")
|
263
265
|
parser.add_argument('--targetenvironment', required=False, default="QualityCheck")
|
264
266
|
parser.add_argument('--additionalargumentsfile', required=False, default=None)
|
265
267
|
parser.add_argument('--assume_dependent_codeunits_are_already_built', type=GeneralUtilities.string_to_boolean, const=True, default=False, nargs='?')
|
266
|
-
args = parser.parse_args()
|
267
|
-
TasksForCommonProjectStructure(
|
268
|
-
|
268
|
+
#args = parser.parse_args()
|
269
|
+
#t=TasksForCommonProjectStructure(args)
|
270
|
+
#t.build_codeunit(args.codeunitfolder, args.targetenvironment, args.additionalargumentsfile, False, None, args.assume_dependent_codeunits_are_already_built, sys.argv)
|
271
|
+
#return 0
|
272
|
+
return 1#TODO
|
269
273
|
|
270
274
|
|
271
275
|
def BuildCodeUnits() -> int:
|
272
276
|
parser = argparse.ArgumentParser()
|
277
|
+
|
273
278
|
parser.add_argument('--repositoryfolder', required=False, default=".")
|
274
|
-
|
279
|
+
verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
|
280
|
+
parser.add_argument('-v', '--verbosity', required=False, default=3, help=f"Sets the loglevel. Possible values: {verbosity_values}")
|
275
281
|
parser.add_argument('--targetenvironment', required=False, default="QualityCheck")
|
276
282
|
parser.add_argument('--additionalargumentsfile', required=False, default=None)
|
277
283
|
parser.add_argument('--removeuncommittedfiles', required=False, default=False, action='store_true')
|
284
|
+
parser.add_argument("-c",'--nocache', required=False, default=False, action='store_true')
|
285
|
+
parser.add_argument('--ispremerge', required=False, default=False, action='store_true')
|
286
|
+
|
278
287
|
args = parser.parse_args()
|
279
|
-
|
288
|
+
|
289
|
+
verbosity=LogLevel(int(args.verbosity))
|
290
|
+
|
291
|
+
repo:str=args.repositoryfolder
|
292
|
+
if not os.path.isabs(args.repositoryfolder):
|
293
|
+
repo=GeneralUtilities.resolve_relative_path(args.repositoryfolder,os.getcwd())
|
294
|
+
|
295
|
+
t:TFCPS_CodeUnit_BuildCodeUnits=TFCPS_CodeUnit_BuildCodeUnits(repo,verbosity,args.targetenvironment,args.additionalargumentsfile,not args.nocache,args.ispremerge)
|
296
|
+
t.build_codeunits()
|
280
297
|
return 0
|
281
298
|
|
282
299
|
|
283
300
|
def BuildCodeUnitsC() -> int:
|
284
301
|
parser = argparse.ArgumentParser()
|
285
302
|
parser.add_argument('--repositoryfolder', required=False, default=".")
|
286
|
-
|
303
|
+
verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
|
304
|
+
parser.add_argument('-v', '--verbosity', required=False, default=3, help=f"Sets the loglevel. Possible values: {verbosity_values}")
|
287
305
|
parser.add_argument('--targetenvironment', required=False, default="QualityCheck")
|
288
306
|
parser.add_argument('--additionalargumentsfile', required=False, default=None)
|
289
307
|
parser.add_argument('--image', required=False, default="scbuilder:latest")
|
290
|
-
args = parser.parse_args()
|
308
|
+
#args = parser.parse_args()
|
291
309
|
GeneralUtilities.reconfigure_standrd_input_and_outputs()
|
292
|
-
TasksForCommonProjectStructure(
|
310
|
+
#t=TasksForCommonProjectStructure(args)
|
311
|
+
#t.build_codeunitsC(args.repositoryfolder, args.image, args.targetenvironment, args.additionalargumentsfile, sys.argv)
|
312
|
+
#return 0
|
313
|
+
return 1#TODO
|
314
|
+
|
315
|
+
def UpdateDependencies() -> int:
|
316
|
+
parser = argparse.ArgumentParser()
|
317
|
+
|
318
|
+
parser.add_argument('--repositoryfolder', required=False, default=".")
|
319
|
+
verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
|
320
|
+
parser.add_argument('-v', '--verbosity', required=False, default=3, help=f"Sets the loglevel. Possible values: {verbosity_values}")
|
321
|
+
parser.add_argument('--targetenvironment', required=False, default="QualityCheck")
|
322
|
+
parser.add_argument('--additionalargumentsfile', required=False, default=None)
|
323
|
+
parser.add_argument('--removeuncommittedfiles', required=False, default=False, action='store_true')
|
324
|
+
parser.add_argument("-c",'--nocache', required=False, default=False, action='store_true')
|
325
|
+
|
326
|
+
args = parser.parse_args()
|
327
|
+
|
328
|
+
verbosity=LogLevel(int(args.verbosity))
|
329
|
+
|
330
|
+
repo:str=args.repositoryfolder
|
331
|
+
if not os.path.isabs(args.repositoryfolder):
|
332
|
+
repo=GeneralUtilities.resolve_relative_path(args.repositoryfolder,os.getcwd())
|
333
|
+
|
334
|
+
t:TFCPS_CodeUnit_BuildCodeUnits=TFCPS_CodeUnit_BuildCodeUnits(repo,verbosity,args.targetenvironment,args.additionalargumentsfile,not args.nocache,False)
|
335
|
+
t.update_dependencies()
|
293
336
|
return 0
|
294
337
|
|
295
338
|
|
@@ -389,7 +432,8 @@ def CreateChangelogEntry() -> int:
|
|
389
432
|
folder = args.repositorypath
|
390
433
|
else:
|
391
434
|
folder = GeneralUtilities.resolve_relative_path(args.repositorypath, os.getcwd())
|
392
|
-
|
435
|
+
t=TFCPS_Tools_General(ScriptCollectionCore())
|
436
|
+
t.create_changelog_entry(folder, args.message, args.commit, args.force)
|
393
437
|
return 0
|
394
438
|
|
395
439
|
|
@@ -607,13 +651,14 @@ def NpmI() -> int:
|
|
607
651
|
parser.add_argument('-d', '--directory', required=False, default=".")
|
608
652
|
parser.add_argument('-f', '--force', action='store_true', required=False, default=False)
|
609
653
|
parser.add_argument('-v', '--verbose', action='store_true', required=False, default=False)
|
654
|
+
parser.add_argument('-c', '--nocache', action='store_true', required=False, default=False)
|
610
655
|
args = parser.parse_args()
|
611
656
|
if os.path.isabs(args.directory):
|
612
657
|
folder = args.directory
|
613
|
-
else:
|
658
|
+
else:
|
614
659
|
folder = GeneralUtilities.resolve_relative_path(args.directory, os.getcwd())
|
615
|
-
t =
|
616
|
-
t.do_npm_install(folder, args.force,
|
660
|
+
t = TFCPS_Tools_General(ScriptCollectionCore())
|
661
|
+
t.do_npm_install(folder, args.force,not args.nocache)
|
617
662
|
return 0
|
618
663
|
|
619
664
|
|
@@ -747,10 +792,11 @@ def SetFileContent() -> int:
|
|
747
792
|
def GenerateTaskfileFromWorkspacefile() -> int:
|
748
793
|
parser = argparse.ArgumentParser(description="Generates a taskfile.yml-file from a .code-workspace-file")
|
749
794
|
parser.add_argument('-f', '--repositoryfolder', required=True)
|
750
|
-
args = parser.parse_args()
|
751
|
-
t = TasksForCommonProjectStructure()
|
752
|
-
t.generate_tasksfile_from_workspace_file(args.repositoryfolder)
|
753
|
-
return 0
|
795
|
+
#args = parser.parse_args()
|
796
|
+
#t = TasksForCommonProjectStructure()
|
797
|
+
#t.generate_tasksfile_from_workspace_file(args.repositoryfolder)
|
798
|
+
#return 0
|
799
|
+
return 1#TODO
|
754
800
|
|
755
801
|
|
756
802
|
def UpdateTimestampInFile() -> int:
|
@@ -782,5 +828,7 @@ def LOC() -> int:
|
|
782
828
|
excluded_patterns = excluded_patterns + sc.default_excluded_patterns_for_loc
|
783
829
|
if args.excluded_pattern is not None:
|
784
830
|
excluded_patterns = excluded_patterns + args.excluded_pattern
|
785
|
-
|
831
|
+
if args.verbose:
|
832
|
+
sc.log.loglevel=LogLevel.Debug
|
833
|
+
GeneralUtilities.write_message_to_stdout(str(sc.get_lines_of_code(folder, excluded_patterns)))
|
786
834
|
return 0
|
@@ -1082,24 +1082,39 @@ class GeneralUtilities:
|
|
1082
1082
|
|
1083
1083
|
@staticmethod
|
1084
1084
|
@check_arguments
|
1085
|
-
def assert_file_exists(file: str) ->
|
1086
|
-
|
1085
|
+
def assert_file_exists(file: str,message=None) -> None:
|
1086
|
+
if message is None:
|
1087
|
+
message=f"File '{file}' does not exist."
|
1088
|
+
GeneralUtilities.assert_condition(os.path.isfile(file), message)
|
1087
1089
|
|
1088
1090
|
@staticmethod
|
1089
1091
|
@check_arguments
|
1090
|
-
def assert_file_does_not_exist(file: str) ->
|
1091
|
-
|
1092
|
+
def assert_file_does_not_exist(file: str,message=None) -> None:
|
1093
|
+
if message is None:
|
1094
|
+
message=f"File '{file}' exists."
|
1095
|
+
GeneralUtilities.assert_condition(not os.path.isfile(file), message)
|
1092
1096
|
|
1093
1097
|
@staticmethod
|
1094
1098
|
@check_arguments
|
1095
|
-
def assert_folder_exists(folder: str) ->
|
1096
|
-
|
1099
|
+
def assert_folder_exists(folder: str,message=None) -> None:
|
1100
|
+
if message is None:
|
1101
|
+
message=f"Folder '{folder}' does not exist."
|
1102
|
+
GeneralUtilities.assert_condition(os.path.isdir(folder),message )
|
1097
1103
|
|
1098
1104
|
@staticmethod
|
1099
1105
|
@check_arguments
|
1100
|
-
def assert_folder_does_not_exist(folder: str) ->
|
1106
|
+
def assert_folder_does_not_exist(folder: str,message=None) -> None:
|
1107
|
+
if message is None:
|
1108
|
+
message= f"Folder '{folder}' exists."
|
1101
1109
|
GeneralUtilities.assert_condition(not os.path.isdir(folder), f"Folder '{folder}' exists.")
|
1102
1110
|
|
1111
|
+
@staticmethod
|
1112
|
+
@check_arguments
|
1113
|
+
def assert_not_null(obj,message:str=None) -> str:
|
1114
|
+
if message is None:
|
1115
|
+
message="Variable is not set"
|
1116
|
+
GeneralUtilities.assert_condition(obj is not None, message)
|
1117
|
+
|
1103
1118
|
@staticmethod
|
1104
1119
|
@check_arguments
|
1105
1120
|
def retry_action(action, amount_of_attempts: int, action_name: str = None) -> None:
|
@@ -9,11 +9,6 @@ class ProgramRunnerBase:
|
|
9
9
|
@abstractmethod
|
10
10
|
@GeneralUtilities.check_arguments
|
11
11
|
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) -> Popen:
|
12
|
-
# Verbosity:
|
13
|
-
# 0=Quiet (No output will be printed.)
|
14
|
-
# 1=Normal (If the exitcode of the executed program is not 0 then the StdErr will be printed.)
|
15
|
-
# 2=Full (Prints StdOut and StdErr of the executed program.)
|
16
|
-
# 3=Verbose (Same as "Full" but with some more information.)
|
17
12
|
raise NotImplementedError
|
18
13
|
|
19
14
|
# Return-values program_runner: Exitcode, StdOut, StdErr, Pid
|
@@ -7,6 +7,7 @@ from uuid import uuid4
|
|
7
7
|
from .GeneralUtilities import GeneralUtilities
|
8
8
|
from .ProgramRunnerBase import ProgramRunnerBase
|
9
9
|
from .ProgramRunnerPopen import ProgramRunnerPopen
|
10
|
+
from .SCLog import LogLevel
|
10
11
|
|
11
12
|
|
12
13
|
class CustomEpewArgument:
|
@@ -17,7 +18,7 @@ class CustomEpewArgument:
|
|
17
18
|
addLogOverhead: bool
|
18
19
|
title: str
|
19
20
|
log_namespace: str
|
20
|
-
verbosity:
|
21
|
+
verbosity: LogLevel
|
21
22
|
arguments_for_log: list[str]
|
22
23
|
tempdir = os.path.join(tempfile.gettempdir(), str(uuid4()))
|
23
24
|
stdoutfile = tempdir + ".epew.stdout.txt"
|
@@ -25,7 +26,7 @@ class CustomEpewArgument:
|
|
25
26
|
exitcodefile = tempdir + ".epew.exitcode.txt"
|
26
27
|
pidfile = tempdir + ".epew.pid.txt"
|
27
28
|
|
28
|
-
def __init__(self, print_errors_as_information: bool, log_file: str, timeoutInSeconds: int, addLogOverhead: bool, title: str, log_namespace: str, verbosity:
|
29
|
+
def __init__(self, print_errors_as_information: bool, log_file: str, timeoutInSeconds: int, addLogOverhead: bool, title: str, log_namespace: str, verbosity: LogLevel, arguments_for_log: list[str]):
|
29
30
|
self.print_errors_as_information = print_errors_as_information
|
30
31
|
self.log_file = log_file
|
31
32
|
self.timeoutInSeconds = timeoutInSeconds
|
@@ -58,19 +59,40 @@ class ProgramRunnerEpew(ProgramRunnerBase):
|
|
58
59
|
if custom_argument.pidfile is not None:
|
59
60
|
args.append(f'-r {custom_argument.pidfile}')
|
60
61
|
args.append(f'-d {str(custom_argument.timeoutInSeconds*1000)}')
|
61
|
-
|
62
|
-
|
62
|
+
if GeneralUtilities.string_has_content(custom_argument.title):
|
63
|
+
args.append(f'-t "{custom_argument.title}"')
|
64
|
+
if GeneralUtilities.string_has_content(custom_argument.log_namespace):
|
65
|
+
args.append(f'-l "{custom_argument.log_namespace}"')
|
63
66
|
if not GeneralUtilities.string_is_none_or_whitespace(custom_argument.log_file):
|
64
67
|
args.append(f'-f "{custom_argument.log_file}"')
|
65
68
|
if custom_argument.print_errors_as_information:
|
66
69
|
args.append("-i")
|
67
70
|
if custom_argument.addLogOverhead:
|
68
71
|
args.append("-g")
|
69
|
-
args.append("-v "+str(
|
72
|
+
args.append("-v "+str(self.__get_microsoft_loglevel()))
|
70
73
|
return ProgramRunnerPopen().run_program_argsasarray_async_helper("epew", args, working_directory, custom_argument, interactive)
|
71
74
|
else:
|
72
75
|
raise ValueError("Epew is not available.")
|
73
76
|
|
77
|
+
def __get_microsoft_loglevel(self):
|
78
|
+
#see https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.loglevel
|
79
|
+
#match self.verbosity:
|
80
|
+
# case LogLevel.Quiet:
|
81
|
+
# return 6
|
82
|
+
# case LogLevel.Error:
|
83
|
+
# return 4
|
84
|
+
# case LogLevel.Warning:
|
85
|
+
# return 3
|
86
|
+
# case LogLevel.Information:
|
87
|
+
# return 5
|
88
|
+
# case LogLevel.Debug:
|
89
|
+
# return 1
|
90
|
+
# case LogLevel.Diagnostig:
|
91
|
+
# return 0
|
92
|
+
# case _:
|
93
|
+
# raise ValueError(f"Unhandled log level: {level}")
|
94
|
+
return 2#TODO
|
95
|
+
|
74
96
|
# Return-values program_runner: Exitcode, StdOut, StdErr, Pid
|
75
97
|
@GeneralUtilities.check_arguments
|
76
98
|
def wait(self, process: Popen, custom_argument: object = None) -> tuple[int, str, str, int]:
|
ScriptCollection/SCLog.py
CHANGED
@@ -17,7 +17,7 @@ class LogLevel(Enum):
|
|
17
17
|
|
18
18
|
|
19
19
|
class SCLog:
|
20
|
-
loglevel: LogLevel
|
20
|
+
loglevel: LogLevel#minimum loglevel
|
21
21
|
log_file: str
|
22
22
|
add_overhead_to_console: bool
|
23
23
|
add_overhead_to_logfile: bool
|
@@ -36,8 +36,8 @@ class SCLog:
|
|
36
36
|
self.print_as_color = print_as_color
|
37
37
|
|
38
38
|
@GeneralUtilities.check_arguments
|
39
|
-
def log_exception(self, message: str, ex: Exception, current_traceback):
|
40
|
-
self.log(f"Exception: {message}; Exception-details: {str(ex)}; Traceback: {current_traceback.format_exc()}",
|
39
|
+
def log_exception(self, message: str, ex: Exception, current_traceback,loglevel:LogLevel=LogLevel.Error):
|
40
|
+
self.log(f"Exception: {message}; Exception-details: {str(ex)}; Traceback: {current_traceback.format_exc()}", loglevel)
|
41
41
|
|
42
42
|
@GeneralUtilities.check_arguments
|
43
43
|
def log(self, message: str, loglevel: LogLevel = None):
|
@@ -53,7 +53,7 @@ class SCLog:
|
|
53
53
|
if loglevel is None:
|
54
54
|
loglevel = LogLevel.Information
|
55
55
|
|
56
|
-
if int(loglevel)
|
56
|
+
if int(self.loglevel)<int(loglevel) :
|
57
57
|
return
|
58
58
|
|
59
59
|
if message.endswith("\n"):
|
@@ -99,7 +99,7 @@ class SCLog:
|
|
99
99
|
GeneralUtilities.print_text_in_yellow(part2, print_to_std_out, self.print_as_color)
|
100
100
|
elif loglevel == LogLevel.Debug:
|
101
101
|
GeneralUtilities.print_text_in_cyan(part2, print_to_std_out, self.print_as_color)
|
102
|
-
elif loglevel == LogLevel.
|
102
|
+
elif loglevel == LogLevel.Diagnostic:
|
103
103
|
GeneralUtilities.print_text_in_cyan(part2, print_to_std_out, self.print_as_color)
|
104
104
|
else:
|
105
105
|
raise ValueError("Unknown loglevel.")
|