2023-02-11 00:46:56 +00:00
|
|
|
from yaml import safe_load
|
|
|
|
from io import open
|
|
|
|
from threading import Thread
|
|
|
|
from subprocess import run
|
|
|
|
from time import sleep
|
|
|
|
|
2023-02-11 01:20:59 +00:00
|
|
|
running_modules_dict = {}
|
|
|
|
|
|
|
|
def print_modules():
|
|
|
|
for module in running_modules_dict:
|
|
|
|
print(running_modules_dict[module] + " | ", end='')
|
|
|
|
print(flush=True)
|
|
|
|
|
|
|
|
def module_thread(name, cmd, refresh, pre, post):
|
2023-02-11 00:46:56 +00:00
|
|
|
while True:
|
2023-02-11 01:20:59 +00:00
|
|
|
result = pre
|
|
|
|
result += run(cmd, shell=True, capture_output=True, text=True).stdout.strip()
|
|
|
|
result += post
|
|
|
|
running_modules_dict[name] = result
|
|
|
|
print_modules()
|
2023-02-11 00:46:56 +00:00
|
|
|
sleep(refresh/1000)
|
|
|
|
|
|
|
|
with open("./testing_config.yml", 'r', encoding='utf8') as file:
|
|
|
|
config_file = safe_load(file)
|
|
|
|
|
|
|
|
modules = config_file['bar']['modules']
|
|
|
|
for module in modules:
|
|
|
|
cmd = modules[module]['command']
|
|
|
|
refresh = modules[module]['refresh']
|
2023-02-11 01:20:59 +00:00
|
|
|
|
|
|
|
running_modules_dict[module] = ''
|
|
|
|
|
|
|
|
x = Thread(target=module_thread, args=(module, cmd, refresh, '', ''))
|
2023-02-11 00:46:56 +00:00
|
|
|
x.start()
|