[modules/sensors] Remove unused imports and minor reformatting

This commit is contained in:
Tobias Witek 2017-06-15 07:48:25 +02:00
parent df6e323fa4
commit 215bfd23df

View file

@ -1,3 +1,4 @@
# -*- coding: UTF-8 -*-
# pylint: disable=C0111,R0903
"""Displays sensor temperature
@ -11,9 +12,6 @@ Parameters:
"""
import re
import decimal
from subprocess import call
import bumblebee.input
import bumblebee.output
@ -24,6 +22,7 @@ class Module(bumblebee.engine.Module):
super(Module, self).__init__(engine, config,
bumblebee.output.Widget(full_text=self.temperature))
self._temperature = "unknown"
self._mhz = "n/a"
pattern = self.parameter("match", "temp1_input")
pattern_string = r"^\s*{}:\s*([\d.]+)$".format(pattern)
self._match_number = int(self.parameter("match_number", "-1"))
@ -40,17 +39,17 @@ class Module(bumblebee.engine.Module):
return temperature
def get_mhz( self ):
output = open( '/proc/cpuinfo' ).read()
m = re.search( r"cpu MHz\s+:\s+(\d+)", output )
mhz = int( m.group( 1 ) )
output = open("/proc/cpuinfo").read()
m = re.search(r"cpu MHz\s+:\s+(\d+)", output)
mhz = int(m.group(1))
if mhz < 1000:
return "{} MHz".format( mhz )
return "{} MHz".format(mhz)
else:
return "%.1f GHz" % ( decimal.Decimal( mhz ) / 1000 )
return "{:0.01f} GHz".format(float(mhz)/1000.0)
def temperature(self, _):
return u"{}°c @ {}".format( self._temperature, self._mhz )
return u"{}°c @ {}".format(self._temperature, self._mhz)
def update(self, widgets):
self._temperature = self.get_temp()