Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Rafael Monnerat
slapos.core
Commits
42b2b5ef
Commit
42b2b5ef
authored
Dec 26, 2018
by
Jérome Perrin
Committed by
Thomas Gambier
Dec 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
collect: tolerate "No sensors found!" error running sensors
/reviewed-on
nexedi/slapos.core!81
parent
d4d89cce
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
slapos/collect/temperature/__init__.py
slapos/collect/temperature/__init__.py
+16
-4
No files found.
slapos/collect/temperature/__init__.py
View file @
42b2b5ef
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
=
[]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment