multiCMD 1.19__py3-none-any.whl → 1.21__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: multiCMD
3
- Version: 1.19
3
+ Version: 1.21
4
4
  Summary: Run commands simultaneously
5
5
  Home-page: https://github.com/yufei-pan/multiCMD
6
6
  Author: Yufei Pan
@@ -25,31 +25,24 @@ Dynamic: requires-python
25
25
  Dynamic: summary
26
26
 
27
27
  # multiCMD
28
- A simple script that is able to issue multiple commands and execute them at the same time locally.
29
-
30
- multiCMD can display realtime-ish outputs in color if running multiple commands at the same time.
31
-
32
- Can be used in bash scripts for automation actions.
33
-
34
- Also able to be imported and act as a wrapper for subprocess.
35
28
 
36
- Use return_object=True with run_commands or run_command to get the Task Object (definition below)
37
-
38
- Use quiet=True and wait_for_return=False to create a daemon thread that async updates the return list / objects when return comes
39
-
40
- For each process, it will initialize a thread if using -m/--max_threads > 1
29
+ A simple script that is able to issue multiple commands and execute them at the same time locally.
41
30
 
42
- For each thread, it will use subprocess lib to open a process for the command task
31
+ `multiCMD` can display realtime-ish outputs in color if running multiple commands at the same time.
43
32
 
44
- And it will open two sub threads for processing input and output for the task.
33
+ It can be used in bash scripts for automation actions, and it can also be imported and act as a wrapper for `subprocess`.
45
34
 
46
- They input / output threads will be non-blocking.
35
+ - Use `return_object=True` with `run_commands` or `run_command` to get the Task Object (definition below).
36
+ - Use `quiet=True` and `wait_for_return=False` to create a daemon thread that asynchronously updates the return list / objects when commands finish.
47
37
 
48
- Thus using -t/--timeout will work more reliably.
38
+ For each process, a thread will be initialized if using `-m/--max_threads > 1`.
39
+ For each thread, `subprocess` is used to open a process for the command task.
40
+ Two additional threads are opened for processing input and output for the task.
49
41
 
50
- Note: timeout specifies how many seconds multiCMD will kill the command if NO COMMITTED OUTPUT was detected from the program for this long.
42
+ The input / output threads are non-blocking.
43
+ Thus, using `-t/--timeout` will work more reliably.
51
44
 
52
- An output line is considered committed if steram hanlder encounters a '\n' or '\r' character.
45
+ **Note:** `timeout` specifies how many seconds `multiCMD` will wait before killing the command if **no committed output** was detected for this duration. An output line is considered committed if the **stream handler** encounters a `\n` or `\r` character.
53
46
 
54
47
 
55
48
  Install via
@@ -0,0 +1,6 @@
1
+ multiCMD.py,sha256=d0kwe5KYNJTiR6521NB7UcX_qNwYA3tELWPjL1quYK0,17056
2
+ multiCMD-1.21.dist-info/METADATA,sha256=KkZMgNNJXXWGBBzt10MMaOf5Jbx2Yf-itSj5MnEM5wM,5640
3
+ multiCMD-1.21.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
4
+ multiCMD-1.21.dist-info/entry_points.txt,sha256=nSLBkYrcUCQxt1w3LIJkvgOhpRYEC0xAPqNG7u4OYs8,89
5
+ multiCMD-1.21.dist-info/top_level.txt,sha256=DSqgftD40G09F3qEjpHRCUNUsGUvGZZG69Sm3YEUiWI,9
6
+ multiCMD-1.21.dist-info/RECORD,,
multiCMD.py CHANGED
@@ -1,4 +1,10 @@
1
1
  #!/usr/bin/env python3
2
+ # /// script
3
+ # requires-python = ">=3.6"
4
+ # dependencies = [
5
+ # "argparse",
6
+ # ]
7
+ # ///
2
8
  import time
3
9
  import threading
4
10
  import io
@@ -12,7 +18,7 @@ import re
12
18
  import itertools
13
19
  import signal
14
20
 
15
- version = '1.19'
21
+ version = '1.21'
16
22
  __version__ = version
17
23
 
18
24
  __running_threads = []
@@ -194,7 +200,7 @@ def __run_command(task,sem, timeout=60, quiet=False,dry_run=False,with_stdErr=Fa
194
200
  start_time = time.time()
195
201
  outLength = len(task.stdout) + len(task.stderr)
196
202
  time.sleep(0)
197
- sleep_time = 1.0e-8 # 10 nanoseconds
203
+ sleep_time = 1.0e-7 # 100 nanoseconds
198
204
  while proc.poll() is None: # while the process is still running
199
205
  if task.stop:
200
206
  proc.send_signal(signal.SIGINT)
@@ -236,6 +242,11 @@ def __run_command(task,sem, timeout=60, quiet=False,dry_run=False,with_stdErr=Fa
236
242
  if not quiet:
237
243
  print(pre+'\n'+ '-'*100+post)
238
244
  print(pre+f'Process exited with return code {task.returncode}'+post)
245
+ # if file not found
246
+ except FileNotFoundError as e:
247
+ task.stdout.append(f'Command / path not found: {task.command[0]}')
248
+ task.stderr.append(str(e))
249
+ task.returncode = 127
239
250
  except Exception as e:
240
251
  import traceback
241
252
  task.stderr.extend(str(e).split('\n'))
@@ -1,6 +0,0 @@
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,,