From c754f48718d930f2e77a88739679f4931cb67ad9 Mon Sep 17 00:00:00 2001 From: PavelMuhortov Date: Mon, 21 Jun 2021 00:05:04 +0300 Subject: [PATCH] srchproc.py rename to procutil.py --- README.md | 68 +++++++++++++++++++------------------- ffmpeger.py | 4 +-- srchproc.py => procutil.py | 0 3 files changed, 36 insertions(+), 36 deletions(-) rename srchproc.py => procutil.py (100%) diff --git a/README.md b/README.md index 56f13d6..0607353 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # utils * [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) -* [srchproc.py](https://git.hmp.today/pavel.muhortov/utils#srchproc-py) ____ ## ffmpeger.py **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| |-------------|-------------|--------| @@ -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 **Description:** Sending email from Python **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) -``` diff --git a/ffmpeger.py b/ffmpeger.py index a06830d..e83af6a 100644 --- a/ffmpeger.py +++ b/ffmpeger.py @@ -6,7 +6,7 @@ from os import path, environ from subprocess import Popen, PIPE, STDOUT from sys import platform 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: @@ -177,7 +177,7 @@ if __name__ == "__main__": epilog='Dependencies: ' 'Python 3 (tested version 3.9.5), ' '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, help='sources urls (example: "rtsp://user:pass@host:554/Streaming/Channels/101, anull")') diff --git a/srchproc.py b/procutil.py similarity index 100% rename from srchproc.py rename to procutil.py