multiCMD 1.17__py3-none-any.whl → 1.19__py3-none-any.whl
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.
- {multiCMD-1.17.dist-info → multiCMD-1.19.dist-info}/METADATA +1 -1
- multiCMD-1.19.dist-info/RECORD +6 -0
- multiCMD.py +25 -8
- multiCMD-1.17.dist-info/RECORD +0 -6
- {multiCMD-1.17.dist-info → multiCMD-1.19.dist-info}/WHEEL +0 -0
- {multiCMD-1.17.dist-info → multiCMD-1.19.dist-info}/entry_points.txt +0 -0
- {multiCMD-1.17.dist-info → multiCMD-1.19.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,6 @@
|
|
1
|
+
multiCMD.py,sha256=37XQxwae418swW1sKVMHHrxaY-IIka0wgXSGa96KOr8,16787
|
2
|
+
multiCMD-1.19.dist-info/METADATA,sha256=Eh01OHQEypIvGY9qT3qooR3ER_-Q-aYC6cV3aV1PmZM,5580
|
3
|
+
multiCMD-1.19.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
4
|
+
multiCMD-1.19.dist-info/entry_points.txt,sha256=nSLBkYrcUCQxt1w3LIJkvgOhpRYEC0xAPqNG7u4OYs8,89
|
5
|
+
multiCMD-1.19.dist-info/top_level.txt,sha256=DSqgftD40G09F3qEjpHRCUNUsGUvGZZG69Sm3YEUiWI,9
|
6
|
+
multiCMD-1.19.dist-info/RECORD,,
|
multiCMD.py
CHANGED
@@ -10,8 +10,9 @@ import os
|
|
10
10
|
import string
|
11
11
|
import re
|
12
12
|
import itertools
|
13
|
+
import signal
|
13
14
|
|
14
|
-
version = '1.
|
15
|
+
version = '1.19'
|
15
16
|
__version__ = version
|
16
17
|
|
17
18
|
__running_threads = []
|
@@ -21,10 +22,11 @@ class Task:
|
|
21
22
|
self.returncode = None
|
22
23
|
self.stdout = []
|
23
24
|
self.stderr = []
|
25
|
+
self.stop = False
|
24
26
|
def __iter__(self):
|
25
27
|
return zip(['command', 'returncode', 'stdout', 'stderr'], [self.command, self.returncode, self.stdout, self.stderr])
|
26
28
|
def __repr__(self):
|
27
|
-
return f'Task(command={self.command}, returncode={self.returncode}, stdout={self.stdout}, stderr={self.stderr})'
|
29
|
+
return f'Task(command={self.command}, returncode={self.returncode}, stdout={self.stdout}, stderr={self.stderr}, stop={self.stop})'
|
28
30
|
def __str__(self):
|
29
31
|
return str(dict(self))
|
30
32
|
|
@@ -194,13 +196,21 @@ def __run_command(task,sem, timeout=60, quiet=False,dry_run=False,with_stdErr=Fa
|
|
194
196
|
time.sleep(0)
|
195
197
|
sleep_time = 1.0e-8 # 10 nanoseconds
|
196
198
|
while proc.poll() is None: # while the process is still running
|
197
|
-
if
|
198
|
-
|
199
|
-
|
200
|
-
if timeout > 0 and time.time() - start_time > timeout:
|
201
|
-
task.stderr.append('Timeout!')
|
199
|
+
if task.stop:
|
200
|
+
proc.send_signal(signal.SIGINT)
|
201
|
+
time.sleep(0.01)
|
202
202
|
proc.terminate()
|
203
203
|
break
|
204
|
+
if timeout > 0:
|
205
|
+
if len(task.stdout) + len(task.stderr) != outLength:
|
206
|
+
start_time = time.time()
|
207
|
+
outLength = len(task.stdout) + len(task.stderr)
|
208
|
+
elif time.time() - start_time > timeout:
|
209
|
+
task.stderr.append('Timeout!')
|
210
|
+
proc.send_signal(signal.SIGINT)
|
211
|
+
time.sleep(0.01)
|
212
|
+
proc.terminate()
|
213
|
+
break
|
204
214
|
time.sleep(sleep_time)
|
205
215
|
# exponential backoff
|
206
216
|
if sleep_time < 0.001:
|
@@ -215,7 +225,14 @@ def __run_command(task,sem, timeout=60, quiet=False,dry_run=False,with_stdErr=Fa
|
|
215
225
|
__handle_stream(io.BytesIO(stdout),task.stdout, task)
|
216
226
|
if stderr:
|
217
227
|
__handle_stream(io.BytesIO(stderr),task.stderr, task)
|
218
|
-
task.returncode
|
228
|
+
if task.returncode is None:
|
229
|
+
# process been killed via timeout or sigkill
|
230
|
+
if task.stderr and task.stderr[-1].strip().startswith('Timeout!'):
|
231
|
+
task.returncode = 124
|
232
|
+
elif task.stderr and task.stderr[-1].strip().startswith('Ctrl C detected, Emergency Stop!'):
|
233
|
+
task.returncode = 137
|
234
|
+
else:
|
235
|
+
task.returncode = -1
|
219
236
|
if not quiet:
|
220
237
|
print(pre+'\n'+ '-'*100+post)
|
221
238
|
print(pre+f'Process exited with return code {task.returncode}'+post)
|
multiCMD-1.17.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
multiCMD.py,sha256=kDQx1wobcsGjJppVaK7qEznU85oSjhJQkgt-MnQHNsg,16246
|
2
|
-
multiCMD-1.17.dist-info/METADATA,sha256=LwQKK0sBVujoLgucBT_R0GkXPWuBCYDvI2qVSYv1Mc0,5580
|
3
|
-
multiCMD-1.17.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
4
|
-
multiCMD-1.17.dist-info/entry_points.txt,sha256=nSLBkYrcUCQxt1w3LIJkvgOhpRYEC0xAPqNG7u4OYs8,89
|
5
|
-
multiCMD-1.17.dist-info/top_level.txt,sha256=DSqgftD40G09F3qEjpHRCUNUsGUvGZZG69Sm3YEUiWI,9
|
6
|
-
multiCMD-1.17.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|