diff src/core/constants.py @ 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 eb3601ff73bc
children 191f440d11b4
line wrap: on
line diff
--- a/src/core/constants.py	Wed Apr 30 16:34:09 2014 +0200
+++ b/src/core/constants.py	Wed Apr 30 19:54:21 2014 +0200
@@ -17,7 +17,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import os.path
+from os.path import expanduser, abspath
 try:
     import __pyjamas__  # do not import xdg when building Libervia
     BaseDirectory = None
@@ -30,6 +30,7 @@
     ## Application ##
     APP_NAME = u'Salut à Toi'
     APP_NAME_SHORT = u'SàT'
+    APP_NAME_FILE = u'sat'
     APP_NAME_FULL = u'%s (%s)' % (APP_NAME_SHORT, APP_NAME)
     APP_VERSION = u'0.4.1D'  # Please add 'D' at the end for dev versions
     APP_URL = 'http://salut-a-toi.org'
@@ -54,21 +55,16 @@
 
         ## Configuration ##
         DEFAULT_CONFIG = {
-            'media_dir': '/usr/share/sat/media',
-            'pid_dir': '/tmp',
-            'log_dir': BaseDirectory.save_data_path('sat'),
+            'media_dir': '/usr/share/' + APP_NAME_FILE + '/media',
+            'local_dir': BaseDirectory.save_data_path(APP_NAME_FILE),
+            'pid_dir': '%(local_dir)s',
+            'log_dir': '%(local_dir)s',
         }
 
-        # XXX: tmp update code, will be removed in the future
-        # When you remove this, please add that in DEFAULT_CONFIG:
-        # 'local_dir': BaseDirectory.save_data_path('sat'),
-        # and also remove sat.memory.memory.Memory.__fixLocalDir
-        DEFAULT_LOCAL_DIR = BaseDirectory.save_data_path('sat')
-
         # List of the configuration filenames sorted by ascending priority
-        CONFIG_FILES = [(os.path.expanduser(path) + 'sat.conf') for path in
+        CONFIG_FILES = [abspath(expanduser(path) + APP_NAME_FILE + '.conf') for path in
                         ['/etc/', '~/', '~/.', '', '.'] +
-                        ['%s/' % path for path in list(BaseDirectory.load_config_paths('sat'))]
+                        ['%s/' % path for path in list(BaseDirectory.load_config_paths(APP_NAME_FILE))]
                        ]
 
 
@@ -89,7 +85,7 @@
 
 
     ## Misc ##
-    SAVEFILE_DATABASE = "sat.db"
+    SAVEFILE_DATABASE = APP_NAME_FILE + ".db"
     IQ_SET = '/iq[@type="set"]'
     ENV_PREFIX = 'SAT_' # Prefix used for environment variables