pyallel 0.12.1__tar.gz → 0.13.0__tar.gz
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.
- {pyallel-0.12.1 → pyallel-0.13.0}/PKG-INFO +2 -3
- {pyallel-0.12.1 → pyallel-0.13.0}/README.md +1 -2
- {pyallel-0.12.1 → pyallel-0.13.0}/pyproject.toml +1 -1
- {pyallel-0.12.1 → pyallel-0.13.0}/src/pyallel/main.py +0 -4
- {pyallel-0.12.1 → pyallel-0.13.0}/src/pyallel/parser.py +0 -9
- {pyallel-0.12.1 → pyallel-0.13.0}/src/pyallel/process.py +1 -55
- {pyallel-0.12.1 → pyallel-0.13.0}/LICENSE +0 -0
- {pyallel-0.12.1 → pyallel-0.13.0}/src/pyallel/__init__.py +0 -0
- {pyallel-0.12.1 → pyallel-0.13.0}/src/pyallel/constants.py +0 -0
- {pyallel-0.12.1 → pyallel-0.13.0}/src/pyallel/errors.py +0 -0
- {pyallel-0.12.1 → pyallel-0.13.0}/src/pyallel/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyallel
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0
|
|
4
4
|
Summary: Run and handle the output of multiple executables in pyallel (as in parallel)
|
|
5
5
|
Home-page: https://github.com/Danthewaann/pyallel
|
|
6
6
|
License: MIT
|
|
@@ -40,7 +40,7 @@ pip install pyallel
|
|
|
40
40
|
Once installed, you can run `pyallel` to see usage information, like so:
|
|
41
41
|
|
|
42
42
|
```
|
|
43
|
-
usage: pyallel [-h] [-t] [-n] [-
|
|
43
|
+
usage: pyallel [-h] [-t] [-n] [-V] [-v] [commands ...]
|
|
44
44
|
|
|
45
45
|
Run and handle the output of multiple executables in pyallel (as in parallel)
|
|
46
46
|
|
|
@@ -56,7 +56,6 @@ options:
|
|
|
56
56
|
-t, --no-timer don't time how long each command is taking
|
|
57
57
|
-n, --non-interactive
|
|
58
58
|
run in non-interactive mode
|
|
59
|
-
-s, --no-stream don't stream output of each command
|
|
60
59
|
-V, --verbose run in verbose mode
|
|
61
60
|
-v, --version print version and exit
|
|
62
61
|
```
|
|
@@ -19,7 +19,7 @@ pip install pyallel
|
|
|
19
19
|
Once installed, you can run `pyallel` to see usage information, like so:
|
|
20
20
|
|
|
21
21
|
```
|
|
22
|
-
usage: pyallel [-h] [-t] [-n] [-
|
|
22
|
+
usage: pyallel [-h] [-t] [-n] [-V] [-v] [commands ...]
|
|
23
23
|
|
|
24
24
|
Run and handle the output of multiple executables in pyallel (as in parallel)
|
|
25
25
|
|
|
@@ -35,7 +35,6 @@ options:
|
|
|
35
35
|
-t, --no-timer don't time how long each command is taking
|
|
36
36
|
-n, --non-interactive
|
|
37
37
|
run in non-interactive mode
|
|
38
|
-
-s, --no-stream don't stream output of each command
|
|
39
38
|
-V, --verbose run in verbose mode
|
|
40
39
|
-v, --version print version and exit
|
|
41
40
|
```
|
|
@@ -15,13 +15,10 @@ def main_loop(
|
|
|
15
15
|
interactive: bool = False,
|
|
16
16
|
timer: bool = False,
|
|
17
17
|
verbose: bool = False,
|
|
18
|
-
stream: bool = False,
|
|
19
18
|
) -> int:
|
|
20
19
|
process_group = ProcessGroup.from_commands(
|
|
21
20
|
*commands, interactive=interactive, timer=timer, verbose=verbose
|
|
22
21
|
)
|
|
23
|
-
if not stream:
|
|
24
|
-
return process_group.run()
|
|
25
22
|
|
|
26
23
|
return process_group.stream()
|
|
27
24
|
|
|
@@ -46,7 +43,6 @@ def run(*args: str) -> int:
|
|
|
46
43
|
interactive=parsed_args.interactive,
|
|
47
44
|
timer=parsed_args.timer,
|
|
48
45
|
verbose=parsed_args.verbose,
|
|
49
|
-
stream=parsed_args.stream,
|
|
50
46
|
)
|
|
51
47
|
except InvalidExecutableErrors as e:
|
|
52
48
|
exit_code = 1
|
|
@@ -9,7 +9,6 @@ class Arguments:
|
|
|
9
9
|
timer: bool
|
|
10
10
|
verbose: bool
|
|
11
11
|
version: bool
|
|
12
|
-
stream: bool
|
|
13
12
|
|
|
14
13
|
def __repr__(self) -> str:
|
|
15
14
|
msg = "Arguments:\n"
|
|
@@ -54,14 +53,6 @@ def create_parser() -> ArgumentParser:
|
|
|
54
53
|
dest="interactive",
|
|
55
54
|
default=True,
|
|
56
55
|
)
|
|
57
|
-
parser.add_argument(
|
|
58
|
-
"-s",
|
|
59
|
-
"--no-stream",
|
|
60
|
-
help="don't stream output of each command",
|
|
61
|
-
action="store_false",
|
|
62
|
-
default=True,
|
|
63
|
-
dest="stream",
|
|
64
|
-
)
|
|
65
56
|
parser.add_argument(
|
|
66
57
|
"-V",
|
|
67
58
|
"--verbose",
|
|
@@ -74,26 +74,6 @@ def get_command_status(
|
|
|
74
74
|
return output
|
|
75
75
|
|
|
76
76
|
|
|
77
|
-
def print_command_output(process: Process) -> None:
|
|
78
|
-
output = process.read()
|
|
79
|
-
if output:
|
|
80
|
-
print(prefix(output.decode(), keepend=False))
|
|
81
|
-
print()
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
def run_process(process: Process, timer: bool = False, verbose: bool = False) -> bool:
|
|
85
|
-
print(f"{constants.CLEAR_LINE}{constants.CARRIAGE_RETURN}", end="")
|
|
86
|
-
|
|
87
|
-
if process.return_code() != 0:
|
|
88
|
-
print(get_command_status(process, passed=False, verbose=verbose, timer=timer))
|
|
89
|
-
print_command_output(process)
|
|
90
|
-
return False
|
|
91
|
-
else:
|
|
92
|
-
print(get_command_status(process, passed=True, verbose=verbose, timer=timer))
|
|
93
|
-
print_command_output(process)
|
|
94
|
-
return True
|
|
95
|
-
|
|
96
|
-
|
|
97
77
|
@dataclass
|
|
98
78
|
class ProcessGroup:
|
|
99
79
|
processes: list[Process]
|
|
@@ -106,40 +86,6 @@ class ProcessGroup:
|
|
|
106
86
|
passed: bool = True
|
|
107
87
|
icon: int = 0
|
|
108
88
|
|
|
109
|
-
def run(self) -> int:
|
|
110
|
-
for process in self.processes:
|
|
111
|
-
process.run()
|
|
112
|
-
|
|
113
|
-
if not self.interactive or not constants.IN_TTY:
|
|
114
|
-
print(
|
|
115
|
-
f"{constants.WHITE_BOLD}Running commands...{constants.RESET_COLOUR}\n"
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
while True:
|
|
119
|
-
if self.interactive and constants.IN_TTY:
|
|
120
|
-
for icon in constants.ICONS:
|
|
121
|
-
print(
|
|
122
|
-
f"{constants.CLEAR_LINE}{constants.CARRIAGE_RETURN}{constants.WHITE_BOLD}Running commands{constants.RESET_COLOUR} {icon}",
|
|
123
|
-
end="",
|
|
124
|
-
)
|
|
125
|
-
time.sleep(0.1)
|
|
126
|
-
|
|
127
|
-
for process in self.processes:
|
|
128
|
-
if process.id in self.completed_processes or process.poll() is None:
|
|
129
|
-
continue
|
|
130
|
-
|
|
131
|
-
self.completed_processes.add(process.id)
|
|
132
|
-
process_passed = run_process(
|
|
133
|
-
process, verbose=self.verbose, timer=self.timer
|
|
134
|
-
)
|
|
135
|
-
if not process_passed:
|
|
136
|
-
self.passed = False
|
|
137
|
-
|
|
138
|
-
if len(self.completed_processes) == len(self.processes):
|
|
139
|
-
break
|
|
140
|
-
|
|
141
|
-
return 1 if not self.passed else 0
|
|
142
|
-
|
|
143
89
|
def stream(self) -> int:
|
|
144
90
|
for process in self.processes:
|
|
145
91
|
process.run()
|
|
@@ -358,10 +304,10 @@ class Process:
|
|
|
358
304
|
self._fd = open(fd_name, "rb")
|
|
359
305
|
self._process = subprocess.Popen(
|
|
360
306
|
[self.name, *self.args],
|
|
307
|
+
stdin=subprocess.DEVNULL,
|
|
361
308
|
stdout=fd,
|
|
362
309
|
stderr=subprocess.STDOUT,
|
|
363
310
|
env=self.env,
|
|
364
|
-
# shell=True,
|
|
365
311
|
)
|
|
366
312
|
|
|
367
313
|
def __del__(self) -> None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|