[modules/nvidiagpu] Update to latest API
This commit is contained in:
parent
97866362d5
commit
8e9fba36c4
1 changed files with 16 additions and 15 deletions
|
@ -9,23 +9,22 @@ Parameters:
|
||||||
Requires nvidia-smi
|
Requires nvidia-smi
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import subprocess
|
import core.module
|
||||||
import bumblebee.input
|
import core.widget
|
||||||
import bumblebee.output
|
|
||||||
import bumblebee.engine
|
|
||||||
|
|
||||||
class Module(bumblebee.engine.Module):
|
import util.cli
|
||||||
def __init__(self, engine, config):
|
|
||||||
super(Module, self).__init__(engine, config, bumblebee.output.Widget(full_text=self.utilization))
|
class Module(core.module.Module):
|
||||||
self._utilization = 'Not found: 0 0/0'
|
def __init__(self, config):
|
||||||
|
super().__init__(config, core.widget.Widget(self.utilization))
|
||||||
|
|
||||||
|
self.__utilization = 'Not found: 0 0/0'
|
||||||
|
|
||||||
def utilization(self, widget):
|
def utilization(self, widget):
|
||||||
return self._utilization
|
return self.__utilization
|
||||||
|
|
||||||
def update(self, widgets):
|
def update(self):
|
||||||
sp = subprocess.Popen(['nvidia-smi', '-q'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
sp = util.cli.execute('nvidia-smi -q', ignore_errors=True)
|
||||||
out_str = sp.communicate()
|
|
||||||
out_list = out_str[0].decode('utf-8').split('\n')
|
|
||||||
|
|
||||||
title = ''
|
title = ''
|
||||||
usedMem = ''
|
usedMem = ''
|
||||||
|
@ -35,7 +34,7 @@ class Module(bumblebee.engine.Module):
|
||||||
clockMem = ''
|
clockMem = ''
|
||||||
clockGpu = ''
|
clockGpu = ''
|
||||||
fanspeed = ''
|
fanspeed = ''
|
||||||
for item in out_list:
|
for item in sp.split('\n'):
|
||||||
try:
|
try:
|
||||||
key, val = item.split(':')
|
key, val = item.split(':')
|
||||||
key, val = key.strip(), val.strip()
|
key, val = key.strip(), val.strip()
|
||||||
|
@ -60,7 +59,7 @@ class Module(bumblebee.engine.Module):
|
||||||
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,
|
||||||
mem_used = usedMem,
|
mem_used = usedMem,
|
||||||
|
@ -69,3 +68,5 @@ class Module(bumblebee.engine.Module):
|
||||||
clock_mem = clockMem,
|
clock_mem = clockMem,
|
||||||
fanspeed = fanspeed,
|
fanspeed = fanspeed,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||||
|
|
Loading…
Reference in a new issue