feature: print help if ini file is missing

This commit is contained in:
uhi22 2023-05-12 08:17:17 +02:00
parent 4edad2658a
commit 82f08c7c4a

View file

@ -3,12 +3,20 @@
# See https://docs.python.org/3/library/configparser.html
import configparser
import sys
config = configparser.ConfigParser()
config.read('pyPlc.ini')
def getConfigValue(s):
return config['general'][s]
try:
return config['general'][s]
except:
print("Error: seems we have a problem with pyPlc.ini.")
print("How to fix: Try to use the docs/pyPlc.ini.template,")
print(" copy it into the pyPlc's main folder,")
print(" rename it to pyPlc.ini, and edit it for your needs.")
sys.exit()
def getConfigValueBool(s):
return config.getboolean('general', s)