[modules/hddtemp] double to single quotes

This commit is contained in:
tobi-wan-kenobi 2020-03-31 21:03:30 +02:00
parent 0873a58dc0
commit 52ca6e5a43

View file

@ -9,12 +9,12 @@ import socket
import bumblebee.engine import bumblebee.engine
import bumblebee.output import bumblebee.output
HOST = "localhost" HOST = 'localhost'
PORT = 7634 PORT = 7634
CHUNK_SIZE = 1024 CHUNK_SIZE = 1024
RECORD_SIZE = 5 RECORD_SIZE = 5
SEPARATOR = "|" SEPARATOR = '|'
class Module(bumblebee.engine.Module): class Module(bumblebee.engine.Module):
@ -31,7 +31,7 @@ class Module(bumblebee.engine.Module):
try: try:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.connect((HOST, PORT)) sock.connect((HOST, PORT))
data = "" data = ''
while True: while True:
chunk = sock.recv(CHUNK_SIZE) chunk = sock.recv(CHUNK_SIZE)
if chunk: if chunk:
@ -48,7 +48,7 @@ class Module(bumblebee.engine.Module):
split data using | separator and remove first item split data using | separator and remove first item
(because the first item is empty) (because the first item is empty)
""" """
parts = data.split("|")[1:] parts = data.split('|')[1:]
return parts return parts
@staticmethod @staticmethod
@ -66,20 +66,20 @@ class Module(bumblebee.engine.Module):
get device name (without /dev part, to save space on bar) get device name (without /dev part, to save space on bar)
and temperature (in °C) as tuple and temperature (in °C) as tuple
""" """
device_name = device_record[0].split("/")[-1] device_name = device_record[0].split('/')[-1]
device_temp = device_record[2] device_temp = device_record[2]
return (device_name, device_temp) return (device_name, device_temp)
@staticmethod @staticmethod
def _get_hddtemp(device_record): def _get_hddtemp(device_record):
name, temp = device_record name, temp = device_record
hddtemp = "{}+{}°C".format(name, temp) hddtemp = '{}+{}°C'.format(name, temp)
return hddtemp return hddtemp
def _get_hddtemps(self): def _get_hddtemps(self):
data = self._fetch_data() data = self._fetch_data()
if data is None: if data is None:
return "n/a" return 'n/a'
parts = self._get_parts(data) parts = self._get_parts(data)
per_disk = self._partition_parts(parts) per_disk = self._partition_parts(parts)
names_and_temps = [self._get_name_and_temp(x) for x in per_disk] names_and_temps = [self._get_name_and_temp(x) for x in per_disk]