ScriptCollection 3.5.1__py3-none-any.whl → 3.5.2__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.
@@ -8,7 +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) -> Popen:
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
12
  raise NotImplementedError
13
13
 
14
14
  # Return-values program_runner: Exitcode, StdOut, StdErr, Pid
@@ -20,23 +20,23 @@ class ProgramRunnerBase:
20
20
  # Return-values program_runner: Exitcode, StdOut, StdErr, Pid
21
21
  @abstractmethod
22
22
  @GeneralUtilities.check_arguments
23
- def run_program_argsasarray(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None) -> 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]:
24
24
  raise NotImplementedError
25
25
 
26
26
  # Return-values program_runner: Exitcode, StdOut, StdErr, Pid
27
27
  @abstractmethod
28
28
  @GeneralUtilities.check_arguments
29
- def run_program(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None) -> 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]:
30
30
  raise NotImplementedError
31
31
 
32
32
  # Return-values program_runner: Pid
33
33
  @abstractmethod
34
34
  @GeneralUtilities.check_arguments
35
- def run_program_argsasarray_async(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None) -> 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:
36
36
  raise NotImplementedError
37
37
 
38
38
  # Return-values program_runner: Pid
39
39
  @abstractmethod
40
40
  @GeneralUtilities.check_arguments
41
- def run_program_async(self, program: str, arguments: str, working_directory: str, custom_argument: object) -> int:
41
+ def run_program_async(self, program: str, arguments: str, working_directory: str, custom_argument: object, interactive:bool=False) -> int:
42
42
  raise NotImplementedError
@@ -39,7 +39,7 @@ class CustomEpewArgument:
39
39
  class ProgramRunnerEpew(ProgramRunnerBase):
40
40
 
41
41
  @GeneralUtilities.check_arguments
42
- def run_program_argsasarray_async_helper(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None) -> Popen:
42
+ 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:
43
43
  if GeneralUtilities.epew_is_available():
44
44
  custom_argument: CustomEpewArgument = custom_argument
45
45
  args = []
@@ -67,7 +67,7 @@ class ProgramRunnerEpew(ProgramRunnerBase):
67
67
  if custom_argument.addLogOverhead:
68
68
  args.append("-g")
69
69
  args.append("-v "+str(custom_argument.verbosity))
70
- return ProgramRunnerPopen().run_program_argsasarray_async_helper("epew", args, working_directory)
70
+ return ProgramRunnerPopen().run_program_argsasarray_async_helper("epew", args, working_directory,custom_argument,interactive)
71
71
  else:
72
72
  raise ValueError("Epew is not available.")
73
73
 
@@ -85,21 +85,21 @@ class ProgramRunnerEpew(ProgramRunnerBase):
85
85
  return result
86
86
 
87
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) -> tuple[int, str, str, int]:
89
- process: Popen = self.run_program_argsasarray_async_helper(program, arguments_as_array, working_directory, custom_argument)
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
+ process: Popen = self.run_program_argsasarray_async_helper(program, arguments_as_array, working_directory, custom_argument,interactive)
90
90
  return self.wait(process, custom_argument)
91
91
 
92
92
  @GeneralUtilities.check_arguments
93
- def run_program(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None) -> tuple[int, str, str, int]:
94
- return self.run_program_argsasarray(program, GeneralUtilities.arguments_to_array(arguments), working_directory, custom_argument)
93
+ def run_program(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None, interactive:bool=False) -> tuple[int, str, str, int]:
94
+ return self.run_program_argsasarray(program, GeneralUtilities.arguments_to_array(arguments), working_directory, custom_argument,interactive)
95
95
 
96
96
  @GeneralUtilities.check_arguments
97
- def run_program_argsasarray_async(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None) -> int:
98
- return self.run_program_argsasarray_async_helper(program, arguments_as_array, working_directory, custom_argument).pid
97
+ 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:
98
+ return self.run_program_argsasarray_async_helper(program, arguments_as_array, working_directory, custom_argument,interactive).pid
99
99
 
100
100
  @GeneralUtilities.check_arguments
101
- def run_program_async(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None) -> int:
102
- return self.run_program_argsasarray_async(program, GeneralUtilities.arguments_to_array(arguments), working_directory, custom_argument)
101
+ def run_program_async(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None, interactive:bool=False) -> int:
102
+ return self.run_program_argsasarray_async(program, GeneralUtilities.arguments_to_array(arguments), working_directory, custom_argument,interactive)
103
103
 
104
104
  @GeneralUtilities.check_arguments
105
105
  def __get_number_from_filecontent(self, filecontent: str) -> int:
@@ -7,14 +7,17 @@ from .ProgramRunnerBase import ProgramRunnerBase
7
7
  class ProgramRunnerPopen(ProgramRunnerBase):
8
8
 
9
9
  @GeneralUtilities.check_arguments
10
- def run_program_argsasarray_async_helper(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None) -> Popen:
10
+ 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:
11
11
  arguments_for_process = [program]
12
12
  arguments_for_process.extend(arguments_as_array)
13
13
  # "shell=True" is not allowed because it is not recommended and also something like
14
14
  # "ScriptCollectionCore().run_program('curl', 'https://example.com/dataset?id=1&format=json')"
15
15
  # would not be possible anymore because the ampersand will be treated as shell-command.
16
16
  try:
17
- result = Popen(arguments_for_process, cwd=working_directory, stdin=sys.stdin, stdout=PIPE, stderr=PIPE, shell=False) # pylint: disable=consider-using-with
17
+ if interactive:
18
+ result = Popen(arguments_for_process, cwd=working_directory , stdout=PIPE, stderr=PIPE, shell=False, stdin = sys.stdin) # pylint: disable=consider-using-with
19
+ else:
20
+ result = Popen(arguments_for_process, cwd=working_directory, stdout=PIPE, stderr=PIPE, shell=False) # pylint: disable=consider-using-with
18
21
  except FileNotFoundError as fileNotFoundError:
19
22
  raise FileNotFoundError(f"Starting '{program}' in '{working_directory}' resulted in a FileNotFoundError: '{fileNotFoundError.filename}'")
20
23
  return result
@@ -31,18 +34,18 @@ class ProgramRunnerPopen(ProgramRunnerBase):
31
34
  return result
32
35
 
33
36
  @GeneralUtilities.check_arguments
34
- def run_program_argsasarray(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None) -> tuple[int, str, str, int]:
35
- process: Popen = self.run_program_argsasarray_async_helper(program, arguments_as_array, working_directory, custom_argument)
37
+ 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]:
38
+ process: Popen = self.run_program_argsasarray_async_helper(program, arguments_as_array, working_directory, custom_argument,interactive)
36
39
  return self.wait(process, custom_argument)
37
40
 
38
41
  @GeneralUtilities.check_arguments
39
- def run_program(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None) -> tuple[int, str, str, int]:
42
+ def run_program(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None, interactive:bool=False) -> tuple[int, str, str, int]:
40
43
  return self.run_program_argsasarray(program, GeneralUtilities.arguments_to_array(arguments), working_directory, custom_argument)
41
44
 
42
45
  @GeneralUtilities.check_arguments
43
- def run_program_argsasarray_async(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None) -> int:
44
- return self.run_program_argsasarray_async_helper(program, arguments_as_array, working_directory, custom_argument).pid
46
+ 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:
47
+ return self.run_program_argsasarray_async_helper(program, arguments_as_array, working_directory, custom_argument,interactive).pid
45
48
 
46
49
  @GeneralUtilities.check_arguments
47
- def run_program_async(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None) -> int:
48
- return self.run_program_argsasarray_async(program, GeneralUtilities.arguments_to_array(arguments), working_directory, custom_argument)
50
+ def run_program_async(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None, interactive:bool=False) -> int:
51
+ return self.run_program_argsasarray_async(program, GeneralUtilities.arguments_to_array(arguments), working_directory, custom_argument,interactive)