Hello. When my script is restarting I often times will have these configuration errors.
Importing:
Thank you
Importing:
import configparserAbsolute file path (attempt to fix this, didn't help):
thisfolder = os.path.dirname(os.path.abspath(__file__)) test_config_path = os.path.join(thisfolder, '/home/pi/test_configuration.ini') assert os.path.exists(test_config_path)Load from that absolute path:
Config = configparser.ConfigParser() Config.read(test_config_path)My Read / Write functions:
# Read the Configuration File
def readConfig(section, key):
Config = loadConfiguration()
return Config.get(section, key)
# Write to the Configuration File
def writeConfig(section, key, value):
Config = loadConfiguration()
Config.set(section, key, str(value))
with open(raindeck_config_path, "w") as configfile:
Config.write(configfile)
return ConfigThe error I'm receivingException in thread Thread-5:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/home/pi/test_minion.py", line 821, in begin
runSequence(zone_id)
File "/home/pi/test_minion.py", line 418, in runSequence
outputMIDI("Water", program_water_name, zone_id)
File "/home/pi/test_minion.py", line 295, in outputMIDI
solenoids_zone_2 = int(readConfig("Program", "program_total_solenoids_zone_2"))
File "/home/pi/test_minion.py", line 189, in readConfig
Config = loadConfiguration()
File "/home/pi/test_minion.py", line 129, in loadConfiguration
Config_ServerName = Config.get("Server", "Server_Name")
File "/usr/lib/python3.7/configparser.py", line 780, in get
d = self._unify_values(section, vars)
File "/usr/lib/python3.7/configparser.py", line 1146, in _unify_values
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'Server'I am using threads throughout this script and the script is killed and restarted at the end.Thank you
