Skip to content

Instantly share code, notes, and snippets.

@PhotonQuantum
Created June 1, 2019 14:08
Show Gist options
  • Save PhotonQuantum/6f73e2c191c75b348879a4af85bde253 to your computer and use it in GitHub Desktop.
Save PhotonQuantum/6f73e2c191c75b348879a4af85bde253 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import sys
import os
import subprocess
from lxml import objectify, etree
if os.path.exists('/var/lock/boinccpu.lock'):
print("Masked")
sys.exit()
with open("/var/lib/boinc/global_prefs_override.xml", mode="r+") as f:
xml_conf = objectify.fromstring(f.read())
xml_conf.cpu_usage_limit = float(sys.argv[1])
objectify.deannotate(xml_conf, cleanup_namespaces=True)
f.seek(0)
f.write(etree.tostring(xml_conf, pretty_print=True).decode())
f.truncate()
with open("/var/lib/boinc/gui_rpc_auth.cfg") as f:
passwd = f.read()
subprocess.run(["boinccmd", "--passwd", passwd, "--read_global_prefs_override"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment