Subversion Repositories HomeAutomation

Rev

Blame | Last modification | View Log | SVN | RSS feed

  1.  
  2. import os
  3.  
  4. Settings = {}
  5.  
  6. def FindConfig():
  7.     filename = "/etc/atom.conf"
  8.  
  9.     if os.path.exists(filename):
  10.         return filename
  11.  
  12.     filename = "./atom.conf"
  13.  
  14.     if os.path.exists(filename):
  15.         return filename
  16.  
  17.     print "No config file found"
  18.     return False
  19.  
  20. def LoadSettings():
  21.     filename = FindConfig()
  22.  
  23.     if filename != False:
  24.         settingsFile = open(filename, 'r')
  25.         lines = settingsFile.readlines()
  26.         settingsFile.close()
  27.    
  28.         for line in lines:
  29.             line = line.strip("\n").strip(" ")
  30.             if len(line) > 0:
  31.                 if line[0] != '#':
  32.                     settingName = line[:line.find("=")]
  33.                     settingValue = line[line.find("=")+1:]
  34.  
  35.                     Settings[settingName] = settingValue
  36.  
  37.         print "Loaded settings from " + filename
  38.  
  39.     print ""
  40.