Sensors: more uniform display

Use the same letter symbol for lm_sensors and hddtemp:
- C = Celsius
- F = Fahrenheit
pull/704/head
Alessio Sergi 2015-10-12 18:12:12 +02:00
parent bbf4cffa86
commit a3f6f81ca4
1 changed files with 11 additions and 19 deletions

View File

@ -26,23 +26,14 @@ try:
except ImportError:
pass
# Import system libs
import locale
# Import Glances lib
from glances.core.glances_globals import is_py3
from glances.core.glances_logging import logger
from glances.plugins.glances_batpercent import Plugin as BatPercentPlugin
from glances.plugins.glances_hddtemp import Plugin as HddTempPlugin
from glances.plugins.glances_plugin import GlancesPlugin
if is_py3:
SENSOR_TEMP_UNIT = '°C'
else:
# ensure UTF-8 characters are in a charset the terminal can understand
SENSOR_TEMP_UNIT = u'°C '.encode(locale.getpreferredencoding(), 'ignore')
SENSOR_FAN_UNIT = 'RPM'
SENSOR_TEMP_UNIT = 'C'
SENSOR_FAN_UNIT = 'rpm'
def to_fahrenheit(celsius):
@ -200,18 +191,19 @@ class Plugin(GlancesPlugin):
label = self.has_alias(i['label'].lower())
if label is None:
label = i['label']
try:
msg = "{0:12} {1:3}".format(label[:11], i['unit'])
except (KeyError, UnicodeEncodeError):
msg = "{0:16}".format(label[:15])
if args.fahrenheit:
msg = msg.replace('°C', '°F')
if i['type'] != 'fan_speed':
msg = '{0:15}'.format(label[:15])
else:
msg = '{0:13}'.format(label[:13])
ret.append(self.curse_add_line(msg))
if args.fahrenheit and i['type'] != 'battery':
if (args.fahrenheit and i['type'] != 'battery' and
i['type'] != 'fan_speed'):
value = to_fahrenheit(i['value'])
unit = 'F'
else:
value = i['value']
msg = '{0:>7.0f}'.format(value)
unit = i['unit']
msg = '{0:>7.0f}{1}'.format(value, unit)
ret.append(self.curse_add_line(
msg, self.get_views(item=i[self.get_key()],
key='value',