ScriptCollection 3.5.2__py3-none-any.whl → 3.5.4__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/Executables.py +5 -4
- ScriptCollection/ProcessesRunner.py +41 -0
- ScriptCollection/ProgramRunnerBase.py +5 -0
- ScriptCollection/RPStream.py +42 -0
- ScriptCollection/ScriptCollectionCore.py +137 -225
- ScriptCollection/TasksForCommonProjectStructure.py +138 -77
- ScriptCollection/UpdateCertificates.py +2 -2
- {ScriptCollection-3.5.2.dist-info → ScriptCollection-3.5.4.dist-info}/METADATA +3 -2
- ScriptCollection-3.5.4.dist-info/RECORD +16 -0
- {ScriptCollection-3.5.2.dist-info → ScriptCollection-3.5.4.dist-info}/WHEEL +1 -1
- ScriptCollection-3.5.2.dist-info/RECORD +0 -14
- {ScriptCollection-3.5.2.dist-info → ScriptCollection-3.5.4.dist-info}/entry_points.txt +0 -0
- {ScriptCollection-3.5.2.dist-info → ScriptCollection-3.5.4.dist-info}/top_level.txt +0 -0
ScriptCollection/Executables.py
CHANGED
|
@@ -2,6 +2,7 @@ import os
|
|
|
2
2
|
import argparse
|
|
3
3
|
import time
|
|
4
4
|
import traceback
|
|
5
|
+
import sys
|
|
5
6
|
import keyboard
|
|
6
7
|
from .TasksForCommonProjectStructure import TasksForCommonProjectStructure
|
|
7
8
|
from .ScriptCollectionCore import ScriptCollectionCore
|
|
@@ -262,7 +263,7 @@ def BuildCodeUnit() -> int:
|
|
|
262
263
|
parser.add_argument('--additionalargumentsfile', required=False, default=None)
|
|
263
264
|
parser.add_argument('--assume_dependent_codeunits_are_already_built', type=GeneralUtilities.string_to_boolean, const=True, default=False, nargs='?')
|
|
264
265
|
args = parser.parse_args()
|
|
265
|
-
TasksForCommonProjectStructure().build_codeunit(args.codeunitfolder, int(args.verbosity), args.targetenvironment, args.additionalargumentsfile,
|
|
266
|
+
TasksForCommonProjectStructure().build_codeunit(args.codeunitfolder, int(args.verbosity), args.targetenvironment, args.additionalargumentsfile,False, None, args.assume_dependent_codeunits_are_already_built,sys.argv)
|
|
266
267
|
return 0
|
|
267
268
|
|
|
268
269
|
|
|
@@ -273,7 +274,7 @@ def BuildCodeUnits() -> int:
|
|
|
273
274
|
parser.add_argument('--targetenvironment', required=False, default="Development")
|
|
274
275
|
parser.add_argument('--additionalargumentsfile', required=False, default=None)
|
|
275
276
|
args = parser.parse_args()
|
|
276
|
-
TasksForCommonProjectStructure().build_codeunits(args.repositoryfolder, int(args.verbosity), args.targetenvironment, args.additionalargumentsfile)
|
|
277
|
+
TasksForCommonProjectStructure().build_codeunits(args.repositoryfolder, int(args.verbosity), args.targetenvironment, args.additionalargumentsfile,False,None,sys.argv)
|
|
277
278
|
return 0
|
|
278
279
|
|
|
279
280
|
|
|
@@ -286,7 +287,7 @@ def BuildCodeUnitsC() -> int:
|
|
|
286
287
|
parser.add_argument('--image', required=False, default="scbuilder:latest")
|
|
287
288
|
args = parser.parse_args()
|
|
288
289
|
GeneralUtilities.reconfigure_standrd_input_and_outputs()
|
|
289
|
-
TasksForCommonProjectStructure().build_codeunitsC(args.repositoryfolder, args.image, int(args.verbosity), args.targetenvironment, args.additionalargumentsfile)
|
|
290
|
+
TasksForCommonProjectStructure().build_codeunitsC(args.repositoryfolder, args.image, int(args.verbosity), args.targetenvironment, args.additionalargumentsfile,sys.argv)
|
|
290
291
|
return 0
|
|
291
292
|
|
|
292
293
|
|
|
@@ -317,7 +318,7 @@ def GenerateCertificate() -> int:
|
|
|
317
318
|
parser.add_argument('--days_until_expire', required=False, default=None, type=int)
|
|
318
319
|
parser.add_argument('--password', required=False, default=None)
|
|
319
320
|
args = parser.parse_args()
|
|
320
|
-
ScriptCollectionCore().generate_certificate(os.getcwd(), args.domain, args.filename, args.subj_c, args.subj_st,
|
|
321
|
+
ScriptCollectionCore().generate_certificate(os.getcwd(), args.domain, args.filename, args.subj_c, args.subj_st, args.subj_l, args.subj_o, args.subj_ou, args.days_until_expire, args.password)
|
|
321
322
|
return 0
|
|
322
323
|
|
|
323
324
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import psutil
|
|
2
|
+
from .ScriptCollectionCore import ScriptCollectionCore
|
|
3
|
+
|
|
4
|
+
# runs multiple processes in parallel and terminate all if at least one is terminated
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ProcessStartInformation:
|
|
8
|
+
workingdirectory: str = None
|
|
9
|
+
program: str = None
|
|
10
|
+
arguments: str = None
|
|
11
|
+
|
|
12
|
+
def __init__(self, workingdirectory: str, program: str, arguments: str):
|
|
13
|
+
self.workingdirectory = workingdirectory
|
|
14
|
+
self.program = program
|
|
15
|
+
self.arguments = arguments
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ProcessesRunner:
|
|
19
|
+
sc: ScriptCollectionCore
|
|
20
|
+
processes: list[ProcessStartInformation]
|
|
21
|
+
|
|
22
|
+
def __init__(self, processes: list[ProcessStartInformation]):
|
|
23
|
+
self.sc = ScriptCollectionCore()
|
|
24
|
+
self.processes = processes
|
|
25
|
+
|
|
26
|
+
def run(self):
|
|
27
|
+
pids: list[int] = list[int]()
|
|
28
|
+
for processstartinfo in self.processes:
|
|
29
|
+
pids.append(self.sc.run_program_async(processstartinfo.program, processstartinfo.argumentss, processstartinfo.workingdirectory))
|
|
30
|
+
enabled = True
|
|
31
|
+
while enabled:
|
|
32
|
+
for pid in pids:
|
|
33
|
+
if not psutil.pid_exists(pid):
|
|
34
|
+
enabled = False
|
|
35
|
+
# one program terminate so exit and terminate all now
|
|
36
|
+
processes = psutil.process_iter()
|
|
37
|
+
for pid in pids:
|
|
38
|
+
if psutil.pid_exists(pid):
|
|
39
|
+
for proc in processes:
|
|
40
|
+
if proc.pid == pid:
|
|
41
|
+
proc.kill()
|
|
@@ -9,6 +9,11 @@ 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.)
|
|
12
17
|
raise NotImplementedError
|
|
13
18
|
|
|
14
19
|
# Return-values program_runner: Exitcode, StdOut, StdErr, Pid
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import psutil
|
|
3
|
+
from .GeneralUtilities import GeneralUtilities
|
|
4
|
+
from .ProcessesRunner import ProcessStartInformation, ProcessesRunner
|
|
5
|
+
# streams the local libcam-vid-stream to a rtsp-server
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class RPStream:
|
|
9
|
+
|
|
10
|
+
__working_directory: str = None
|
|
11
|
+
__pid_file: str = None
|
|
12
|
+
|
|
13
|
+
def __init__(self, working_directory: str):
|
|
14
|
+
self.__working_directory = working_directory
|
|
15
|
+
self.__pid_file = os.path.join(self.__working_directory, "pid.txt")
|
|
16
|
+
|
|
17
|
+
def __get_pid(self) -> str:
|
|
18
|
+
GeneralUtilities.ensure_file_exists(self.__pid_file)
|
|
19
|
+
return GeneralUtilities.read_text_from_file(self.__pid_file)
|
|
20
|
+
|
|
21
|
+
def __set_pid(self, pid: str):
|
|
22
|
+
GeneralUtilities.ensure_file_exists(self.__pid_file)
|
|
23
|
+
GeneralUtilities.write_text_to_file(self.__pid_file, pid)
|
|
24
|
+
|
|
25
|
+
def __ensure_previous_process_is_not_running(self):
|
|
26
|
+
pid = self.__get_pid()
|
|
27
|
+
if GeneralUtilities.string_has_content(pid):
|
|
28
|
+
for proc in psutil.process_iter():
|
|
29
|
+
if proc.pid == pid and proc.name() == "python":
|
|
30
|
+
proc.kill()
|
|
31
|
+
|
|
32
|
+
def __start_stream(self):
|
|
33
|
+
prinfo: list[ProcessStartInformation] = list[ProcessStartInformation]()
|
|
34
|
+
prinfo.append(ProcessStartInformation(None, "", ""))
|
|
35
|
+
prinfo.append(ProcessStartInformation(None, "", ""))
|
|
36
|
+
processesRunner: ProcessesRunner = ProcessesRunner(prinfo)
|
|
37
|
+
self.__set_pid(str(os.getpid()))
|
|
38
|
+
processesRunner.run()
|
|
39
|
+
|
|
40
|
+
def start(self):
|
|
41
|
+
self.__ensure_previous_process_is_not_running()
|
|
42
|
+
self.__start_stream()
|