-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathESGunRPointerKill.py
35 lines (30 loc) · 1.14 KB
/
ESGunRPointerKill.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
34
35
import os
import configparser
import subprocess
import logging
# Configuration du logger
logging.basicConfig(level=logging.INFO)
def find_ini_file(start_path):
current_path = start_path
while current_path != os.path.dirname(current_path):
ini_path = os.path.join(current_path, 'plugins', 'GunRPointer', 'config.ini')
if os.path.exists(ini_path):
return ini_path
current_path = os.path.dirname(current_path)
raise FileNotFoundError("Le fichier events.ini n'a pas été trouvé.")
def load_config():
current_working_dir = os.getcwd()
config_path = find_ini_file(current_working_dir)
config = configparser.ConfigParser()
config.read(config_path)
return config
def execute_kill_command(config):
kill_command = config['Settings']['GunRPointerKillCommand']
logging.info(f"Executing kill command: {kill_command}")
process = subprocess.run(kill_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if __name__ == "__main__":
try:
config = load_config()
execute_kill_command(config)
except Exception as e:
logging.error(f"An error occurred: {e}")