multiCMD 1.26__py3-none-any.whl → 1.27__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.py +8 -5
- {multicmd-1.26.dist-info → multicmd-1.27.dist-info}/METADATA +2 -2
- multicmd-1.27.dist-info/RECORD +6 -0
- {multicmd-1.26.dist-info → multicmd-1.27.dist-info}/WHEEL +1 -1
- multicmd-1.26.dist-info/RECORD +0 -6
- {multicmd-1.26.dist-info → multicmd-1.27.dist-info}/entry_points.txt +0 -0
- {multicmd-1.26.dist-info → multicmd-1.27.dist-info}/top_level.txt +0 -0
multiCMD.py
CHANGED
@@ -18,7 +18,7 @@ import re
|
|
18
18
|
import itertools
|
19
19
|
import signal
|
20
20
|
|
21
|
-
version = '1.
|
21
|
+
version = '1.27'
|
22
22
|
__version__ = version
|
23
23
|
|
24
24
|
__running_threads = []
|
@@ -307,7 +307,7 @@ def ping(hosts,timeout=1,max_threads=0,quiet=True,dry_run=False,with_stdErr=Fals
|
|
307
307
|
|
308
308
|
|
309
309
|
def run_command(command, timeout=0,max_threads=1,quiet=False,dry_run=False,with_stdErr=False,
|
310
|
-
return_code_only=False,return_object=False,wait_for_return=True):
|
310
|
+
return_code_only=False,return_object=False,wait_for_return=True, sem = None):
|
311
311
|
'''
|
312
312
|
Run a command
|
313
313
|
|
@@ -321,13 +321,14 @@ def run_command(command, timeout=0,max_threads=1,quiet=False,dry_run=False,with_
|
|
321
321
|
return_code_only: Whether to return only the return code
|
322
322
|
return_object: Whether to return the Task object
|
323
323
|
wait_for_return: Whether to wait for the return of the command
|
324
|
+
sem: The semaphore to use for threading
|
324
325
|
|
325
326
|
@returns:
|
326
327
|
None | int | list[str] | Task: The output of the command
|
327
328
|
'''
|
328
329
|
return run_commands(commands=[command], timeout=timeout, max_threads=max_threads, quiet=quiet,
|
329
330
|
dry_run=dry_run, with_stdErr=with_stdErr, return_code_only=return_code_only,
|
330
|
-
return_object=return_object,parse=False,wait_for_return=wait_for_return)[0]
|
331
|
+
return_object=return_object,parse=False,wait_for_return=wait_for_return,sem=sem)[0]
|
331
332
|
|
332
333
|
def __format_command(command,expand = False):
|
333
334
|
'''
|
@@ -366,7 +367,7 @@ def __format_command(command,expand = False):
|
|
366
367
|
return __format_command(str(command),expand=expand)
|
367
368
|
|
368
369
|
def run_commands(commands, timeout=0,max_threads=1,quiet=False,dry_run=False,with_stdErr=False,
|
369
|
-
return_code_only=False,return_object=False, parse = False, wait_for_return = True):
|
370
|
+
return_code_only=False,return_object=False, parse = False, wait_for_return = True, sem : threading.Semaphore = None):
|
370
371
|
'''
|
371
372
|
Run multiple commands in parallel
|
372
373
|
|
@@ -381,6 +382,7 @@ def run_commands(commands, timeout=0,max_threads=1,quiet=False,dry_run=False,wit
|
|
381
382
|
return_object: Whether to return the Task object
|
382
383
|
parse: Whether to parse ranged input
|
383
384
|
wait_for_return: Whether to wait for the return of the commands
|
385
|
+
sem: The semaphore to use for threading
|
384
386
|
|
385
387
|
@returns:
|
386
388
|
list: The output of the commands ( list[None] | list[int] | list[list[str]] | list[Task] )
|
@@ -395,7 +397,8 @@ def run_commands(commands, timeout=0,max_threads=1,quiet=False,dry_run=False,wit
|
|
395
397
|
if max_threads < 1:
|
396
398
|
max_threads = len(formatedCommands)
|
397
399
|
if max_threads > 1 or not wait_for_return:
|
398
|
-
|
400
|
+
if not sem:
|
401
|
+
sem = threading.Semaphore(max_threads) # Limit concurrent sessions
|
399
402
|
threads = [threading.Thread(target=__run_command, args=(task,sem,timeout,quiet,dry_run,...),daemon=True) for task in tasks]
|
400
403
|
for thread,task in zip(threads,tasks):
|
401
404
|
task.thread = thread
|
@@ -0,0 +1,6 @@
|
|
1
|
+
multiCMD.py,sha256=YroqJCPegx_Ea-FSNWPzNRdlFWSEmiqt2YN94sqVPw8,18903
|
2
|
+
multicmd-1.27.dist-info/METADATA,sha256=TF_qAeuDkNtIgC70KCUZbEwf5PftyStFW_TIyfFU4Go,5640
|
3
|
+
multicmd-1.27.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
4
|
+
multicmd-1.27.dist-info/entry_points.txt,sha256=nSLBkYrcUCQxt1w3LIJkvgOhpRYEC0xAPqNG7u4OYs8,89
|
5
|
+
multicmd-1.27.dist-info/top_level.txt,sha256=DSqgftD40G09F3qEjpHRCUNUsGUvGZZG69Sm3YEUiWI,9
|
6
|
+
multicmd-1.27.dist-info/RECORD,,
|
multicmd-1.26.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
multiCMD.py,sha256=NIUkbXTFdCTQJb6QMuAAhf6cJoiDwZ0vZ0H721ND85c,18750
|
2
|
-
multicmd-1.26.dist-info/METADATA,sha256=Xy_tztr92dFb0cszDrbVGHeI4SOybpmhYTEP0IIqUJ0,5640
|
3
|
-
multicmd-1.26.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
4
|
-
multicmd-1.26.dist-info/entry_points.txt,sha256=nSLBkYrcUCQxt1w3LIJkvgOhpRYEC0xAPqNG7u4OYs8,89
|
5
|
-
multicmd-1.26.dist-info/top_level.txt,sha256=DSqgftD40G09F3qEjpHRCUNUsGUvGZZG69Sm3YEUiWI,9
|
6
|
-
multicmd-1.26.dist-info/RECORD,,
|
File without changes
|
File without changes
|