pyallel 1.3.5__tar.gz → 1.3.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyallel
3
- Version: 1.3.5
3
+ Version: 1.3.6
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
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pyallel"
3
- version = "1.3.5"
3
+ version = "1.3.6"
4
4
  description = "Run and handle the output of multiple executables in pyallel (as in parallel)"
5
5
  authors = ["Daniel Black <danielcrblack@gmail.com>"]
6
6
  license = "MIT"
@@ -298,18 +298,18 @@ class InteractiveConsolePrinter(ConsolePrinter):
298
298
 
299
299
  def print(self, process_group_manager: ProcessGroupManager) -> None:
300
300
  output = process_group_manager.get_cur_process_group_output()
301
- self.print_progress_group_output(output, process_group_manager._interrupt_count)
301
+ self.print_process_group_output(output, process_group_manager._interrupt_count)
302
302
 
303
303
  poll = process_group_manager.poll()
304
304
  if poll is not None:
305
305
  self.clear_last_printed_lines()
306
306
  self.reset()
307
- self.print_progress_group_output(
307
+ self.print_process_group_output(
308
308
  output, process_group_manager._interrupt_count, tail_output=False
309
309
  )
310
310
  self.reset()
311
311
 
312
- def print_progress_group_output(
312
+ def print_process_group_output(
313
313
  self,
314
314
  output: ProcessGroupOutput,
315
315
  interrupt_count: int = 0,
@@ -318,6 +318,7 @@ class InteractiveConsolePrinter(ConsolePrinter):
318
318
  columns = constants.COLUMNS()
319
319
  self.generate_process_group_output(output, interrupt_count, tail_output)
320
320
 
321
+ num_lines_to_print = len(self._to_print)
321
322
  num_last_printed_lines = len(self._last_printed)
322
323
 
323
324
  # If we don't have any last printed lines or we don't want to tail the output,
@@ -333,25 +334,42 @@ class InteractiveConsolePrinter(ConsolePrinter):
333
334
  # Move the cursor up the amount the lines that were last printed so we can start
334
335
  # comparing the last printed lines with the new lines that were generated
335
336
  print(f"\033[{num_last_printed_lines}A", end="")
336
- for i, line_parts in enumerate(self._to_print):
337
- # If this is a completely new line, just print it
338
- if i >= num_last_printed_lines:
339
- include_prefix, line, end = line_parts
340
- self.write(
341
- line, include_prefix, end, truncate=tail_output, columns=columns
342
- )
337
+ cursor_line = 0
338
+ for cur_line, line_parts in enumerate(self._last_printed):
343
339
  # If the current line is not the same as it's newly generated version, we update the line
344
- elif line_parts[1] != self._last_printed[i][1]:
345
- include_prefix, line, end = line_parts
340
+ if line_parts[1] != self._to_print[cur_line][1]:
341
+ include_prefix, line, end = self._to_print[cur_line]
342
+ # Jump to the line that needs to be changed
343
+ lines_to_jump = cur_line - cursor_line
344
+ if lines_to_jump:
345
+ print(f"\033[{lines_to_jump}B\r", end="")
346
346
  # Clear the current line
347
347
  print(f"{constants.CLEAR_LINE}\r", end="")
348
348
  # Write the new line, this will move the cursor to the next line automatically
349
349
  self.write(
350
350
  line, include_prefix, end, truncate=tail_output, columns=columns
351
351
  )
352
- else:
353
- # Move on to the next line as this one doesn't need to be updated
354
- print(constants.DOWN_LINE, end="")
352
+ # Need to set the cursor_line to be the current line + 1 as the above write
353
+ # will move the cursor to the next line
354
+ cursor_line = cur_line + 1
355
+
356
+ if num_lines_to_print > num_last_printed_lines:
357
+ # Jump to the start of the new lines that needs to be printed
358
+ lines_to_jump = num_last_printed_lines - cursor_line
359
+ if lines_to_jump:
360
+ print(f"\033[{lines_to_jump}B\r", end="")
361
+
362
+ # Just print the new lines as normal
363
+ for line_parts in self._to_print[num_last_printed_lines:]:
364
+ include_prefix, line, end = line_parts
365
+ self.write(
366
+ line, include_prefix, end, truncate=tail_output, columns=columns
367
+ )
368
+ else:
369
+ # Jump to the end of the output
370
+ lines_to_jump = num_lines_to_print - cursor_line
371
+ if lines_to_jump:
372
+ print(f"\033[{lines_to_jump}B\r", end="")
355
373
 
356
374
  # Force a flush to return the cursor to the bottom immediately
357
375
  print("", end="", flush=True)
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