machineconfig 5.92__py3-none-any.whl → 5.94__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.
Potentially problematic release.
This version of machineconfig might be problematic. Click here for more details.
- machineconfig/settings/shells/bash/init.sh +0 -1
- machineconfig/utils/procs.py +31 -14
- {machineconfig-5.92.dist-info → machineconfig-5.94.dist-info}/METADATA +1 -1
- {machineconfig-5.92.dist-info → machineconfig-5.94.dist-info}/RECORD +7 -7
- {machineconfig-5.92.dist-info → machineconfig-5.94.dist-info}/WHEEL +0 -0
- {machineconfig-5.92.dist-info → machineconfig-5.94.dist-info}/entry_points.txt +0 -0
- {machineconfig-5.92.dist-info → machineconfig-5.94.dist-info}/top_level.txt +0 -0
|
@@ -16,7 +16,6 @@ add_to_path_if_not_already \
|
|
|
16
16
|
"$HOME/.cargo/bin" \
|
|
17
17
|
"$CONFIG_ROOT/scripts/linux" \
|
|
18
18
|
"$HOME/dotfiles/scripts/linux" \
|
|
19
|
-
|
|
20
19
|
"/usr/games"
|
|
21
20
|
# this way, if the script was run multiple times, e.g. due to nested shells in zellij, there will be no duplicates in the path
|
|
22
21
|
# export DISPLAY=localhost:0.0 # xming server
|
machineconfig/utils/procs.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import psutil
|
|
4
4
|
from rich.progress import Progress, SpinnerColumn, TextColumn
|
|
5
5
|
from machineconfig.utils.options import choose_from_options
|
|
6
|
-
from typing import Optional
|
|
6
|
+
from typing import Optional, TypedDict, List, Dict
|
|
7
7
|
from rich.console import Console
|
|
8
8
|
from rich.panel import Panel
|
|
9
9
|
from datetime import datetime
|
|
@@ -14,11 +14,29 @@ console = Console()
|
|
|
14
14
|
BOX_WIDTH = 78 # width for box drawing
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
class ProcessInfo(TypedDict):
|
|
18
|
+
"""TypedDict for process information."""
|
|
19
|
+
command: str
|
|
20
|
+
pid: int
|
|
21
|
+
name: str
|
|
22
|
+
username: str
|
|
23
|
+
cpu_percent: float
|
|
24
|
+
memory_usage_mb: float
|
|
25
|
+
status: str
|
|
26
|
+
create_time: datetime
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class FileAccessInfo(TypedDict):
|
|
30
|
+
"""TypedDict for file access information."""
|
|
31
|
+
pid: int
|
|
32
|
+
files: List[str]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_processes_accessing_file(path: str) -> List[FileAccessInfo]:
|
|
18
36
|
# header for searching processes
|
|
19
37
|
title = "🔍 SEARCHING FOR PROCESSES ACCESSING FILE"
|
|
20
38
|
console.print(Panel(title, title="[bold blue]Process Info[/bold blue]", border_style="blue"))
|
|
21
|
-
res:
|
|
39
|
+
res: Dict[int, List[str]] = {}
|
|
22
40
|
|
|
23
41
|
with Progress(SpinnerColumn(), TextColumn("[progress.description]{task.description}")) as progress:
|
|
24
42
|
progress.add_task("🔎 Scanning processes...", total=None)
|
|
@@ -33,7 +51,7 @@ def get_processes_accessing_file(path: str):
|
|
|
33
51
|
res[proc.pid] = tmp
|
|
34
52
|
|
|
35
53
|
# Convert to list of dictionaries for consistent data structure
|
|
36
|
-
result_data = [{"pid": pid, "files": files} for pid, files in res.items()]
|
|
54
|
+
result_data: List[FileAccessInfo] = [{"pid": pid, "files": files} for pid, files in res.items()]
|
|
37
55
|
console.print(Panel(f"✅ Found {len(res)} processes accessing the specified file", title="[bold blue]Process Info[/bold blue]", border_style="blue"))
|
|
38
56
|
return result_data
|
|
39
57
|
|
|
@@ -56,7 +74,7 @@ class ProcessManager:
|
|
|
56
74
|
# header for initializing process manager
|
|
57
75
|
title = "📊 INITIALIZING PROCESS MANAGER"
|
|
58
76
|
console.print(Panel(title, title="[bold blue]Process Info[/bold blue]", border_style="blue"))
|
|
59
|
-
process_info = []
|
|
77
|
+
process_info: List[ProcessInfo] = []
|
|
60
78
|
with Progress(SpinnerColumn(), TextColumn("[progress.description]{task.description}")) as progress:
|
|
61
79
|
progress.add_task("🔍 Reading system processes...", total=None)
|
|
62
80
|
for proc in psutil.process_iter():
|
|
@@ -90,8 +108,8 @@ class ProcessManager:
|
|
|
90
108
|
return ""
|
|
91
109
|
|
|
92
110
|
# Create header
|
|
93
|
-
_headers = ["PID", "Name", "Username", "CPU%", "Memory(MB)", "Status", "Create Time"
|
|
94
|
-
header_line = f"{'PID':<8} {'Name':<20} {'Username':<12} {'CPU%':<8} {'Memory(MB)':<12} {'Status':<12} {'Create Time':<20}
|
|
111
|
+
_headers = ["Command", "PID", "Name", "Username", "CPU%", "Memory(MB)", "Status", "Create Time"]
|
|
112
|
+
header_line = f"{'Command':<50} {'PID':<8} {'Name':<20} {'Username':<12} {'CPU%':<8} {'Memory(MB)':<12} {'Status':<12} {'Create Time':<20}"
|
|
95
113
|
separator = "-" * len(header_line)
|
|
96
114
|
|
|
97
115
|
lines = [header_line, separator]
|
|
@@ -102,7 +120,7 @@ class ProcessManager:
|
|
|
102
120
|
# Truncate command if too long
|
|
103
121
|
command = process["command"][:47] + "..." if len(process["command"]) > 50 else process["command"]
|
|
104
122
|
|
|
105
|
-
line = f"{process['pid']:<8} {process['name'][:19]:<20} {process['username'][:11]:<12} {process['cpu_percent']:<8.1f} {process['memory_usage_mb']:<12.2f} {process['status'][:11]:<12} {create_time_str:<20}
|
|
123
|
+
line = f"{command:<50} {process['pid']:<8} {process['name'][:19]:<20} {process['username'][:11]:<12} {process['cpu_percent']:<8.1f} {process['memory_usage_mb']:<12.2f} {process['status'][:11]:<12} {create_time_str:<20}"
|
|
106
124
|
lines.append(line)
|
|
107
125
|
|
|
108
126
|
return "\n".join(lines)
|
|
@@ -126,7 +144,7 @@ class ProcessManager:
|
|
|
126
144
|
print(f"PID: {process['pid']}, Name: {process['name']}, Memory: {process['memory_usage_mb']:.2f}MB")
|
|
127
145
|
|
|
128
146
|
for idx, process in enumerate(selected_processes):
|
|
129
|
-
pprint(process, f"📌 Process {idx}")
|
|
147
|
+
pprint(dict(process), f"📌 Process {idx}")
|
|
130
148
|
|
|
131
149
|
kill_all = input("\n⚠️ Confirm killing ALL selected processes? y/[n] ").lower() == "y"
|
|
132
150
|
if kill_all:
|
|
@@ -138,7 +156,7 @@ class ProcessManager:
|
|
|
138
156
|
indices = [int(val) for val in kill_by_index.split(" ")]
|
|
139
157
|
target_processes = [selected_processes[i] for i in indices]
|
|
140
158
|
for idx2, process in enumerate(target_processes):
|
|
141
|
-
pprint(process, f"🎯 Target Process {idx2}")
|
|
159
|
+
pprint(dict(process), f"🎯 Target Process {idx2}")
|
|
142
160
|
_ = self.kill(pids=[p["pid"] for p in target_processes]) if input("\n⚠️ Confirm termination? y/[n] ").lower() == "y" else None
|
|
143
161
|
console.print(Panel("🔔 No processes were terminated.", title="[bold blue]Process Info[/bold blue]", border_style="blue"))
|
|
144
162
|
|
|
@@ -185,7 +203,7 @@ class ProcessManager:
|
|
|
185
203
|
try:
|
|
186
204
|
proc = psutil.Process(pid)
|
|
187
205
|
proc_name = proc.name()
|
|
188
|
-
proc_lifetime = get_age(proc.create_time())
|
|
206
|
+
proc_lifetime = get_age(datetime.fromtimestamp(proc.create_time(), tz=None))
|
|
189
207
|
proc.kill()
|
|
190
208
|
print(f'💀 Killed process with PID {pid} and name "{proc_name}". It lived {proc_lifetime}. RIP 🪦💐')
|
|
191
209
|
killed_count += 1
|
|
@@ -205,10 +223,9 @@ class ProcessManager:
|
|
|
205
223
|
console.print(Panel(f"✅ Termination complete: {killed_count} processes terminated", title="[bold blue]Process Info[/bold blue]", border_style="blue"))
|
|
206
224
|
|
|
207
225
|
|
|
208
|
-
def get_age(create_time:
|
|
226
|
+
def get_age(create_time: datetime) -> str:
|
|
209
227
|
dtm_now = datetime.now()
|
|
210
|
-
|
|
211
|
-
delta = dtm_now - dtm_create
|
|
228
|
+
delta = dtm_now - create_time
|
|
212
229
|
return str(delta).split(".")[0] # remove microseconds
|
|
213
230
|
|
|
214
231
|
|
|
@@ -323,7 +323,7 @@ machineconfig/settings/rofi/config.rasi,sha256=nDX5B8wdXQYF1fwiOTBRJUI4l_gQbYaLa
|
|
|
323
323
|
machineconfig/settings/rofi/config_default.rasi,sha256=rTfKnC-bZuWX1l-lWQACCUOE1ShhkfykAxtXX9PlQHE,4694
|
|
324
324
|
machineconfig/settings/shells/alacritty/alacritty.toml,sha256=EbL-2Y4QunW1pvRWB2yuLCw8MMPONheJr5LFoWRieUQ,871
|
|
325
325
|
machineconfig/settings/shells/alacritty/alacritty.yml,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
326
|
-
machineconfig/settings/shells/bash/init.sh,sha256=
|
|
326
|
+
machineconfig/settings/shells/bash/init.sh,sha256=vQCV0bnIh8nBiFq1d2YoToDqPdPTrCPDEeRFY0Om6sE,2266
|
|
327
327
|
machineconfig/settings/shells/hyper/.hyper.js,sha256=h-HqeYlvPvPD4Ee7828Cxo87uVkzbMGJFqXTZIWoegw,8884
|
|
328
328
|
machineconfig/settings/shells/ipy/profiles/default/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
329
329
|
machineconfig/settings/shells/ipy/profiles/default/startup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -392,7 +392,7 @@ machineconfig/utils/notifications.py,sha256=tuXIudcip0tEioG-bm8BbLr3FMDve4f6Bktl
|
|
|
392
392
|
machineconfig/utils/options.py,sha256=vUO4Kej-vDOv64wHr2HNDyu6PATURpjd7xp6N8OOoJg,7083
|
|
393
393
|
machineconfig/utils/path_extended.py,sha256=4RhL0twcIG2kJxmC4r_YzaiTxrYkSRbdh9SO5ObMABw,53122
|
|
394
394
|
machineconfig/utils/path_helper.py,sha256=0e3Xh3BAEv27oqcezNeVLHJllGmLEgLH4T1l90m-650,8014
|
|
395
|
-
machineconfig/utils/procs.py,sha256=
|
|
395
|
+
machineconfig/utils/procs.py,sha256=rw8LR8MjGgvtrpcgxb3hudq2B9fkkpYUXe9x5-FgHuc,10694
|
|
396
396
|
machineconfig/utils/scheduler.py,sha256=jZ_1yghqA3-aINPRmE_76gboqJc0UElroR7urNOfXKs,14940
|
|
397
397
|
machineconfig/utils/scheduling.py,sha256=RF1iXJpqf4Dg18jdZWtBixz97KAHC6VKYqTFSpdLWuc,11188
|
|
398
398
|
machineconfig/utils/source_of_truth.py,sha256=ZAnCRltiM07ig--P6g9_6nEAvNFC4X4ERFTVcvpIYsE,764
|
|
@@ -421,8 +421,8 @@ machineconfig/utils/schemas/installer/installer_types.py,sha256=QClRY61QaduBPJoS
|
|
|
421
421
|
machineconfig/utils/schemas/layouts/layout_types.py,sha256=TcqlZdGVoH8htG5fHn1KWXhRdPueAcoyApppZsPAPto,2020
|
|
422
422
|
machineconfig/utils/schemas/repos/repos_types.py,sha256=ECVr-3IVIo8yjmYmVXX2mnDDN1SLSwvQIhx4KDDQHBQ,405
|
|
423
423
|
machineconfig/utils/ssh_utils/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
424
|
-
machineconfig-5.
|
|
425
|
-
machineconfig-5.
|
|
426
|
-
machineconfig-5.
|
|
427
|
-
machineconfig-5.
|
|
428
|
-
machineconfig-5.
|
|
424
|
+
machineconfig-5.94.dist-info/METADATA,sha256=RkrR24IGdAjvpYIIwt594YIkWuLUq_IYtBRqrDU0YDs,3012
|
|
425
|
+
machineconfig-5.94.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
426
|
+
machineconfig-5.94.dist-info/entry_points.txt,sha256=M0jwN_brZdXWhmNVeXLvdKxfkv8WhhXFZYcuKBA9qnk,418
|
|
427
|
+
machineconfig-5.94.dist-info/top_level.txt,sha256=porRtB8qms8fOIUJgK-tO83_FeH6Bpe12oUVC670teA,14
|
|
428
|
+
machineconfig-5.94.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|