pyallel 1.3.1__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.1 → pyallel-1.3.2}/PKG-INFO +4 -4
- {pyallel-1.3.1 → pyallel-1.3.2}/README.md +3 -3
- {pyallel-1.3.1 → pyallel-1.3.2}/pyproject.toml +1 -1
- {pyallel-1.3.1 → pyallel-1.3.2}/src/pyallel/printer.py +40 -34
- {pyallel-1.3.1 → pyallel-1.3.2}/src/pyallel/process.py +2 -0
- {pyallel-1.3.1 → pyallel-1.3.2}/LICENSE +0 -0
- {pyallel-1.3.1 → pyallel-1.3.2}/src/pyallel/__init__.py +0 -0
- {pyallel-1.3.1 → pyallel-1.3.2}/src/pyallel/colours.py +0 -0
- {pyallel-1.3.1 → pyallel-1.3.2}/src/pyallel/constants.py +0 -0
- {pyallel-1.3.1 → pyallel-1.3.2}/src/pyallel/errors.py +0 -0
- {pyallel-1.3.1 → pyallel-1.3.2}/src/pyallel/main.py +0 -0
- {pyallel-1.3.1 → pyallel-1.3.2}/src/pyallel/parser.py +0 -0
- {pyallel-1.3.1 → pyallel-1.3.2}/src/pyallel/process_group.py +0 -0
- {pyallel-1.3.1 → pyallel-1.3.2}/src/pyallel/process_group_manager.py +0 -0
- {pyallel-1.3.1 → 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
|
|
|
@@ -259,46 +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
|
-
|
|
266
|
-
|
|
267
|
-
other_processes.append(out)
|
|
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)
|
|
268
269
|
continue
|
|
269
270
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
process_with_most_lines is None
|
|
275
|
-
or process_with_most_lines.process.lines < out.process.lines
|
|
276
|
-
):
|
|
277
|
-
process_with_most_lines = out
|
|
271
|
+
process_output.process.lines = int(
|
|
272
|
+
lines * process_output.process.percentage_lines
|
|
273
|
+
)
|
|
274
|
+
used_lines += process_output.process.lines
|
|
278
275
|
|
|
276
|
+
# Remove the used lines from the total available lines
|
|
279
277
|
lines -= used_lines
|
|
280
278
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
for
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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
|
|
302
308
|
|
|
303
309
|
|
|
304
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:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|