serial-device/reader.py

32 lines
673 B
Python
Raw Normal View History

2023-10-01 22:41:21 +03:00
import getopt
import sys
import yaml
from data_processor import DataProcessor
config_name = 'config.yml'
options = "hc:"
long_options = ["help", "config="]
argumentList = sys.argv[1:]
arguments, values = getopt.getopt(argumentList, options, long_options)
for currentArgument, currentValue in arguments:
if currentArgument in ("-h", "--help"):
print("reader.py [--config=path/to/config.yml]")
sys.exit(0)
elif currentArgument in ("-c", "--config"):
config_name = currentValue
with open(config_name) as f:
config = yaml.load(f, Loader=yaml.FullLoader)
print("config: ", config)
processor = DataProcessor(config)
processor.run()