cwconfig.py
branch3.5
changeset 3115 29262ba01464
parent 3059 1be8bf42bc5d
child 3118 9e7a155bc4e5
equal deleted inserted replaced
3103:1d09765ee720 3115:29262ba01464
    18 import os
    18 import os
    19 import logging
    19 import logging
    20 from smtplib import SMTP
    20 from smtplib import SMTP
    21 from threading import Lock
    21 from threading import Lock
    22 from os.path import exists, join, expanduser, abspath, normpath, basename, isdir
    22 from os.path import exists, join, expanduser, abspath, normpath, basename, isdir
       
    23 import tempfile
    23 
    24 
    24 from logilab.common.decorators import cached
    25 from logilab.common.decorators import cached
    25 from logilab.common.deprecation import deprecated
    26 from logilab.common.deprecation import deprecated
    26 from logilab.common.logging_ext import set_log_methods, init_log
    27 from logilab.common.logging_ext import set_log_methods, init_log
    27 from logilab.common.configuration import (Configuration, Method,
    28 from logilab.common.configuration import (Configuration, Method,
   524 
   525 
   525     INSTANCE_DATA_DIR = None
   526     INSTANCE_DATA_DIR = None
   526     if CubicWebNoAppConfiguration.mode == 'test':
   527     if CubicWebNoAppConfiguration.mode == 'test':
   527         root = os.environ['APYCOT_ROOT']
   528         root = os.environ['APYCOT_ROOT']
   528         REGISTRY_DIR = '%s/etc/cubicweb.d/' % root
   529         REGISTRY_DIR = '%s/etc/cubicweb.d/' % root
   529         RUNTIME_DIR = '/tmp/'
   530         RUNTIME_DIR = tempfile.gettempdir()
   530         MIGRATION_DIR = '%s/local/share/cubicweb/migration/' % root
   531         MIGRATION_DIR = '%s/local/share/cubicweb/migration/' % root
   531         if not exists(REGISTRY_DIR):
   532         if not exists(REGISTRY_DIR):
   532             os.makedirs(REGISTRY_DIR)
   533             os.makedirs(REGISTRY_DIR)
   533     elif CubicWebNoAppConfiguration.mode == 'dev':
   534     elif CubicWebNoAppConfiguration.mode == 'dev':
   534         REGISTRY_DIR = expanduser('~/etc/cubicweb.d/')
   535         REGISTRY_DIR = expanduser('~/etc/cubicweb.d/')
   535         RUNTIME_DIR = '/tmp/'
   536         RUNTIME_DIR = tempfile.gettempdir()
   536         MIGRATION_DIR = join(CW_SOFTWARE_ROOT, 'misc', 'migration')
   537         MIGRATION_DIR = join(CW_SOFTWARE_ROOT, 'misc', 'migration')
   537     else: #mode = 'installed'
   538     else: #mode = 'installed'
   538         REGISTRY_DIR = '/etc/cubicweb.d/'
   539         REGISTRY_DIR = '/etc/cubicweb.d/'
   539         INSTANCE_DATA_DIR = '/var/lib/cubicweb/instances/'
   540         INSTANCE_DATA_DIR = '/var/lib/cubicweb/instances/'
   540         RUNTIME_DIR = '/var/run/cubicweb/'
   541         RUNTIME_DIR = '/var/run/cubicweb/'
   649         return self.appid
   650         return self.appid
   650 
   651 
   651     def default_log_file(self):
   652     def default_log_file(self):
   652         """return default path to the log file of the instance'server"""
   653         """return default path to the log file of the instance'server"""
   653         if self.mode == 'dev':
   654         if self.mode == 'dev':
   654             basepath = '/tmp/%s-%s' % (basename(self.appid), self.name)
   655             basepath = join(tempfile.gettempdir(), '%s-%s' % (basename(self.appid), self.name))
   655             path = basepath + '.log'
   656             path = basepath + '.log'
   656             i = 1
   657             i = 1
   657             while exists(path) and i < 100: # arbitrary limit to avoid infinite loop
   658             while exists(path) and i < 100: # arbitrary limit to avoid infinite loop
   658                 try:
   659                 try:
   659                     file(path, 'a')
   660                     file(path, 'a')