WizardKit/.bin/Scripts/hw-sensors-monitor
2Shirt 5550cce8db
Add background mode for monitoring sensors
* This will be called by hw_diags.py to update a file in the background
* NOTE: This uses a naive check before attempting to write data
2018-12-05 23:55:15 -07:00

37 lines
911 B
Python
Executable file

#!/bin/python3
#
## Wizard Kit: Sensor monitoring tool
import os
import sys
# Init
os.chdir(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(os.getcwd())
from functions.sensors import *
from functions.tmux import *
init_global_vars()
if __name__ == '__main__':
background = False
try:
if len(sys.argv) > 1 and os.path.exists(sys.argv[1]):
background = True
monitor_file = sys.argv[1]
monitor_pane=None
else:
result = run_program(['mktemp'])
monitor_file = result.stdout.decode().strip()
if not background:
monitor_pane = tmux_split_window(
percent=1, vertical=True, watch=monitor_file)
cmd = ['tmux', 'resize-pane', '-Z', '-t', monitor_pane]
run_program(cmd, check=False)
monitor_sensors(monitor_pane, monitor_file)
exit_script()
except SystemExit:
pass
except:
major_exception()
# vim: sts=2 sw=2 ts=2