[modules/nvidiagpu] quotes

This commit is contained in:
tobi-wan-kenobi 2020-04-24 16:09:12 +02:00
parent 53afade88d
commit 97866362d5

View file

@ -3,7 +3,7 @@
"""Displays GPU name, temperature and memory usage. """Displays GPU name, temperature and memory usage.
Parameters: Parameters:
* nvidiagpu.format: Format string (defaults to "{name}: {temp}°C %{usedmem}/{totalmem} MiB") * nvidiagpu.format: Format string (defaults to '{name}: {temp}°C %{usedmem}/{totalmem} MiB')
Available values are: {name} {temp} {mem_used} {mem_total} {fanspeed} {clock_gpu} {clock_mem} Available values are: {name} {temp} {mem_used} {mem_total} {fanspeed} {clock_gpu} {clock_mem}
Requires nvidia-smi Requires nvidia-smi
@ -17,7 +17,7 @@ import bumblebee.engine
class Module(bumblebee.engine.Module): class Module(bumblebee.engine.Module):
def __init__(self, engine, config): def __init__(self, engine, config):
super(Module, self).__init__(engine, config, bumblebee.output.Widget(full_text=self.utilization)) super(Module, self).__init__(engine, config, bumblebee.output.Widget(full_text=self.utilization))
self._utilization = "Not found: 0 0/0" self._utilization = 'Not found: 0 0/0'
def utilization(self, widget): def utilization(self, widget):
return self._utilization return self._utilization
@ -25,41 +25,41 @@ class Module(bumblebee.engine.Module):
def update(self, widgets): def update(self, widgets):
sp = subprocess.Popen(['nvidia-smi', '-q'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) sp = subprocess.Popen(['nvidia-smi', '-q'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out_str = sp.communicate() out_str = sp.communicate()
out_list = out_str[0].decode("utf-8").split('\n') out_list = out_str[0].decode('utf-8').split('\n')
title = "" title = ''
usedMem = "" usedMem = ''
totalMem = "" totalMem = ''
temp = "" temp = ''
name = "not found" name = 'not found'
clockMem = "" clockMem = ''
clockGpu = "" clockGpu = ''
fanspeed = "" fanspeed = ''
for item in out_list: for item in out_list:
try: try:
key, val = item.split(':') key, val = item.split(':')
key, val = key.strip(), val.strip() key, val = key.strip(), val.strip()
if title == "Clocks": if title == 'Clocks':
if key == "Graphics": if key == 'Graphics':
clockGpu = val.split(" ")[0] clockGpu = val.split(' ')[0]
elif key == "Memory": elif key == 'Memory':
clockMem = val.split(" ")[0] clockMem = val.split(' ')[0]
if title == "FB Memory Usage": if title == 'FB Memory Usage':
if key == "Total": if key == 'Total':
totalMem = val.split(" ")[0] totalMem = val.split(' ')[0]
elif key == "Used": elif key == 'Used':
usedMem = val.split(" ")[0] usedMem = val.split(' ')[0]
elif key == "GPU Current Temp": elif key == 'GPU Current Temp':
temp = val.split(" ")[0] temp = val.split(' ')[0]
elif key == "Product Name": elif key == 'Product Name':
name = val name = val
elif key == "Fan Speed": elif key == 'Fan Speed':
fanspeed = val.split(" ")[0] fanspeed = val.split(' ')[0]
except: except:
title = item.strip() title = item.strip()
str_format = self.parameter("format", '{name}: {temp}°C {mem_used}/{mem_total} MiB') str_format = self.parameter('format', '{name}: {temp}°C {mem_used}/{mem_total} MiB')
self._utilization = str_format.format( self._utilization = str_format.format(
name = name, name = name,
temp = temp, temp = temp,