diff src/sat.sh @ 1003:52ec79aa5bbe

memory: fixes the method fixLocalDir for pid_dir and log_dir to use local_dir as default
author souliane <souliane@mailoo.org>
date Wed, 30 Apr 2014 19:54:21 +0200
parents 3b30e9f83d88
children 7293233970ab
line wrap: on
line diff
--- a/src/sat.sh	Wed Apr 30 16:34:09 2014 +0200
+++ b/src/sat.sh	Wed Apr 30 19:54:21 2014 +0200
@@ -1,8 +1,6 @@
 #!/bin/sh
 
 DEBUG=""
-NAME="sat"
-FULL_NAME="Salut à Toi"
 PYTHON="python2"
 
 kill_process() {
@@ -23,14 +21,17 @@
 
 #We use python to parse config files
 eval `"$PYTHON" << PYTHONEND
-from sat.core.constants import Const
+from sat.core.constants import Const as C
+from sat.memory.memory import fixLocalDir
 from ConfigParser import SafeConfigParser
 from os.path import expanduser, join
 import sys
 
-config = SafeConfigParser(defaults=Const.DEFAULT_CONFIG)
+fixLocalDir()  # XXX: tmp update code, will be removed in the future
+
+config = SafeConfigParser(defaults=C.DEFAULT_CONFIG)
 try:
-    config.read(Const.CONFIG_FILES)
+    config.read(C.CONFIG_FILES)
 except:
     print ("echo \"/!\\ Can't read main config ! Please check the syntax\";")
     print ("exit 1")
@@ -40,21 +41,22 @@
 env.append("PID_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),''))
 env.append("LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'log_dir')),''))
 
+env.append("APP_NAME_FILE='%s'" % C.APP_NAME_FILE)
 print ";".join(env)
 PYTHONEND
 `
-
-PID_FILE="$PID_DIR$NAME.pid"
-LOG_FILE="$LOG_DIR$NAME.log"
+APP_NAME="Salut à Toi"  # FIXME: the import from Python constants fails because of the à
+PID_FILE="$PID_DIR$APP_NAME_FILE.pid"
+LOG_FILE="$LOG_DIR$APP_NAME_FILE.log"
 
 # if there is one argument which is "stop", then we kill SàT
 if [ $# -eq 1 ];then
     if [ $1 = "stop" ];then
-        kill_process $PID_FILE "$FULL_NAME"
+        kill_process $PID_FILE "$APP_NAME"
         exit 0
     fi
     if [ $1 = "debug" ];then
-        echo "Launching $FULL_NAME in debug mode"
+        echo "Launching $APP_NAME in debug mode"
         DEBUG="--debug"
     fi
 fi
@@ -62,7 +64,7 @@
 DAEMON="n"
 MAIN_OPTIONS="-${DAEMON}oy"
 TAP_PATH="./"
-TAP_FILE="$NAME.tac"
+TAP_FILE="$APP_NAME_FILE.tac"
 
 #Don't change the next line
 AUTO_OPTIONS=""