pyallel 1.3.0__tar.gz → 1.3.2__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-1.3.0 → pyallel-1.3.2}/PKG-INFO +4 -4
- {pyallel-1.3.0 → pyallel-1.3.2}/README.md +3 -3
- {pyallel-1.3.0 → pyallel-1.3.2}/pyproject.toml +1 -1
- {pyallel-1.3.0 → pyallel-1.3.2}/src/pyallel/main.py +1 -1
- {pyallel-1.3.0 → pyallel-1.3.2}/src/pyallel/printer.py +42 -22
- {pyallel-1.3.0 → pyallel-1.3.2}/src/pyallel/process.py +6 -4
- {pyallel-1.3.0 → pyallel-1.3.2}/src/pyallel/process_group.py +1 -1
- {pyallel-1.3.0 → pyallel-1.3.2}/LICENSE +0 -0
- {pyallel-1.3.0 → pyallel-1.3.2}/src/pyallel/__init__.py +0 -0
- {pyallel-1.3.0 → pyallel-1.3.2}/src/pyallel/colours.py +0 -0
- {pyallel-1.3.0 → pyallel-1.3.2}/src/pyallel/constants.py +0 -0
- {pyallel-1.3.0 → pyallel-1.3.2}/src/pyallel/errors.py +0 -0
- {pyallel-1.3.0 → pyallel-1.3.2}/src/pyallel/parser.py +0 -0
- {pyallel-1.3.0 → pyallel-1.3.2}/src/pyallel/process_group_manager.py +0 -0
- {pyallel-1.3.0 → pyallel-1.3.2}/src/pyallel/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyallel
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.2
|
|
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
|
|
@@ -66,7 +66,7 @@ positional arguments:
|
|
|
66
66
|
--------------
|
|
67
67
|
commands can be grouped using the group separator symbol (:::)
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
pyallel "echo boil kettle" "sleep 1" ::: "echo make coffee"
|
|
70
70
|
|
|
71
71
|
the above will print "boil kettle" and sleep for 1 second first before printing "make coffee"
|
|
72
72
|
|
|
@@ -79,8 +79,8 @@ positional arguments:
|
|
|
79
79
|
|
|
80
80
|
lines (only used in interactive mode):
|
|
81
81
|
the lines modifier allows you to specify how many lines the command output can take up on the screen
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
|
|
83
|
+
pyallel "lines=90 :: echo running long command..." "echo running other command..."
|
|
84
84
|
|
|
85
85
|
90 is expressed as a percentage value, which must be between 1 and 100 inclusive
|
|
86
86
|
|
|
@@ -42,7 +42,7 @@ positional arguments:
|
|
|
42
42
|
--------------
|
|
43
43
|
commands can be grouped using the group separator symbol (:::)
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
pyallel "echo boil kettle" "sleep 1" ::: "echo make coffee"
|
|
46
46
|
|
|
47
47
|
the above will print "boil kettle" and sleep for 1 second first before printing "make coffee"
|
|
48
48
|
|
|
@@ -55,8 +55,8 @@ positional arguments:
|
|
|
55
55
|
|
|
56
56
|
lines (only used in interactive mode):
|
|
57
57
|
the lines modifier allows you to specify how many lines the command output can take up on the screen
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
|
|
59
|
+
pyallel "lines=90 :: echo running long command..." "echo running other command..."
|
|
60
60
|
|
|
61
61
|
90 is expressed as a percentage value, which must be between 1 and 100 inclusive
|
|
62
62
|
|
|
@@ -243,9 +243,9 @@ class Printer:
|
|
|
243
243
|
end="",
|
|
244
244
|
)
|
|
245
245
|
|
|
246
|
-
self.
|
|
246
|
+
self.reset()
|
|
247
247
|
|
|
248
|
-
def
|
|
248
|
+
def reset(self) -> None:
|
|
249
249
|
self._printed.clear()
|
|
250
250
|
|
|
251
251
|
|
|
@@ -259,32 +259,52 @@ def set_process_lines(
|
|
|
259
259
|
lines -= 2
|
|
260
260
|
|
|
261
261
|
# Allocate lines to processes that have a fixed percentage of lines set
|
|
262
|
+
allocated_process_lines = lines // len(output.processes)
|
|
263
|
+
processes_with_dynamic_lines: list[ProcessOutput] = []
|
|
262
264
|
used_lines = 0
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
if not
|
|
266
|
-
|
|
265
|
+
for process_output in output.processes:
|
|
266
|
+
# This process output doesn't have percentage_lines set, so skip it
|
|
267
|
+
if not process_output.process.percentage_lines:
|
|
268
|
+
processes_with_dynamic_lines.append(process_output)
|
|
267
269
|
continue
|
|
268
270
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
+
process_output.process.lines = int(
|
|
272
|
+
lines * process_output.process.percentage_lines
|
|
273
|
+
)
|
|
274
|
+
used_lines += process_output.process.lines
|
|
271
275
|
|
|
276
|
+
# Remove the used lines from the total available lines
|
|
272
277
|
lines -= used_lines
|
|
273
278
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
for
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
279
|
+
while lines:
|
|
280
|
+
# Calculate how many lines each process should have based on how many processes and lines are left
|
|
281
|
+
num_processes = len(processes_with_dynamic_lines) or 1
|
|
282
|
+
allocated_process_lines = lines // num_processes
|
|
283
|
+
processes_with_excess_output: list[ProcessOutput] = []
|
|
284
|
+
recalculate_lines = False
|
|
285
|
+
for process_output in processes_with_dynamic_lines:
|
|
286
|
+
# If the number of lines in this process output is less than how many terminal lines we would allocate it,
|
|
287
|
+
# Set it's allocated terminal lines to the exact number of lines in its output and remove this number from
|
|
288
|
+
# the total available terminal lines
|
|
289
|
+
if process_output.lines < allocated_process_lines:
|
|
290
|
+
process_output.process.lines = process_output.lines
|
|
291
|
+
lines -= process_output.process.lines
|
|
292
|
+
recalculate_lines = True
|
|
293
|
+
continue
|
|
294
|
+
|
|
295
|
+
processes_with_excess_output.append(process_output)
|
|
296
|
+
|
|
297
|
+
# We need to re-calcuate how many terminal lines we can allocate to each process if the output of at least one process
|
|
298
|
+
# contains less lines than what we would normally allocate it. This is done so we can allocate these extra lines to the
|
|
299
|
+
# other processes that contain more lines of output.
|
|
300
|
+
if recalculate_lines:
|
|
301
|
+
processes_with_dynamic_lines = processes_with_excess_output
|
|
302
|
+
else:
|
|
303
|
+
# All remaining processes exceed the number of terminal lines we will allocate them, so allocate them
|
|
304
|
+
# their terminal lines as normal and break out of the while loop
|
|
305
|
+
for process_output in processes_with_excess_output:
|
|
306
|
+
process_output.process.lines = allocated_process_lines
|
|
307
|
+
break
|
|
288
308
|
|
|
289
309
|
|
|
290
310
|
def get_num_lines(line: str, columns: int | None = None) -> int:
|
|
@@ -13,10 +13,12 @@ class ProcessOutput:
|
|
|
13
13
|
def __init__(self, id: int, process: Process, data: str = "") -> None:
|
|
14
14
|
self.id = id
|
|
15
15
|
self.data = data
|
|
16
|
+
self.lines = len(data.splitlines()) + 1
|
|
16
17
|
self.process = process
|
|
17
18
|
|
|
18
19
|
def merge(self, other: ProcessOutput) -> None:
|
|
19
20
|
self.data += other.data
|
|
21
|
+
self.lines += len(other.data.splitlines())
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
class Process:
|
|
@@ -82,7 +84,7 @@ class Process:
|
|
|
82
84
|
|
|
83
85
|
args, *parts = cmd
|
|
84
86
|
|
|
85
|
-
percentage_lines = 0
|
|
87
|
+
percentage_lines = 0
|
|
86
88
|
for arg in args.split(" "):
|
|
87
89
|
try:
|
|
88
90
|
arg, value = args.split("=")
|
|
@@ -91,17 +93,17 @@ class Process:
|
|
|
91
93
|
|
|
92
94
|
if arg == "lines":
|
|
93
95
|
try:
|
|
94
|
-
percentage_lines = int(value)
|
|
96
|
+
percentage_lines = int(value)
|
|
95
97
|
except ValueError:
|
|
96
98
|
raise InvalidLinesModifierError(
|
|
97
99
|
"lines modifier must be a number between 1 and 100"
|
|
98
100
|
)
|
|
99
101
|
|
|
100
|
-
if not 0
|
|
102
|
+
if not 0 < percentage_lines <= 100:
|
|
101
103
|
raise InvalidLinesModifierError(
|
|
102
104
|
"lines modifier must be a number between 1 and 100"
|
|
103
105
|
)
|
|
104
106
|
|
|
105
107
|
break
|
|
106
108
|
|
|
107
|
-
return cls(id, " ".join(parts), percentage_lines)
|
|
109
|
+
return cls(id, " ".join(parts), round(percentage_lines / 100, 2))
|
|
@@ -72,7 +72,7 @@ class ProcessGroup:
|
|
|
72
72
|
percentage_lines_sum += process.percentage_lines
|
|
73
73
|
processes.append(process)
|
|
74
74
|
|
|
75
|
-
if percentage_lines_sum > 1.0:
|
|
75
|
+
if round(percentage_lines_sum, 2) > 1.0:
|
|
76
76
|
raise InvalidLinesModifierError(
|
|
77
77
|
"lines modifier must not exceed 100 across all processes within each process group"
|
|
78
78
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|