Javi Merino | 572049d | 2014-03-31 16:45:23 +0100 | [diff] [blame] | 1 | #!/usr/bin/python3 |
| 2 | """Process the output of the power allocator trace in the current directory's trace.dat""" |
| 3 | |
| 4 | import os |
| 5 | import subprocess |
| 6 | |
| 7 | class Thermal(object): |
| 8 | def __init__(self): |
| 9 | if not os.path.isfile("trace.txt"): |
| 10 | self.__run_trace_cmd_report() |
| 11 | |
| 12 | |
| 13 | def __run_trace_cmd_report(self): |
| 14 | """Run "trace-cmd report > trace.txt". Overwrites the contents of trace.txt if it exists.""" |
| 15 | with open(os.devnull) as devnull: |
| 16 | out = subprocess.check_output(["trace-cmd", "report"], stderr=devnull) |
| 17 | |
| 18 | with open("trace.txt", "w") as f: |
| 19 | f.write(out) |