# HG changeset patch # User souliane # Date 1395612323 -3600 # Node ID 2bd609d7dd6565bf515d4e9924eabf9dabef989d # Parent e9bc7854bce6da7d1bbdf20907ec3f5317f7e61a server_side: use XDG recommended paths as the defaults diff -r e9bc7854bce6 -r 2bd609d7dd65 libervia_server/__init__.py --- a/libervia_server/__init__.py Mon Mar 24 17:12:14 2014 +0100 +++ b/libervia_server/__init__.py Sun Mar 23 23:05:23 2014 +0100 @@ -1044,8 +1044,8 @@ 'radiocolStarted', 'radiocolPreload', 'radiocolPlay', 'radiocolNoUpload', 'radiocolUploadOk', 'radiocolSongRejected', 'radiocolPlayers', 'roomLeft', 'roomUserChangedNick', 'chatStateReceived']: self.bridge.register(signal_name, self.signal_handler.getGenericCb(signal_name), "plugin") - self.media_dir = self.bridge.getConfig('','media_dir') - self.local_dir = self.bridge.getConfig('','local_dir') + self.media_dir = self.bridge.getConfig('', 'media_dir') + self.local_dir = self.bridge.getConfig('', 'local_dir') root.putChild('', Redirect('libervia.html')) root.putChild('json_signal_api', self.signal_handler) root.putChild('json_api', MethodHandler(self)) diff -r e9bc7854bce6 -r 2bd609d7dd65 libervia_server/libervia.sh --- a/libervia_server/libervia.sh Mon Mar 24 17:12:14 2014 +0100 +++ b/libervia_server/libervia.sh Sun Mar 23 23:05:23 2014 +0100 @@ -19,31 +19,29 @@ #We use python to parse config files eval `"$PYTHON" << PYTHONEND +from sat.core.constants import Const from ConfigParser import SafeConfigParser from os.path import expanduser, join import sys -config = SafeConfigParser(defaults={'local_dir':'~/.libervia', - 'pid_dir':'/tmp', - 'log_dir':'%(local_dir)s'}) +config = SafeConfigParser(defaults=Const.DEFAULT_CONFIG) try: - config.read(map(expanduser, ['/etc/libervia.conf', '~/libervia.conf', '~/.libervia.conf', 'libervia.conf', '.libervia.conf'])) + config.read(Const.CONFIG_FILES) except: print ("echo \"/!\\ Can't read main config ! Please check the syntax\";") print ("exit 1") sys.exit() env=[] -env.append("LOCAL_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'local_dir')),'')) env.append("PID_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),'')) -env.append("LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),'')) +env.append("LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'log_dir')),'')) print ";".join(env) PYTHONEND ` PID_FILE="$PID_DIR$NAME.pid" -LOG_FILE="$LOCAL_DIR$NAME.log" +LOG_FILE="$LOG_DIR$NAME.log" DAEMON="n" MAIN_OPTIONS="-${DAEMON}o" diff -r e9bc7854bce6 -r 2bd609d7dd65 twisted/plugins/libervia.py --- a/twisted/plugins/libervia.py Mon Mar 24 17:12:14 2014 +0100 +++ b/twisted/plugins/libervia.py Sun Mar 23 23:05:23 2014 +0100 @@ -25,8 +25,7 @@ from xdg.BaseDirectory import save_config_path from ConfigParser import SafeConfigParser, NoSectionError, NoOptionError -from os.path import expanduser - +from sat.core.constants import Const try: from libervia_server import Libervia opt_params = Libervia.OPT_PARAMETERS @@ -70,6 +69,6 @@ config_path = save_config_path('sat') config = SafeConfigParser() -config.read(map(expanduser, ['/etc/sat.conf', config_path + '/sat.conf', 'sat.conf', '.sat.conf'])) +config.read(Const.CONFIG_FILES) serviceMaker = LiberviaMaker()