basic module parsing and threading

This commit is contained in:
Noah Swerhun 2023-02-10 18:46:56 -06:00
parent d3e2b6ec87
commit 89fd0c84b5

24
modules.py Normal file
View file

@ -0,0 +1,24 @@
from yaml import safe_load
from io import open
from threading import Thread
from subprocess import run
from time import sleep
def module_thread(cmd, refresh, pre, post):
while True:
print(pre, end='')
cmd_output = run(cmd, shell=True, capture_output=True, text=True).stdout
print(cmd_output.strip(), end='')
print(post)
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']
x = Thread(target=module_thread, args=(cmd, refresh, '', ''))
x.start()