Commit f7caa461 authored by Daniel Gerhardt's avatar Daniel Gerhardt

Fix reading of config property on first line

If arsnova.properties did not start with comments and had a property on
the first line it was ignored.
parent ac439b5f
......@@ -17,7 +17,7 @@ class ConfigReader:
f.close()
config = ConfigParser.RawConfigParser()
config.readfp(io.BytesIO("[arsnova]" + properties))
config.readfp(io.BytesIO("[arsnova]\n" + properties))
self.host = config.get("arsnova", "couchdb.host")
self.port = config.get("arsnova", "couchdb.port")
self.dbName = config.get("arsnova", "couchdb.name")
......
  • Have to revert this change in order to use the tool.py on arsnova.thm.de.

    With this change in, i'll get the following:

    Traceback (most recent call last):
      File "tool.py", line 63, in <module>
        (db, conn) = couchconnection.arsnova_connection("/etc/arsnova/arsnova.properties")
      File "/root/arsnova-setuptool/couchconnection.py", line 60, in arsnova_connection
        config = configreader.ConfigReader(propertypath)
      File "/root/arsnova-setuptool/configreader.py", line 7, in __init__
        self.readProperties(propertiesFile)
      File "/root/arsnova-setuptool/configreader.py", line 20, in readProperties
        config.readfp(io.BytesIO("[arsnova]\n" + properties))
      File "/usr/lib/python2.7/ConfigParser.py", line 324, in readfp
        self._read(fp, filename)
      File "/usr/lib/python2.7/ConfigParser.py", line 546, in _read
        raise e
    ConfigParser.ParsingError: File contains parsing errors: <???>
    	[line  2]: 'q################################################################################\n'
  • It looks to me like it is just a coincidence that reverting this change fixes the problem.

    The real problem here is that the config file is invalid:

    [line 2]: 'q################################################################################\n'

    Edited by Daniel Gerhardt
  • well... I could have figured that out.

    Interesting tho as to why the revert fixed it.

    Anyway, thank you and sorry

  • No problem. Without the commit, the parser would read [arsnova]q###... and just ignore anything behind the closing brace. So the problem would also occur after a revert if you add an empty line to the beginning of the config file yourself.

    Edited by Daniel Gerhardt
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment