mirror of
https://github.com/uhi22/pyPLC.git
synced 2024-11-10 01:05:42 +00:00
feature: print help if ini file is missing
This commit is contained in:
parent
4edad2658a
commit
82f08c7c4a
1 changed files with 9 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue