Skip to content

Commit a8187bb

Browse files
authored
Merge pull request #5122 from c-po/op-mode-sensors
op-mode: T8483: fix /show_sensors.py: No such file or directory
2 parents 5c2973e + 4a5cb1d commit a8187bb

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

op-mode-definitions/show-environment.xml.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
<properties>
1212
<help>Show hardware monitoring results</help>
1313
</properties>
14-
<!-- Linux always adds "hypervisor" to CPU flags -->
15-
<command>bash -c 'if ! grep -q hypervisor /proc/cpuinfo; then ${vyos_op_scripts_dir}/show_sensors.py; else echo "VyOS running under hypervisor, no sensors available"; fi'</command>
14+
<command>${vyos_op_scripts_dir}/show_sensors.py</command>
1615
</leafNode>
1716
</children>
1817
</node>

src/op_mode/show_sensors.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,26 @@
1717

1818
import re
1919
import sys
20+
2021
from vyos.utils.process import popen
2122
from vyos.utils.process import DEVNULL
2223

23-
output,retcode = popen("sensors --no-adapter", stderr=DEVNULL)
24+
output, retcode = popen("sensors --no-adapter", stderr=DEVNULL)
2425
if retcode == 0:
2526
print (output)
2627
sys.exit(0)
2728
else:
28-
output,retcode = popen("sensors-detect --auto",stderr=DEVNULL)
29-
match = re.search(r'#----cut here----(.*)#----cut here----',output, re.DOTALL)
29+
output, retcode = popen("sensors-detect --auto", stderr=DEVNULL)
30+
match = re.search(r'#----cut here----(.*)#----cut here----', output,
31+
re.DOTALL)
3032
if match:
3133
for module in match.group(0).split('\n'):
3234
if not module.startswith("#"):
3335
popen("modprobe {}".format(module.strip()))
34-
output,retcode = popen("sensors --no-adapter", stderr=DEVNULL)
36+
output, retcode = popen("sensors --no-adapter", stderr=DEVNULL)
3537
if retcode == 0:
36-
print (output)
38+
print(output)
3739
sys.exit(0)
3840

39-
40-
print ("No sensors found")
41+
print("No sensors found")
4142
sys.exit(1)

0 commit comments

Comments
 (0)