VRUtil/vrutil/utils.py

30 lines
614 B
Python
Raw Normal View History

#!/usr/bin/env python3
import os
import subprocess
import traceback
def loaded(option, value=None):
print(f'Loaded {option}' + (f': {value}' if value is not None else ''))
def store(option, value):
print(f'Store {option}: {value}')
2024-07-07 16:53:24 +02:00
def write_as_sudo(file, value):
try:
if os.geteuid() == 0:
with open(file, 'w') as f:
f.write(value)
else:
subprocess.call([
'pkexec',
'sh',
'-c',
2024-07-07 16:53:24 +02:00
f'echo "{value}" > {file}'
])
except:
traceback.print_exc()
pass