sumnerboy12 / mqtt-gpio-monitor

Python script for sending/receiving commands to/from GPIO pins via MQTT messages
46 stars 23 forks source link

Cert_Path Errors #26

Closed NoBloodyABCorD closed 6 years ago

NoBloodyABCorD commented 6 years ago

Bit of a python n00b so I'm sure this is pretty simple, but I don't see this in the Readme so figured I'd ask.

I've copied your example .ini file and made changes, i'm working in a test enviroment first so I don't have any security while I get things figured out to see if a Pi will do what I need. So I have left the TLS and CERT_PATH options commented out in the .ini file. However the script seems to still be looking for them when I run it?

Traceback (most recent call last): File "mqtt-gpio-monitor.py", line 37, in <module> MQTT_CERT_PATH = config.get("global", "mqtt_cert_path") File "/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", line 803, in get raise NoOptionError(option, section) backports.configparser.NoOptionError: No option 'mqtt_cert_path' in section: 'global'

Same with Python3

Traceback (most recent call last): File "/usr/lib/python3.5/configparser.py", line 786, in get value = d[option] File "/usr/lib/python3.5/collections/__init__.py", line 881, in __getitem__ return self.__missing__(key) # support subclasses that define __missing__ File "/usr/lib/python3.5/collections/__init__.py", line 873, in __missing__ raise KeyError(key) KeyError: 'mqtt_cert_path'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "mqtt-gpio-monitor.py", line 37, in <module> MQTT_CERT_PATH = config.get("global", "mqtt_cert_path") File "/usr/lib/python3.5/configparser.py", line 789, in get raise NoOptionError(option, section) configparser.NoOptionError: No option 'mqtt_cert_path' in section: 'global'

sumnerboy12 commented 6 years ago

Apologies, TLS support was added recently by another contributor but since I no longer use this script I haven't tested it since the changes. I have just pushed some changes which should make things a bit clearer. The quick fix is to add those config options with no value to your INI, but I have also updated the config parser to use fallback values if none are explicitly specified.