Commit 42b2b5ef authored by Jérome Perrin's avatar Jérome Perrin Committed by Thomas Gambier

collect: tolerate "No sensors found!" error running sensors

/reviewed-on nexedi/slapos.core!81
parent d4d89cce
from __future__ import print_function
from multiprocessing import Process, active_children, cpu_count, Pipe
import subprocess
try:
import subprocess32 as subprocess
except ImportError:
import subprocess
import os
import signal
import sys
......@@ -15,9 +18,18 @@ except NotImplementedError:
DEFAULT_CPU = 1
def collectComputerTemperature(sensor_bin="sensors"):
stdout = subprocess.check_output((sensor_bin, '-u'), universal_newlines=True)
sensor_output_list = stdout.splitlines()
result = subprocess.run((sensor_bin, '-u'),
universal_newlines=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
if result.returncode:
# This can happen on environments where sensors are not available,
# such as virtual machines.
if "No sensors found!" not in result.stdout:
raise RuntimeError("Error executing {}: {}".format(sensor_bin, result.stdout))
sensor_output_list = result.stdout.splitlines()
adapter_name = ""
sensor_temperature_list = []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment