diff src/sat.sh @ 930:cbf4122baae7

core, memory: use XDG recommended paths as the defaults for the config and local directories
author souliane <souliane@mailoo.org>
date Sun, 23 Mar 2014 22:43:43 +0100
parents 952322b1d490
children 3b30e9f83d88
line wrap: on
line diff
--- a/src/sat.sh	Mon Mar 24 15:18:53 2014 +0100
+++ b/src/sat.sh	Sun Mar 23 22:43:43 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':'~/.sat',
-									'pid_dir':'/tmp',
-									'log_dir':'%(local_dir)s'})
+config = SafeConfigParser(defaults=Const.DEFAULT_CONFIG)
 try:
-	config.read(map(expanduser, ['/etc/sat.conf', '~/sat.conf', '~/.sat.conf', 'sat.conf', '.sat.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}oy"
 TAP_PATH="./"