Migrate from pysensors to py3sensors

pull/354/head
Alessio Sergi 2014-03-13 13:13:13 +01:00
parent aa99ebed5a
commit db4b9ae147
5 changed files with 12 additions and 5 deletions

View File

@ -34,7 +34,7 @@ Requirements
Optional dependencies:
- ``jinja2`` (for HTML output)
- ``pysensors`` (for HW monitoring support) [Linux-only]
- ``py3sensors`` (for HW monitoring support) [Linux-only]
- ``hddtemp`` (for HDD temperature monitoring support)
- ``batinfo`` (for battery monitoring support) [Linux-only]

View File

@ -57,7 +57,7 @@ class Config:
for path in self.get_paths_list():
if (os.path.isfile(path) and os.path.getsize(path) > 0):
try:
if (sys.version_info >= (3, 2)):
if is_python3:
self.parser.read(path, encoding='utf-8')
else:
self.parser.read(path)

View File

@ -52,6 +52,9 @@ work_path = os.path.realpath(os.path.dirname(__file__))
appname_path = os.path.split(sys.argv[0])[0]
sys_prefix = os.path.realpath(os.path.dirname(appname_path))
# Is this Python 3?
is_python3 = sys.version_info >= (3, 2)
# Operating system flag
# Note: Somes libs depends of OS
is_BSD = sys.platform.find('bsd') != -1

View File

@ -26,6 +26,7 @@ except:
pass
# Import Glances lib
from glances.core.glances_globals import is_python3
from glances_hddtemp import Plugin as HddTempPlugin
from glances_plugin import GlancesPlugin
# from glances.core.glances_timer import getTimeSinceLastUpdate
@ -61,7 +62,7 @@ class glancesGrabSensors:
for chip in sensors.iter_detected_chips():
for feature in chip:
sensors_current = {}
if feature.name.startswith('temp'):
if feature.name.startswith(b'temp'):
sensors_current['label'] = feature.label[:20]
sensors_current['value'] = int(feature.get_value())
self.sensors_list.append(sensors_current)
@ -117,7 +118,10 @@ class Plugin(GlancesPlugin):
# Header
msg = "{0:8}".format(_("SENSORS"))
ret.append(self.curse_add_line(msg, "TITLE"))
msg = "{0:>16}".format(_("°C"))
if is_python3:
msg = "{0:>15}".format(_("°C"))
else:
msg = "{0:>16}".format(_("°C"))
ret.append(self.curse_add_line(msg))
# Sensors list (sorted by name): Sensors
sensor_list = sorted(self.stats, key=lambda sensors: sensors['label'])

View File

@ -45,7 +45,7 @@ setup(
install_requires=requires,
extras_require={
'HTML': ['jinja2'],
'SENSORS': ['pysensors'],
'SENSORS': ['py3sensors'],
'BATINFO': ['batinfo']
},
packages=['glances'],