From 215bfd23dfde50d86d7cf6181000bd73000e0ce8 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Thu, 15 Jun 2017 07:48:25 +0200 Subject: [PATCH] [modules/sensors] Remove unused imports and minor reformatting --- bumblebee/modules/sensors.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/bumblebee/modules/sensors.py b/bumblebee/modules/sensors.py index 4f1a879..b8d77d7 100644 --- a/bumblebee/modules/sensors.py +++ b/bumblebee/modules/sensors.py @@ -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()