multiCMD 1.18__py3-none-any.whl → 1.20__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.18
3
+ Version: 1.20
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=5OOmn_3szuEQp4RVS9nDDeEL9cfzQzSLRDJ_qIM0_tw,16788
2
+ multiCMD-1.20.dist-info/METADATA,sha256=-8Yhw0mFiNK6-YiJocXtWV9ANLHGGdSGwoU6XLtRXdw,5640
3
+ multiCMD-1.20.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
4
+ multiCMD-1.20.dist-info/entry_points.txt,sha256=nSLBkYrcUCQxt1w3LIJkvgOhpRYEC0xAPqNG7u4OYs8,89
5
+ multiCMD-1.20.dist-info/top_level.txt,sha256=DSqgftD40G09F3qEjpHRCUNUsGUvGZZG69Sm3YEUiWI,9
6
+ multiCMD-1.20.dist-info/RECORD,,
multiCMD.py CHANGED
@@ -12,7 +12,7 @@ import re
12
12
  import itertools
13
13
  import signal
14
14
 
15
- version = '1.18'
15
+ version = '1.20'
16
16
  __version__ = version
17
17
 
18
18
  __running_threads = []
@@ -194,7 +194,7 @@ def __run_command(task,sem, timeout=60, quiet=False,dry_run=False,with_stdErr=Fa
194
194
  start_time = time.time()
195
195
  outLength = len(task.stdout) + len(task.stderr)
196
196
  time.sleep(0)
197
- sleep_time = 1.0e-8 # 10 nanoseconds
197
+ sleep_time = 1.0e-7 # 100 nanoseconds
198
198
  while proc.poll() is None: # while the process is still running
199
199
  if task.stop:
200
200
  proc.send_signal(signal.SIGINT)
@@ -226,7 +226,13 @@ def __run_command(task,sem, timeout=60, quiet=False,dry_run=False,with_stdErr=Fa
226
226
  if stderr:
227
227
  __handle_stream(io.BytesIO(stderr),task.stderr, task)
228
228
  if task.returncode is None:
229
- task.returncode = -1
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
230
236
  if not quiet:
231
237
  print(pre+'\n'+ '-'*100+post)
232
238
  print(pre+f'Process exited with return code {task.returncode}'+post)
@@ -1,6 +0,0 @@
1
- multiCMD.py,sha256=BWFxhvkhHA0MGxIDGoMTjNLlr0R-pK7iwSIb7SQQpBQ,16505
2
- multiCMD-1.18.dist-info/METADATA,sha256=i2MkVTo5eCfUpW0KmFS6wlHo-a78j_nxZG8ZTgFdam4,5580
3
- multiCMD-1.18.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
4
- multiCMD-1.18.dist-info/entry_points.txt,sha256=nSLBkYrcUCQxt1w3LIJkvgOhpRYEC0xAPqNG7u4OYs8,89
5
- multiCMD-1.18.dist-info/top_level.txt,sha256=DSqgftD40G09F3qEjpHRCUNUsGUvGZZG69Sm3YEUiWI,9
6
- multiCMD-1.18.dist-info/RECORD,,