2016-10-22 19:27:28 +03:00
|
|
|
import psutil
|
|
|
|
import threading
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
|
|
class PluginThread(threading.Thread):
|
|
|
|
def __init__(self, section, config, thread_id):
|
|
|
|
threading.Thread.__init__(self)
|
|
|
|
self.threadID = thread_id
|
|
|
|
self.status = dict()
|
|
|
|
if config.has_option(section, 'color'):
|
|
|
|
self.status['color'] = config.get(section, 'color')
|
2016-10-23 01:53:02 +03:00
|
|
|
self.freq = config.get(section, 'freq', fallback=1)
|
2016-10-22 19:27:28 +03:00
|
|
|
|
|
|
|
def main(self):
|
|
|
|
mem_stat = psutil.virtual_memory()
|
2016-10-23 01:53:02 +03:00
|
|
|
mem_available = str(round(mem_stat.available / 2**30, 2))
|
|
|
|
mem = 'RAM: ' + mem_available + 'G'
|
2016-10-22 19:27:28 +03:00
|
|
|
self.status['full_text'] = mem
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
while True:
|
|
|
|
self.main()
|
|
|
|
time.sleep(self.freq)
|