ScriptCollection 3.5.16__py3-none-any.whl → 4.0.78__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/AnionBuildPlatform.py +206 -0
- ScriptCollection/{UpdateCertificates.py → CertificateUpdater.py} +69 -46
- ScriptCollection/Executables.py +515 -18
- ScriptCollection/GeneralUtilities.py +1272 -873
- ScriptCollection/ImageUpdater.py +648 -0
- ScriptCollection/ProgramRunnerBase.py +10 -10
- ScriptCollection/ProgramRunnerMock.py +2 -0
- ScriptCollection/ProgramRunnerPopen.py +7 -1
- ScriptCollection/ProgramRunnerSudo.py +108 -0
- ScriptCollection/SCLog.py +115 -0
- ScriptCollection/ScriptCollectionCore.py +942 -266
- ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py +95 -0
- ScriptCollection/TFCPS/Docker/__init__.py +0 -0
- ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationBase.py +8 -0
- ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationGenerate.py +6 -0
- ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationNoGenerate.py +7 -0
- ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py +485 -0
- ScriptCollection/TFCPS/DotNet/__init__.py +0 -0
- ScriptCollection/TFCPS/Flutter/TFCPS_CodeUnitSpecific_Flutter.py +130 -0
- ScriptCollection/TFCPS/Flutter/__init__.py +0 -0
- ScriptCollection/TFCPS/Go/TFCPS_CodeUnitSpecific_Go.py +74 -0
- ScriptCollection/TFCPS/Go/__init__.py +0 -0
- ScriptCollection/TFCPS/NodeJS/TFCPS_CodeUnitSpecific_NodeJS.py +131 -0
- ScriptCollection/TFCPS/NodeJS/__init__.py +0 -0
- ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py +227 -0
- ScriptCollection/TFCPS/Python/__init__.py +0 -0
- ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py +418 -0
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py +128 -0
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py +136 -0
- ScriptCollection/TFCPS/TFCPS_CreateRelease.py +95 -0
- ScriptCollection/TFCPS/TFCPS_Generic.py +43 -0
- ScriptCollection/TFCPS/TFCPS_MergeToMain.py +122 -0
- ScriptCollection/TFCPS/TFCPS_MergeToStable.py +350 -0
- ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py +47 -0
- ScriptCollection/TFCPS/TFCPS_Tools_General.py +1356 -0
- ScriptCollection/TFCPS/__init__.py +0 -0
- {ScriptCollection-3.5.16.dist-info → scriptcollection-4.0.78.dist-info}/METADATA +23 -22
- scriptcollection-4.0.78.dist-info/RECORD +43 -0
- {ScriptCollection-3.5.16.dist-info → scriptcollection-4.0.78.dist-info}/WHEEL +1 -1
- {ScriptCollection-3.5.16.dist-info → scriptcollection-4.0.78.dist-info}/entry_points.txt +32 -0
- ScriptCollection/ProgramRunnerEpew.py +0 -122
- ScriptCollection/RPStream.py +0 -42
- ScriptCollection/TasksForCommonProjectStructure.py +0 -2625
- ScriptCollection-3.5.16.dist-info/RECORD +0 -16
- {ScriptCollection-3.5.16.dist-info → scriptcollection-4.0.78.dist-info}/top_level.txt +0 -0
|
@@ -8,12 +8,7 @@ class ProgramRunnerBase:
|
|
|
8
8
|
# Return-values program_runner: Pid
|
|
9
9
|
@abstractmethod
|
|
10
10
|
@GeneralUtilities.check_arguments
|
|
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.)
|
|
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:
|
|
17
12
|
raise NotImplementedError
|
|
18
13
|
|
|
19
14
|
# Return-values program_runner: Exitcode, StdOut, StdErr, Pid
|
|
@@ -25,23 +20,28 @@ class ProgramRunnerBase:
|
|
|
25
20
|
# Return-values program_runner: Exitcode, StdOut, StdErr, Pid
|
|
26
21
|
@abstractmethod
|
|
27
22
|
@GeneralUtilities.check_arguments
|
|
28
|
-
def run_program_argsasarray(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive:bool=False) -> tuple[int, str, str, int]:
|
|
23
|
+
def run_program_argsasarray(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive: bool = False) -> tuple[int, str, str, int]:
|
|
29
24
|
raise NotImplementedError
|
|
30
25
|
|
|
31
26
|
# Return-values program_runner: Exitcode, StdOut, StdErr, Pid
|
|
32
27
|
@abstractmethod
|
|
33
28
|
@GeneralUtilities.check_arguments
|
|
34
|
-
def run_program(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None, interactive:bool=False) -> tuple[int, str, str, int]:
|
|
29
|
+
def run_program(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None, interactive: bool = False) -> tuple[int, str, str, int]:
|
|
35
30
|
raise NotImplementedError
|
|
36
31
|
|
|
37
32
|
# Return-values program_runner: Pid
|
|
38
33
|
@abstractmethod
|
|
39
34
|
@GeneralUtilities.check_arguments
|
|
40
|
-
def run_program_argsasarray_async(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive:bool=False) -> int:
|
|
35
|
+
def run_program_argsasarray_async(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive: bool = False) -> int:
|
|
41
36
|
raise NotImplementedError
|
|
42
37
|
|
|
43
38
|
# Return-values program_runner: Pid
|
|
44
39
|
@abstractmethod
|
|
45
40
|
@GeneralUtilities.check_arguments
|
|
46
|
-
def run_program_async(self, program: str, arguments: str, working_directory: str, custom_argument: object, interactive:bool=False) -> int:
|
|
41
|
+
def run_program_async(self, program: str, arguments: str, working_directory: str, custom_argument: object, interactive: bool = False) -> int:
|
|
42
|
+
raise NotImplementedError
|
|
43
|
+
|
|
44
|
+
@abstractmethod
|
|
45
|
+
@GeneralUtilities.check_arguments
|
|
46
|
+
def will_be_executed_locally(self) -> bool:
|
|
47
47
|
raise NotImplementedError
|
|
@@ -19,7 +19,9 @@ class ProgramRunnerPopen(ProgramRunnerBase):
|
|
|
19
19
|
else:
|
|
20
20
|
result = Popen(arguments_for_process, cwd=working_directory, stdout=PIPE, stderr=PIPE, shell=False, text=True) # pylint: disable=consider-using-with
|
|
21
21
|
except FileNotFoundError as fileNotFoundError:
|
|
22
|
-
raise FileNotFoundError(f"Starting '{program}' in '{working_directory}' resulted in a FileNotFoundError: '{fileNotFoundError
|
|
22
|
+
raise FileNotFoundError(f"Starting '{program}' in '{working_directory}' resulted in a FileNotFoundError: '{str(fileNotFoundError)}'")
|
|
23
|
+
except NotADirectoryError as notADirectoryError:
|
|
24
|
+
raise NotADirectoryError(f"Starting '{program}' in '{working_directory}' resulted in a NotADirectoryError: '{str(notADirectoryError)}'")
|
|
23
25
|
return result
|
|
24
26
|
|
|
25
27
|
# Return-values program_runner: Exitcode, StdOut, StdErr, Pid
|
|
@@ -49,3 +51,7 @@ class ProgramRunnerPopen(ProgramRunnerBase):
|
|
|
49
51
|
@GeneralUtilities.check_arguments
|
|
50
52
|
def run_program_async(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None, interactive: bool = False) -> int:
|
|
51
53
|
return self.run_program_argsasarray_async(program, GeneralUtilities.arguments_to_array(arguments), working_directory, custom_argument, interactive)
|
|
54
|
+
|
|
55
|
+
@GeneralUtilities.check_arguments
|
|
56
|
+
def will_be_executed_locally(self) -> bool:
|
|
57
|
+
return True
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
from subprocess import Popen
|
|
2
|
+
from .GeneralUtilities import GeneralUtilities
|
|
3
|
+
from .ProgramRunnerBase import ProgramRunnerBase
|
|
4
|
+
from .ScriptCollectionCore import ScriptCollectionCore
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class SudoPopenReader:
|
|
8
|
+
content: bytes = None
|
|
9
|
+
|
|
10
|
+
def __init__(self, content: bytes):
|
|
11
|
+
self.content = content
|
|
12
|
+
|
|
13
|
+
def readable(self) -> bool:
|
|
14
|
+
return True
|
|
15
|
+
|
|
16
|
+
def read(self) -> bytes:
|
|
17
|
+
return self.content
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class SudoPopen:
|
|
21
|
+
returncode: int = None
|
|
22
|
+
stdout_str: str = None
|
|
23
|
+
stderr_str: str = None
|
|
24
|
+
pid: int = None
|
|
25
|
+
stdout: bytes = None
|
|
26
|
+
stderr: bytes = None
|
|
27
|
+
|
|
28
|
+
def __init__(self, exitcode: int, stdout: str, stderr: str, pid: int):
|
|
29
|
+
self.returncode: int = exitcode
|
|
30
|
+
self.stdout_str: str = stdout
|
|
31
|
+
self.stdout = str.encode(self.stdout_str)
|
|
32
|
+
self.stderr_str: str = stderr
|
|
33
|
+
self.stderr = str.encode(self.stderr_str)
|
|
34
|
+
self.pid = pid
|
|
35
|
+
|
|
36
|
+
def communicate(self):
|
|
37
|
+
return (self.stdout, self.stderr)
|
|
38
|
+
|
|
39
|
+
def wait(self):
|
|
40
|
+
return self.returncode
|
|
41
|
+
|
|
42
|
+
def poll(self) -> object:
|
|
43
|
+
return self.returncode
|
|
44
|
+
|
|
45
|
+
def __enter__(self):
|
|
46
|
+
return self
|
|
47
|
+
|
|
48
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
|
49
|
+
pass
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class ProgramRunnerSudo(ProgramRunnerBase):
|
|
53
|
+
__sc: ScriptCollectionCore
|
|
54
|
+
__password: str
|
|
55
|
+
|
|
56
|
+
@GeneralUtilities.check_arguments
|
|
57
|
+
def __init__(self,user_password:str):
|
|
58
|
+
GeneralUtilities.assert_condition(GeneralUtilities.current_system_is_linux(), "SudoRunner can only be only executed on Linux.")
|
|
59
|
+
self.__sc = ScriptCollectionCore()
|
|
60
|
+
self.__password = user_password
|
|
61
|
+
|
|
62
|
+
@GeneralUtilities.check_arguments
|
|
63
|
+
def will_be_executed_locally(self) -> bool:
|
|
64
|
+
return True
|
|
65
|
+
|
|
66
|
+
@GeneralUtilities.check_arguments
|
|
67
|
+
def run_program_internal(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None) -> tuple[int, str, str, int]:
|
|
68
|
+
argument = program+" " + ' '.join(GeneralUtilities.args_array_surround_with_quotes_if_required(arguments_as_array))
|
|
69
|
+
argument = f"echo {self.__password} | sudo -k -S {argument}" # TODO maybe add "exit" somewhere before argument or before sudo to correctly return the exit-code"
|
|
70
|
+
result = self.__sc.run_program_argsasarray("sh", ["-c", argument], working_directory)
|
|
71
|
+
return result
|
|
72
|
+
|
|
73
|
+
@GeneralUtilities.check_arguments
|
|
74
|
+
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:
|
|
75
|
+
if interactive:
|
|
76
|
+
raise ValueError("Interactive execution is not supported in Sudo-runner")
|
|
77
|
+
r: tuple[int, str, str, int] = self.run_program_internal(program, arguments_as_array, working_directory, custom_argument)
|
|
78
|
+
popen: SudoPopen = SudoPopen(r[0], r[1], r[2], r[3])
|
|
79
|
+
return popen
|
|
80
|
+
|
|
81
|
+
# Return-values program_runner: Exitcode, StdOut, StdErr, Pid
|
|
82
|
+
@GeneralUtilities.check_arguments
|
|
83
|
+
def wait(self, process: Popen, custom_argument: object) -> tuple[int, str, str, int]:
|
|
84
|
+
raise ValueError("Wait is not supported in Sudo-runner")
|
|
85
|
+
|
|
86
|
+
# Return-values program_runner: Exitcode, StdOut, StdErr, Pid
|
|
87
|
+
@GeneralUtilities.check_arguments
|
|
88
|
+
def run_program_argsasarray(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive: bool = False) -> tuple[int, str, str, int]:
|
|
89
|
+
if interactive:
|
|
90
|
+
raise ValueError("Interactive execution is not supported in Sudo-runner")
|
|
91
|
+
return self.run_program_internal(program, arguments_as_array, working_directory, custom_argument)
|
|
92
|
+
|
|
93
|
+
# Return-values program_runner: Exitcode, StdOut, StdErr, Pid
|
|
94
|
+
@GeneralUtilities.check_arguments
|
|
95
|
+
def run_program(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None, interactive: bool = False) -> tuple[int, str, str, int]:
|
|
96
|
+
if interactive:
|
|
97
|
+
raise ValueError("Interactive execution is not supported in Sudo-runner")
|
|
98
|
+
return self.run_program_internal(program, arguments.split(" "), working_directory, custom_argument)
|
|
99
|
+
|
|
100
|
+
# Return-values program_runner: Pid
|
|
101
|
+
@GeneralUtilities.check_arguments
|
|
102
|
+
def run_program_argsasarray_async(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None, interactive: bool = False) -> int:
|
|
103
|
+
raise ValueError("Async execution is not supported in Sudo-runner")
|
|
104
|
+
|
|
105
|
+
# Return-values program_runner: Pid
|
|
106
|
+
@GeneralUtilities.check_arguments
|
|
107
|
+
def run_program_async(self, program: str, arguments: str, working_directory: str, custom_argument: object, interactive: bool = False) -> int:
|
|
108
|
+
raise ValueError("Async execution is not supported in Sudo-runner")
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import traceback
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from .GeneralUtilities import GeneralUtilities
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class LogLevel(Enum):
|
|
8
|
+
Quiet = 0
|
|
9
|
+
Error = 1
|
|
10
|
+
Warning = 2
|
|
11
|
+
Information = 3
|
|
12
|
+
Debug = 4
|
|
13
|
+
Diagnostic = 5
|
|
14
|
+
|
|
15
|
+
def __int__(self):
|
|
16
|
+
return self.value
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class SCLog:
|
|
20
|
+
loglevel: LogLevel#minimum loglevel
|
|
21
|
+
log_file: str
|
|
22
|
+
add_overhead_to_console: bool
|
|
23
|
+
add_overhead_to_logfile: bool
|
|
24
|
+
print_as_color: bool
|
|
25
|
+
add_milliseconds_to_logfile_entry: bool
|
|
26
|
+
|
|
27
|
+
def __init__(self, log_file: str = None, loglevel: LogLevel = None, print_as_color: bool = True):
|
|
28
|
+
self.log_file = log_file
|
|
29
|
+
if loglevel is None:
|
|
30
|
+
self.loglevel = LogLevel.Information
|
|
31
|
+
else:
|
|
32
|
+
self.loglevel = loglevel
|
|
33
|
+
self.add_overhead_to_console = False
|
|
34
|
+
self.add_overhead_to_logfile = False
|
|
35
|
+
self.add_milliseconds_to_logfile_entry = False
|
|
36
|
+
self.print_as_color = print_as_color
|
|
37
|
+
|
|
38
|
+
@GeneralUtilities.check_arguments
|
|
39
|
+
def log_exception(self, message: str, ex: Exception,loglevel:LogLevel = LogLevel.Error):
|
|
40
|
+
self.log(f"Exception: {message}; Exception-details: {str(ex)}; Traceback: {traceback.format_exc()}", loglevel)
|
|
41
|
+
|
|
42
|
+
@GeneralUtilities.check_arguments
|
|
43
|
+
def log(self, message: str, loglevel: LogLevel = None):
|
|
44
|
+
for line in GeneralUtilities.string_to_lines(message, True, False):
|
|
45
|
+
self.__log_line(line, loglevel)
|
|
46
|
+
|
|
47
|
+
@GeneralUtilities.check_arguments
|
|
48
|
+
def __log_line(self, message: str, loglevel: LogLevel = None):
|
|
49
|
+
|
|
50
|
+
print_to_console: bool = True
|
|
51
|
+
print_to_logfile: bool = self.log_file is not None
|
|
52
|
+
|
|
53
|
+
if loglevel is None:
|
|
54
|
+
loglevel = LogLevel.Information
|
|
55
|
+
|
|
56
|
+
if int(self.loglevel)<int(loglevel):
|
|
57
|
+
return
|
|
58
|
+
|
|
59
|
+
if message.endswith("\n"):
|
|
60
|
+
GeneralUtilities.write_message_to_stderr(f"invalid line: '{message}'") # TODO remove this
|
|
61
|
+
|
|
62
|
+
part1: str = GeneralUtilities.empty_string
|
|
63
|
+
part2: str = GeneralUtilities.empty_string
|
|
64
|
+
part3: str = message
|
|
65
|
+
|
|
66
|
+
if loglevel == LogLevel.Warning:
|
|
67
|
+
part3 = f"Warning: {message}"
|
|
68
|
+
if loglevel == LogLevel.Debug:
|
|
69
|
+
part3 = f"Debug: {message}"
|
|
70
|
+
if loglevel == LogLevel.Diagnostic:
|
|
71
|
+
part3 = f"Diagnostic: {message}"
|
|
72
|
+
|
|
73
|
+
moment: datetime = datetime.now(datetime.now().astimezone().tzinfo)
|
|
74
|
+
|
|
75
|
+
part1 = f"[{GeneralUtilities.datetime_to_string_for_logfile_entry(moment, self.add_milliseconds_to_logfile_entry)}] ["
|
|
76
|
+
if loglevel == LogLevel.Information:
|
|
77
|
+
part2 = f"Information"
|
|
78
|
+
elif loglevel == LogLevel.Error:
|
|
79
|
+
part2 = f"Error"
|
|
80
|
+
elif loglevel == LogLevel.Warning:
|
|
81
|
+
part2 = f"Warning"
|
|
82
|
+
elif loglevel == LogLevel.Debug:
|
|
83
|
+
part2 = f"Debug"
|
|
84
|
+
elif loglevel == LogLevel.Diagnostic:
|
|
85
|
+
part2 = f"Diagnostic"
|
|
86
|
+
else:
|
|
87
|
+
raise ValueError("Unknown loglevel.")
|
|
88
|
+
part3 = f"] {message}"
|
|
89
|
+
|
|
90
|
+
if print_to_console:
|
|
91
|
+
print_to_std_out: bool = loglevel in (LogLevel.Debug, LogLevel.Information)
|
|
92
|
+
if self.add_overhead_to_console:
|
|
93
|
+
GeneralUtilities.print_text(part1, print_to_std_out)
|
|
94
|
+
if loglevel == LogLevel.Information:
|
|
95
|
+
GeneralUtilities.print_text_in_green(part2, print_to_std_out, self.print_as_color)
|
|
96
|
+
elif loglevel == LogLevel.Error:
|
|
97
|
+
GeneralUtilities.print_text_in_red(part2, print_to_std_out, self.print_as_color)
|
|
98
|
+
elif loglevel == LogLevel.Warning:
|
|
99
|
+
GeneralUtilities.print_text_in_yellow(part2, print_to_std_out, self.print_as_color)
|
|
100
|
+
elif loglevel == LogLevel.Debug:
|
|
101
|
+
GeneralUtilities.print_text_in_cyan(part2, print_to_std_out, self.print_as_color)
|
|
102
|
+
elif loglevel == LogLevel.Diagnostic:
|
|
103
|
+
GeneralUtilities.print_text_in_cyan(part2, print_to_std_out, self.print_as_color)
|
|
104
|
+
else:
|
|
105
|
+
raise ValueError("Unknown loglevel.")
|
|
106
|
+
GeneralUtilities.print_text(part3+"\n", print_to_std_out)
|
|
107
|
+
else:
|
|
108
|
+
GeneralUtilities.print_text(message+"\n", print_to_std_out)
|
|
109
|
+
|
|
110
|
+
if print_to_logfile:
|
|
111
|
+
GeneralUtilities.ensure_file_exists(self.log_file)
|
|
112
|
+
if self.add_overhead_to_logfile:
|
|
113
|
+
GeneralUtilities.append_line_to_file(self.log_file, part1+part2+part3)
|
|
114
|
+
else:
|
|
115
|
+
GeneralUtilities.append_line_to_file(self.log_file, message)
|