srchproc.py rename to procutil.py

This commit is contained in:
PavelMuhortov 2021-06-21 00:05:04 +03:00
parent 7a136f236f
commit c754f48718
3 changed files with 36 additions and 36 deletions

View File

@ -1,12 +1,12 @@
# utils # utils
* [ffmpeger.py](https://git.hmp.today/pavel.muhortov/utils#ffmpeger-py) * [ffmpeger.py](https://git.hmp.today/pavel.muhortov/utils#ffmpeger-py)
* [procutil.py](https://git.hmp.today/pavel.muhortov/utils#procutil-py)
* [sendmail.py](https://git.hmp.today/pavel.muhortov/utils#sendmail-py) * [sendmail.py](https://git.hmp.today/pavel.muhortov/utils#sendmail-py)
* [srchproc.py](https://git.hmp.today/pavel.muhortov/utils#srchproc-py)
____ ____
## ffmpeger.py ## ffmpeger.py
**Description:** FFmpeg management from Python **Description:** FFmpeg management from Python
**Dependencies:** Python 3 (tested version 3.9.5), installed or downloaded ffmpeg, [srchproc.py](https://git.hmp.today/pavel.muhortov/utils#srchproc-py) in the same directory **Dependencies:** Python 3 (tested version 3.9.5), installed or downloaded ffmpeg, [procutil.py](https://git.hmp.today/pavel.muhortov/utils#procutil-py) in the same directory
| PARAMETERS | DESCRIPTION | DEFAULT| | PARAMETERS | DESCRIPTION | DEFAULT|
|-------------|-------------|--------| |-------------|-------------|--------|
@ -37,6 +37,38 @@ FFmpeg.run(src='null, anull', preset='240p', fps=10)
``` ```
____ ____
## procutil.py
**Description:** Find a running process from Python
**Dependencies:** Python 3 (tested version 3.9.5)
| PARAMETERS | DESCRIPTION | DEFAULT|
|-------------|-------------|--------|
|**[-h]**|print help and exit||
|**[--find]**|find process pid, name or arguments||
|**[--exclude]**|exclude process pid, name or arguments|`None`|
|**[--self]**|find a clones of self|`True`|
|**[--kill]**|kill the process with pid||
Example usage in terminal with Python for find all running processes:
```shell
python3 ./procutil.py
```
Example usage in terminal with make the script executable for find all specified processes:
```shell
chmod u+x ./procutil.py
./procutil.py --find ssh --exclude sftp
```
Example usage in Python for find a clones of self:
```Python
from os import getpid
from sys import argv
from procutil import Proc
processes = Proc.search(' '.join(argv), str(getpid()))
if processes:
for process in processes:
print(process)
```
## sendmail.py ## sendmail.py
**Description:** Sending email from Python **Description:** Sending email from Python
**Dependencies:** Python 3 (tested version 3.9.5) **Dependencies:** Python 3 (tested version 3.9.5)
@ -75,35 +107,3 @@ print(log)
``` ```
____ ____
## srchproc.py
**Description:** Find a running process from Python
**Dependencies:** Python 3 (tested version 3.9.5)
| PARAMETERS | DESCRIPTION | DEFAULT|
|-------------|-------------|--------|
|**[-h]**|print help and exit||
|**[--find]**|find process pid, name or arguments||
|**[--exclude]**|exclude process pid, name or arguments|`None`|
|**[--self]**|find a clones of self|`True`|
|**[--kill]**|kill the process with pid||
Example usage in terminal with Python for find all running processes:
```shell
python3 ./srchproc.py
```
Example usage in terminal with make the script executable for find all specified processes:
```shell
chmod u+x ./sendmail.py
./srchproc.py --find ssh --exclude sftp
```
Example usage in Python for find a clones of self:
```Python
from os import getpid
from sys import argv
from srchproc import Proc
processes = Proc.search(' '.join(argv), str(getpid()))
if processes:
for process in processes:
print(process)
```

View File

@ -6,7 +6,7 @@ from os import path, environ
from subprocess import Popen, PIPE, STDOUT from subprocess import Popen, PIPE, STDOUT
from sys import platform from sys import platform
from time import sleep from time import sleep
from srchproc import Proc # or copy class Proc from file srchproc.py here for autonomy of this file from procutil import Proc # or copy class Proc from file procutil.py here for autonomy of this file
class FFmpeg: class FFmpeg:
@ -177,7 +177,7 @@ if __name__ == "__main__":
epilog='Dependencies: ' epilog='Dependencies: '
'Python 3 (tested version 3.9.5), ' 'Python 3 (tested version 3.9.5), '
'installed or downloaded ffmpeg, ' 'installed or downloaded ffmpeg, '
'srchproc.py in the same directory' 'procutil.py in the same directory'
) )
args.add_argument('-s', '--src', type=str, required=True, args.add_argument('-s', '--src', type=str, required=True,
help='sources urls (example: "rtsp://user:pass@host:554/Streaming/Channels/101, anull")') help='sources urls (example: "rtsp://user:pass@host:554/Streaming/Channels/101, anull")')