ScriptCollection 3.5.3__py3-none-any.whl → 3.5.5__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 -5
- ScriptCollection/GeneralUtilities.py +6 -0
- ScriptCollection/ProcessesRunner.py +41 -0
- ScriptCollection/RPStream.py +42 -0
- ScriptCollection/ScriptCollectionCore.py +145 -244
- ScriptCollection/TasksForCommonProjectStructure.py +167 -82
- ScriptCollection/UpdateCertificates.py +2 -2
- {ScriptCollection-3.5.3.dist-info → ScriptCollection-3.5.5.dist-info}/METADATA +2 -1
- ScriptCollection-3.5.5.dist-info/RECORD +16 -0
- {ScriptCollection-3.5.3.dist-info → ScriptCollection-3.5.5.dist-info}/WHEEL +1 -1
- ScriptCollection-3.5.3.dist-info/RECORD +0 -14
- {ScriptCollection-3.5.3.dist-info → ScriptCollection-3.5.5.dist-info}/entry_points.txt +0 -0
- {ScriptCollection-3.5.3.dist-info → ScriptCollection-3.5.5.dist-info}/top_level.txt +0 -0
ScriptCollection/Executables.py
CHANGED
|
@@ -259,11 +259,11 @@ def BuildCodeUnit() -> int:
|
|
|
259
259
|
parser = argparse.ArgumentParser()
|
|
260
260
|
parser.add_argument('--codeunitfolder', required=False, default=".")
|
|
261
261
|
parser.add_argument('--verbosity', required=False, default=1)
|
|
262
|
-
parser.add_argument('--targetenvironment', required=False, default="
|
|
262
|
+
parser.add_argument('--targetenvironment', required=False, default="QualityCheck")
|
|
263
263
|
parser.add_argument('--additionalargumentsfile', required=False, default=None)
|
|
264
264
|
parser.add_argument('--assume_dependent_codeunits_are_already_built', type=GeneralUtilities.string_to_boolean, const=True, default=False, nargs='?')
|
|
265
265
|
args = parser.parse_args()
|
|
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
|
+
TasksForCommonProjectStructure().build_codeunit(args.codeunitfolder, int(args.verbosity), args.targetenvironment, args.additionalargumentsfile, False, None, args.assume_dependent_codeunits_are_already_built, sys.argv)
|
|
267
267
|
return 0
|
|
268
268
|
|
|
269
269
|
|
|
@@ -271,10 +271,10 @@ def BuildCodeUnits() -> int:
|
|
|
271
271
|
parser = argparse.ArgumentParser()
|
|
272
272
|
parser.add_argument('--repositoryfolder', required=False, default=".")
|
|
273
273
|
parser.add_argument('--verbosity', required=False, default=1)
|
|
274
|
-
parser.add_argument('--targetenvironment', required=False, default="
|
|
274
|
+
parser.add_argument('--targetenvironment', required=False, default="QualityCheck")
|
|
275
275
|
parser.add_argument('--additionalargumentsfile', required=False, default=None)
|
|
276
276
|
args = parser.parse_args()
|
|
277
|
-
TasksForCommonProjectStructure().build_codeunits(args.repositoryfolder, int(args.verbosity), args.targetenvironment, args.additionalargumentsfile,False,None,sys.argv)
|
|
277
|
+
TasksForCommonProjectStructure().build_codeunits(args.repositoryfolder, int(args.verbosity), args.targetenvironment, args.additionalargumentsfile, False, None, sys.argv)
|
|
278
278
|
return 0
|
|
279
279
|
|
|
280
280
|
|
|
@@ -287,7 +287,7 @@ def BuildCodeUnitsC() -> int:
|
|
|
287
287
|
parser.add_argument('--image', required=False, default="scbuilder:latest")
|
|
288
288
|
args = parser.parse_args()
|
|
289
289
|
GeneralUtilities.reconfigure_standrd_input_and_outputs()
|
|
290
|
-
TasksForCommonProjectStructure().build_codeunitsC(args.repositoryfolder, args.image, int(args.verbosity), args.targetenvironment, args.additionalargumentsfile,sys.argv)
|
|
290
|
+
TasksForCommonProjectStructure().build_codeunitsC(args.repositoryfolder, args.image, int(args.verbosity), args.targetenvironment, args.additionalargumentsfile, sys.argv)
|
|
291
291
|
return 0
|
|
292
292
|
|
|
293
293
|
|
|
@@ -555,6 +555,12 @@ class GeneralUtilities:
|
|
|
555
555
|
except AttributeError:
|
|
556
556
|
return ctypes.windll.shell32.IsUserAnAdmin() == 1
|
|
557
557
|
|
|
558
|
+
@staticmethod
|
|
559
|
+
@check_arguments
|
|
560
|
+
def ensure_elevated_privileges() -> None:
|
|
561
|
+
if (not GeneralUtilities.current_user_has_elevated_privileges()):
|
|
562
|
+
raise ValueError("Not enough privileges.")
|
|
563
|
+
|
|
558
564
|
@staticmethod
|
|
559
565
|
@check_arguments
|
|
560
566
|
def rename_names_of_all_files_and_folders(folder: str, replace_from: str, replace_to: str, replace_only_full_match=False):
|
|
@@ -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()
|
|
@@ -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()
|