#1251878: Cubicweb no longer crash for missing instance and data dir at create.
Those directory should be created by cubicweb now.
We may want to issue a warning if they are missing.
--- a/cwconfig.py Wed Oct 13 11:00:22 2010 +0200
+++ b/cwconfig.py Wed Oct 13 18:54:59 2010 +0200
@@ -151,7 +151,7 @@
from cubicweb import (CW_SOFTWARE_ROOT, CW_MIGRATION_MAP,
ConfigurationError, Binary)
-from cubicweb.toolsutils import env_path, create_dir
+from cubicweb.toolsutils import create_dir
CONFIGURATIONS = []
@@ -304,7 +304,7 @@
mode = _forced_mode or 'system'
_CUBES_DIR = join(_INSTALL_PREFIX, 'share', 'cubicweb', 'cubes')
- CUBES_DIR = env_path('CW_CUBES_DIR', _CUBES_DIR, 'cubes', checkexists=False)
+ CUBES_DIR = abspath(os.environ.get('CW_CUBES_DIR', _CUBES_DIR))
CUBES_PATH = os.environ.get('CW_CUBES_PATH', '').split(os.pathsep)
options = (
@@ -835,7 +835,7 @@
@classmethod
def instances_dir(cls):
"""return the control directory"""
- return env_path('CW_INSTANCES_DIR', cls._INSTANCES_DIR, 'registry')
+ return abspath(os.environ.get('CW_INSTANCES_DIR', cls._INSTANCES_DIR))
@classmethod
def migration_scripts_dir(cls):
@@ -919,8 +919,7 @@
default = tempfile.gettempdir()
# runtime directory created on startup if necessary, don't check it
# exists
- rtdir = env_path('CW_RUNTIME_DIR', default, 'run time',
- checkexists=False)
+ rtdir = abspath(os.environ.get('CW_RUNTIME_DIR', default))
return join(rtdir, '%s-%s.pid' % (self.appid, self.name))
# instance methods used to get instance specific resources #############
@@ -949,7 +948,7 @@
iddir = '/var/lib/cubicweb/instances/'
else:
iddir = self.instances_dir()
- iddir = env_path('CW_INSTANCES_DATA_DIR', iddir, 'additional data')
+ iddir = abspath(os.environ.get('CW_INSTANCES_DATA_DIR', iddir))
return join(iddir, self.appid)
def init_cubes(self, cubes):
--- a/toolsutils.py Wed Oct 13 11:00:22 2010 +0200
+++ b/toolsutils.py Wed Oct 13 18:54:59 2010 +0200
@@ -194,30 +194,6 @@
config_file, ex)
return config
-def env_path(env_var, default, name, checkexists=True):
- """get a path specified in a variable or using the default value and return
- it.
-
- :type env_var: str
- :param env_var: name of an environment variable
-
- :type default: str
- :param default: default value if the environment variable is not defined
-
- :type name: str
- :param name: the informal name of the path, used for error message
-
- :rtype: str
- :return: the value of the environment variable or the default value
-
- :raise `ConfigurationError`: if the returned path does not exist
- """
- path = environ.get(env_var, default)
- if checkexists and not exists(path):
- raise ConfigurationError('%s directory %s doesn\'t exist' % (name, path))
- return abspath(path)
-
-
_HDLRS = {}