-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprocessname.py
33 lines (26 loc) · 904 Bytes
/
processname.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import psutil
import random
def analyze_existing_process_names():
"""
Analyze existing process names and generate a custom name.
Returns:
str: Custom process name.
"""
processes = psutil.process_iter(attrs=['pid', 'name'])
process_names = [p.info['name'] for p in processes]
custom_name = random.choice(process_names) + "_custom_" + str(random.randint(1000, 9999))
return custom_name
def choose_process_name():
"""
Choose a process name based on existing process names.
Returns:
str: Chosen process name.
"""
# Get a list of all existing process names
existing_process_names = [p.name() for p in psutil.process_iter()]
if existing_process_names:
chosen_name = analyze_existing_process_names()
else:
chosen_name = "nvme-update-wq"
print(f"Process name chosen {chosen_name}")
return chosen_name