2012-10-13 09:29:48 +00:00
|
|
|
# coding: utf-8
|
|
|
|
|
2013-07-15 12:37:51 +00:00
|
|
|
import os, sys, tempfile, ConfigParser
|
|
|
|
|
|
|
|
config = ConfigParser.RawConfigParser({ 'cache_dir': os.path.join(tempfile.gettempdir(), 'supysonic') })
|
2012-10-13 09:29:48 +00:00
|
|
|
|
|
|
|
def check():
|
2013-07-15 12:37:51 +00:00
|
|
|
try:
|
|
|
|
ret = config.read([ '/etc/supysonic', os.path.expanduser('~/.supysonic') ])
|
|
|
|
except (ConfigParser.MissingSectionHeaderError, ConfigParser.ParsingError), e:
|
|
|
|
print >>sys.stderr, "Error while parsing the configuration file(s):\n%s" % str(e)
|
|
|
|
return False
|
|
|
|
|
|
|
|
if not ret:
|
|
|
|
print >>sys.stderr, "No configuration file found"
|
|
|
|
return False
|
|
|
|
|
|
|
|
try:
|
|
|
|
config.get('base', 'database_uri')
|
|
|
|
except:
|
|
|
|
print >>sys.stderr, "No database URI set"
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
def get(section, name):
|
|
|
|
try:
|
|
|
|
return config.get(section, name)
|
|
|
|
except:
|
|
|
|
return None
|
|
|
|
|