multiCMD 1.21__tar.gz → 1.23__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.
- {multicmd-1.21 → multicmd-1.23}/PKG-INFO +1 -1
- {multicmd-1.21 → multicmd-1.23}/multiCMD.egg-info/PKG-INFO +1 -1
- {multicmd-1.21 → multicmd-1.23}/multiCMD.py +15 -7
- {multicmd-1.21 → multicmd-1.23}/README.md +0 -0
- {multicmd-1.21 → multicmd-1.23}/multiCMD.egg-info/SOURCES.txt +0 -0
- {multicmd-1.21 → multicmd-1.23}/multiCMD.egg-info/dependency_links.txt +0 -0
- {multicmd-1.21 → multicmd-1.23}/multiCMD.egg-info/entry_points.txt +0 -0
- {multicmd-1.21 → multicmd-1.23}/multiCMD.egg-info/requires.txt +0 -0
- {multicmd-1.21 → multicmd-1.23}/multiCMD.egg-info/top_level.txt +0 -0
- {multicmd-1.21 → multicmd-1.23}/setup.cfg +0 -0
- {multicmd-1.21 → multicmd-1.23}/setup.py +0 -0
@@ -18,7 +18,7 @@ import re
|
|
18
18
|
import itertools
|
19
19
|
import signal
|
20
20
|
|
21
|
-
version = '1.
|
21
|
+
version = '1.23'
|
22
22
|
__version__ = version
|
23
23
|
|
24
24
|
__running_threads = []
|
@@ -28,6 +28,7 @@ class Task:
|
|
28
28
|
self.returncode = None
|
29
29
|
self.stdout = []
|
30
30
|
self.stderr = []
|
31
|
+
self.thread = None
|
31
32
|
self.stop = False
|
32
33
|
def __iter__(self):
|
33
34
|
return zip(['command', 'returncode', 'stdout', 'stderr'], [self.command, self.returncode, self.stdout, self.stderr])
|
@@ -35,6 +36,10 @@ class Task:
|
|
35
36
|
return f'Task(command={self.command}, returncode={self.returncode}, stdout={self.stdout}, stderr={self.stderr}, stop={self.stop})'
|
36
37
|
def __str__(self):
|
37
38
|
return str(dict(self))
|
39
|
+
def is_alive(self):
|
40
|
+
if self.thread is not None:
|
41
|
+
return self.thread.is_alive()
|
42
|
+
return False
|
38
43
|
|
39
44
|
def _expand_ranges(inStr):
|
40
45
|
'''
|
@@ -239,19 +244,21 @@ def __run_command(task,sem, timeout=60, quiet=False,dry_run=False,with_stdErr=Fa
|
|
239
244
|
task.returncode = 137
|
240
245
|
else:
|
241
246
|
task.returncode = -1
|
242
|
-
if not quiet:
|
243
|
-
print(pre+'\n'+ '-'*100+post)
|
244
|
-
print(pre+f'Process exited with return code {task.returncode}'+post)
|
245
247
|
# if file not found
|
246
248
|
except FileNotFoundError as e:
|
247
|
-
|
249
|
+
print(f'Command / path not found: {task.command[0]}',file=sys.stderr,flush=True)
|
248
250
|
task.stderr.append(str(e))
|
249
251
|
task.returncode = 127
|
250
252
|
except Exception as e:
|
251
253
|
import traceback
|
254
|
+
print(f'Error running command: {task.command}',file=sys.stderr,flush=True)
|
255
|
+
print(str(e).split('\n'))
|
252
256
|
task.stderr.extend(str(e).split('\n'))
|
253
257
|
task.stderr.extend(traceback.format_exc().split('\n'))
|
254
258
|
task.returncode = -1
|
259
|
+
if not quiet:
|
260
|
+
print(pre+'\n'+ '-'*100+post)
|
261
|
+
print(pre+f'Process exited with return code {task.returncode}'+post)
|
255
262
|
if with_stdErr:
|
256
263
|
return task.stdout + task.stderr
|
257
264
|
else:
|
@@ -348,7 +355,8 @@ def run_commands(commands, timeout=0,max_threads=1,quiet=False,dry_run=False,wit
|
|
348
355
|
if max_threads > 1 or not wait_for_return:
|
349
356
|
sem = threading.Semaphore(max_threads) # Limit concurrent sessions
|
350
357
|
threads = [threading.Thread(target=__run_command, args=(task,sem,timeout,quiet,dry_run,...),daemon=True) for task in tasks]
|
351
|
-
for thread in threads:
|
358
|
+
for thread,task in zip(threads,tasks):
|
359
|
+
task.thread = thread
|
352
360
|
thread.start()
|
353
361
|
if wait_for_return:
|
354
362
|
for thread in threads:
|
@@ -525,7 +533,7 @@ def main():
|
|
525
533
|
parser.add_argument('-q','--quiet', action='store_true',help='quiet mode')
|
526
534
|
parser.add_argument('-V','--version', action='version', version=f'%(prog)s {version} by pan@zopyr.us')
|
527
535
|
args = parser.parse_args()
|
528
|
-
run_commands(args.commands, args.timeout, args.max_threads, args.quiet,parse = args.parse)
|
536
|
+
run_commands(args.commands, args.timeout, args.max_threads, args.quiet,parse = args.parse, with_stdErr=True)
|
529
537
|
|
530
538
|
if __name__ == '__main__':
|
531
539
|
main()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|