PyManagerTool 1.0.0__tar.gz
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.
- pymanagertool-1.0.0/PKG-INFO +26 -0
- pymanagertool-1.0.0/ProcessLib/__init__.py +117 -0
- pymanagertool-1.0.0/PyManagerTool.egg-info/PKG-INFO +26 -0
- pymanagertool-1.0.0/PyManagerTool.egg-info/SOURCES.txt +7 -0
- pymanagertool-1.0.0/PyManagerTool.egg-info/dependency_links.txt +1 -0
- pymanagertool-1.0.0/PyManagerTool.egg-info/top_level.txt +1 -0
- pymanagertool-1.0.0/README.md +9 -0
- pymanagertool-1.0.0/setup.cfg +4 -0
- pymanagertool-1.0.0/setup.py +15 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: PyManagerTool
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Simple and powerful process management library for Python
|
|
5
|
+
Author: Suleiman
|
|
6
|
+
Author-email: steal.apet@mail.ru
|
|
7
|
+
License: MIT
|
|
8
|
+
Requires-Python: >=3.6
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Dynamic: author
|
|
11
|
+
Dynamic: author-email
|
|
12
|
+
Dynamic: description
|
|
13
|
+
Dynamic: description-content-type
|
|
14
|
+
Dynamic: license
|
|
15
|
+
Dynamic: requires-python
|
|
16
|
+
Dynamic: summary
|
|
17
|
+
|
|
18
|
+
# ProcessLib
|
|
19
|
+
|
|
20
|
+
**ProcessLib** is a simple and powerful library for process management in Python.
|
|
21
|
+
It allows you to run Python code in separate processes, check their status, and terminate them.
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install ProcessLib
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ProcessLib - The best Process Manager of the Python.
|
|
3
|
+
By: Suleiman
|
|
4
|
+
Copyright © Suleiman 2026
|
|
5
|
+
All rights are reserved.
|
|
6
|
+
"""
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
import time
|
|
10
|
+
import subprocess as CMD
|
|
11
|
+
|
|
12
|
+
class Process:
|
|
13
|
+
@staticmethod
|
|
14
|
+
def StartPyCode(code, wait=False, args=None, python="python"):
|
|
15
|
+
try:
|
|
16
|
+
cmd = [python, "-c", code]
|
|
17
|
+
if args:
|
|
18
|
+
cmd.extend(args)
|
|
19
|
+
if wait:
|
|
20
|
+
proc = CMD.run(cmd, capture_output=True, text=True)
|
|
21
|
+
return proc
|
|
22
|
+
else:
|
|
23
|
+
proc = CMD.Popen(cmd)
|
|
24
|
+
return proc
|
|
25
|
+
except Exception as e:
|
|
26
|
+
print(f"Error executing code: {e}")
|
|
27
|
+
return None
|
|
28
|
+
|
|
29
|
+
@staticmethod
|
|
30
|
+
def KillPyScript(pid):
|
|
31
|
+
try:
|
|
32
|
+
os.kill(pid, 15)
|
|
33
|
+
time.sleep(0.2)
|
|
34
|
+
return True
|
|
35
|
+
except ProcessLookupError:
|
|
36
|
+
print(f"Process {pid} not found")
|
|
37
|
+
return False
|
|
38
|
+
except PermissionError:
|
|
39
|
+
print(f"Permission denied to kill process {pid}")
|
|
40
|
+
return False
|
|
41
|
+
except Exception as e:
|
|
42
|
+
print(f"Error killing process: {e}")
|
|
43
|
+
return False
|
|
44
|
+
|
|
45
|
+
@staticmethod
|
|
46
|
+
def KillPyScriptForce(pid):
|
|
47
|
+
try:
|
|
48
|
+
os.kill(pid, 9)
|
|
49
|
+
return True
|
|
50
|
+
except ProcessLookupError:
|
|
51
|
+
print(f"Process {pid} not found")
|
|
52
|
+
return False
|
|
53
|
+
except PermissionError:
|
|
54
|
+
print(f"Permission denied to kill process {pid}")
|
|
55
|
+
return False
|
|
56
|
+
except Exception as e:
|
|
57
|
+
print(f"Error killing process: {e}")
|
|
58
|
+
return False
|
|
59
|
+
|
|
60
|
+
@staticmethod
|
|
61
|
+
def IsRunning(pid):
|
|
62
|
+
try:
|
|
63
|
+
os.kill(pid, 0)
|
|
64
|
+
return True
|
|
65
|
+
except ProcessLookupError:
|
|
66
|
+
return False
|
|
67
|
+
except PermissionError:
|
|
68
|
+
return True
|
|
69
|
+
|
|
70
|
+
@staticmethod
|
|
71
|
+
def GetProcessList():
|
|
72
|
+
try:
|
|
73
|
+
result = CMD.run(['ps', '-e', '-o', 'pid,comm'], capture_output=True, text=True)
|
|
74
|
+
lines = result.stdout.strip().split('\n')[1:]
|
|
75
|
+
processes = []
|
|
76
|
+
for line in lines:
|
|
77
|
+
parts = line.strip().split(' ', 1)
|
|
78
|
+
if len(parts) == 2:
|
|
79
|
+
pid = int(parts[0])
|
|
80
|
+
name = parts[1]
|
|
81
|
+
processes.append({'pid': pid, 'name': name})
|
|
82
|
+
return processes
|
|
83
|
+
except Exception:
|
|
84
|
+
return []
|
|
85
|
+
|
|
86
|
+
@staticmethod
|
|
87
|
+
def GetProcessInfo(pid):
|
|
88
|
+
try:
|
|
89
|
+
result = CMD.run(['ps', '-p', str(pid), '-o', 'pid,comm,%cpu,%mem,etime'], capture_output=True, text=True)
|
|
90
|
+
lines = result.stdout.strip().split('\n')
|
|
91
|
+
if len(lines) < 2:
|
|
92
|
+
return None
|
|
93
|
+
parts = lines[1].strip().split()
|
|
94
|
+
if len(parts) >= 5:
|
|
95
|
+
return {
|
|
96
|
+
'pid': int(parts[0]),
|
|
97
|
+
'name': parts[1],
|
|
98
|
+
'cpu': parts[2],
|
|
99
|
+
'memory': parts[3],
|
|
100
|
+
'time': parts[4]
|
|
101
|
+
}
|
|
102
|
+
return None
|
|
103
|
+
except Exception:
|
|
104
|
+
return None
|
|
105
|
+
|
|
106
|
+
@staticmethod
|
|
107
|
+
def WaitForProcess(pid, timeout=None):
|
|
108
|
+
start_time = time.time()
|
|
109
|
+
while Process.IsRunning(pid):
|
|
110
|
+
if timeout and (time.time() - start_time) > timeout:
|
|
111
|
+
return False
|
|
112
|
+
time.sleep(0.5)
|
|
113
|
+
return True
|
|
114
|
+
|
|
115
|
+
@staticmethod
|
|
116
|
+
def GetCurrentPID():
|
|
117
|
+
return os.getpid()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: PyManagerTool
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Simple and powerful process management library for Python
|
|
5
|
+
Author: Suleiman
|
|
6
|
+
Author-email: steal.apet@mail.ru
|
|
7
|
+
License: MIT
|
|
8
|
+
Requires-Python: >=3.6
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Dynamic: author
|
|
11
|
+
Dynamic: author-email
|
|
12
|
+
Dynamic: description
|
|
13
|
+
Dynamic: description-content-type
|
|
14
|
+
Dynamic: license
|
|
15
|
+
Dynamic: requires-python
|
|
16
|
+
Dynamic: summary
|
|
17
|
+
|
|
18
|
+
# ProcessLib
|
|
19
|
+
|
|
20
|
+
**ProcessLib** is a simple and powerful library for process management in Python.
|
|
21
|
+
It allows you to run Python code in separate processes, check their status, and terminate them.
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install ProcessLib
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ProcessLib
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# setup.py
|
|
2
|
+
from setuptools import setup, find_packages
|
|
3
|
+
|
|
4
|
+
setup(
|
|
5
|
+
name="PyManagerTool",
|
|
6
|
+
version="1.0.0",
|
|
7
|
+
description="Simple and powerful process management library for Python",
|
|
8
|
+
long_description=open("README.md").read(),
|
|
9
|
+
long_description_content_type="text/markdown",
|
|
10
|
+
author="Suleiman",
|
|
11
|
+
author_email="steal.apet@mail.ru",
|
|
12
|
+
license="MIT",
|
|
13
|
+
packages=find_packages(),
|
|
14
|
+
python_requires=">=3.6",
|
|
15
|
+
)
|