pyallel 1.3.6__tar.gz → 1.3.8__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.6
3
+ Version: 1.3.8
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.6"
3
+ version = "1.3.8"
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"
@@ -0,0 +1,10 @@
1
+ class PyallelError(Exception):
2
+ """Base error for issues raised by pyallel"""
3
+
4
+
5
+ class InvalidLinesModifierError(PyallelError):
6
+ """Raised when the lines modifier is invalid"""
7
+
8
+
9
+ class NoCommandsForProcessGroupError(PyallelError):
10
+ """Raised when no commands have been provided for a process group"""
@@ -7,7 +7,7 @@ import traceback
7
7
 
8
8
  from pyallel import constants
9
9
  from pyallel.colours import Colours
10
- from pyallel.errors import InvalidLinesModifierError
10
+ from pyallel.errors import PyallelError
11
11
  from pyallel.parser import Arguments, create_parser
12
12
  from pyallel.printer import (
13
13
  InteractiveConsolePrinter,
@@ -40,7 +40,7 @@ def entry_point(*args: str) -> int:
40
40
 
41
41
  try:
42
42
  process_group_manager = ProcessGroupManager.from_args(*parsed_args.commands)
43
- except InvalidLinesModifierError as e:
43
+ except PyallelError as e:
44
44
  print(f"{colours.red_bold}Error: {str(e)}{colours.reset_colour}")
45
45
  return 1
46
46
 
@@ -335,7 +335,9 @@ class InteractiveConsolePrinter(ConsolePrinter):
335
335
  # comparing the last printed lines with the new lines that were generated
336
336
  print(f"\033[{num_last_printed_lines}A", end="")
337
337
  cursor_line = 0
338
- for cur_line, line_parts in enumerate(self._last_printed):
338
+ for cur_line, line_parts in enumerate(
339
+ self._last_printed[:num_lines_to_print]
340
+ ):
339
341
  # If the current line is not the same as it's newly generated version, we update the line
340
342
  if line_parts[1] != self._to_print[cur_line][1]:
341
343
  include_prefix, line, end = self._to_print[cur_line]
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
  import signal
4
4
  from typing import Any
5
5
 
6
+ from pyallel.errors import NoCommandsForProcessGroupError
6
7
  from pyallel.process import ProcessOutput
7
8
  from pyallel.process_group import ProcessGroupOutput, ProcessGroup
8
9
 
@@ -113,39 +114,31 @@ class ProcessGroupManager:
113
114
 
114
115
  @classmethod
115
116
  def from_args(cls, *args: str) -> ProcessGroupManager:
116
- last_separator_index = 0
117
117
  commands: list[str] = []
118
118
  process_groups: list[ProcessGroup] = []
119
119
  progress_group_id = 1
120
120
  process_id = 1
121
121
 
122
- for i, arg in enumerate(args):
123
- if arg == ":::":
124
- if i - 1 == 0:
125
- pg = ProcessGroup.from_commands(
126
- progress_group_id, process_id, args[0]
127
- )
128
- else:
129
- pg = ProcessGroup.from_commands(
130
- progress_group_id, process_id, *commands[last_separator_index:]
131
- )
132
-
133
- process_groups.append(pg)
134
- process_id += len(pg.processes)
135
- last_separator_index = i
136
- progress_group_id += 1
122
+ for arg in args:
123
+ if arg != ":::":
124
+ commands.append(arg)
137
125
  continue
138
126
 
139
- commands.append(arg)
127
+ if not commands:
128
+ raise NoCommandsForProcessGroupError(
129
+ f"no commands provided for process group {progress_group_id}, did you forgot to provide them before the ::: symbol?"
130
+ )
140
131
 
141
- if len(process_groups) > 1:
142
- last_separator_index -= 1
132
+ pg = ProcessGroup.from_commands(progress_group_id, process_id, *commands)
133
+ process_groups.append(pg)
134
+ process_id += len(pg.processes)
135
+ progress_group_id += 1
136
+ commands.clear()
143
137
 
144
- process_groups.append(
145
- ProcessGroup.from_commands(
146
- progress_group_id, process_id, *commands[last_separator_index:]
138
+ if commands:
139
+ process_groups.append(
140
+ ProcessGroup.from_commands(progress_group_id, process_id, *commands)
147
141
  )
148
- )
149
142
 
150
143
  process_group_manager = cls(process_groups=process_groups)
151
144
 
@@ -1,2 +0,0 @@
1
- class InvalidLinesModifierError(Exception):
2
- """Raised when the lines modifier is invalid"""
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes