Permalink
Browse files

ConfigParserified it

  • Loading branch information...
1 parent 50a03cb commit f3f8dc5d759b240f886aa820c101671a58343548 @kylegordon committed Sep 28, 2012
Showing with 13 additions and 7 deletions.
  1. +13 −7 mqtt-republisher.py
View
@@ -13,13 +13,19 @@
import socket
import mosquitto
-
-MQTT_HOST = "10.8.0.1"
-MQTT_PORT = 1883
-MQTT_TOPIC = "/raw/#"
-MAPFILE = "/etc/mqtt-republisher/map.csv"
-LOGFILE = "/var/log/mqtt-republisher.log"
-DEBUG = False
+import ConfigParser
+
+# Read the config file
+config = ConfigParser.RawConfigParser()
+config.read('/etc/mqtt-republisher/mqtt-republisher.cfg')
+
+#Use ConfigParser to pick out the settings
+DEBUG = config.getboolean('global', 'debug')
+LOGFILE = config.get('global', 'logfile')
+MAPFILE = config.get('global', 'mapfile')
+MQTT_HOST = config.get('global', 'mqtt_host')
+MQTT_PORT = config.get('global', 'mqtt_host')
+MQTT_PORT = config.get('global', 'mqtt_host')
client_id = "Republisher_%d" % os.getpid()
mqttc = mosquitto.Mosquitto(client_id)

0 comments on commit f3f8dc5

Please sign in to comment.