changeset 417:2bd609d7dd65

server_side: use XDG recommended paths as the defaults
author souliane <souliane@mailoo.org>
date Sun, 23 Mar 2014 23:05:23 +0100
parents e9bc7854bce6
children ec8775575886
files libervia_server/__init__.py libervia_server/libervia.sh twisted/plugins/libervia.py
diffstat 3 files changed, 9 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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))
--- 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"
 
--- 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()