-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_handler.py
39 lines (35 loc) · 1.42 KB
/
config_handler.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
36
37
38
39
def modify_config_file(config_path, setting, new_value):
"""Modifies a setting in bluestacks.conf."""
changed = False
try:
with open(config_path, "r") as f:
lines = f.readlines()
with open(config_path, "w") as f:
for line in lines:
if line.startswith(f"{setting}="):
f.write(f"{setting}=\"{new_value}\"\n")
changed = True
else:
f.write(line)
if changed:
print(f"Successfully updated '{setting}' to '{new_value}' in {config_path}")
else:
print(f"No changes made for '{setting}' in {config_path}")
except FileNotFoundError:
print(f"Error: File not found at {config_path}")
except Exception as e:
print(f"Error modifying configuration: {e}")
def is_root_enabled(config_path, instance_name):
"""Checks if root access is enabled for a specific instance."""
try:
with open(config_path, "r") as f:
for line in f:
if line.startswith(f"bst.instance.{instance_name}.enable_root_access="):
return line.strip().endswith("=\"1\"")
return False
except FileNotFoundError:
print(f"Error: File not found at {config_path}")
return False
except Exception as e:
print(f"Error reading configuration: {e}")
return False