INNER CODE UNIT · Python
run_powermetrics_process
tlkh/asitop · asitop/utils.py:47
def run_powermetrics_process(timecode, nice=10, interval=1000):
#ver, *_ = platform.mac_ver()
#major_ver = int(ver.split(".")[0])
for tmpf in glob.glob("/tmp/asitop_powermetrics*"):
os.remove(tmpf)
output_file_flag = "-o"
command = " ".join([
"sudo nice -n",
str(nice),
"powermetrics",
"--samplers cpu_power,gpu_power,thermal",
output_file_flag,
"/tmp/asitop_powermetrics"+timecode,
"-f plist",
"-i",
str(interval)
])
process = subprocess.Popen(command.split(" "), stdin=PIPE, stdout=PIPE)