def _setFakeConfig(self, custom): """ Sets a fake configuration for the current process, using a temporary directory """ config = Config.getInstance() test_config = TestConfig.getInstance() temp = tempfile.mkdtemp(prefix="indico_") self._info('Using %s as temporary dir' % temp) os.mkdir(os.path.join(temp, 'log')) os.mkdir(os.path.join(temp, 'archive')) indicoDist = pkg_resources.get_distribution('indico') htdocsDir = indicoDist.get_resource_filename('indico', 'indico/htdocs') etcDir = indicoDist.get_resource_filename('indico', 'etc') # minimal defaults defaults = { 'BaseURL': 'http://localhost:8000/indico', 'BaseSecureURL': '', 'UseXSendFile': False, 'AuthenticatorList': ['Local'], 'SmtpServer': ('localhost', 58025), 'SmtpUseTLS': 'no', 'DBConnectionParams': ('localhost', TestConfig.getInstance().getFakeDBPort()), 'LogDir': os.path.join(temp, 'log'), 'XMLCacheDir': os.path.join(temp, 'cache'), 'HtdocsDir': htdocsDir, 'ArchiveDir': os.path.join(temp, 'archive'), 'UploadedFilesTempDir': os.path.join(temp, 'tmp'), 'ConfigurationDir': etcDir } defaults.update(custom) # set defaults config.reset(defaults) Config.setInstance(config) self._cfg = config # re-configure logging and template generator, so that paths are updated from MaKaC.common import TemplateExec from MaKaC.common.logger import Logger TemplateExec.mako = TemplateExec._define_lookup() Logger.reset()
def _setFakeConfig(self, custom): """ Sets a fake configuration for the current process, using a temporary directory """ config = Config.getInstance() temp = tempfile.mkdtemp(prefix="indico_") self._info('Using %s as temporary dir' % temp) os.mkdir(os.path.join(temp, 'log')) os.mkdir(os.path.join(temp, 'archive')) indicoDist = pkg_resources.get_distribution('indico') htdocsDir = indicoDist.get_resource_filename('indico', 'indico/htdocs') etcDir = indicoDist.get_resource_filename('indico', 'etc') # minimal defaults defaults = { 'Debug': True, 'BaseURL': 'http://localhost:8000', 'BaseSecureURL': '', 'AuthenticatorList': [('Local', {})], 'SmtpServer': ('localhost', 58025), 'SmtpUseTLS': 'no', 'DBConnectionParams': ('127.0.0.1', TestConfig.getInstance().getFakeDBPort()), 'LogDir': os.path.join(temp, 'log'), 'XMLCacheDir': os.path.join(temp, 'cache'), 'HtdocsDir': htdocsDir, 'ArchiveDir': os.path.join(temp, 'archive'), 'UploadedFilesTempDir': os.path.join(temp, 'tmp'), 'ConfigurationDir': etcDir } defaults.update(custom) # set defaults config.reset(defaults) Config.setInstance(config) self._cfg = config # Update assets environment core_env.directory = core_env.directory.replace('/opt/indico/htdocs', config.getHtdocsDir()) core_env.load_path = [path.replace('/opt/indico/htdocs', config.getHtdocsDir()) for path in core_env.load_path] core_env.url_mapping = {path.replace('/opt/indico/htdocs', config.getHtdocsDir()): url for path, url in core_env.url_mapping.iteritems()} core_env.config['PYSCSS_LOAD_PATHS'] = [x.replace('/opt/indico/htdocs', config.getHtdocsDir()) for x in core_env.config['PYSCSS_LOAD_PATHS']] # re-configure logging and template generator, so that paths are updated from MaKaC.common import TemplateExec from MaKaC.common.logger import Logger TemplateExec.mako = TemplateExec._define_lookup() Logger.reset()
def _setFakeConfig(self, custom): """ Sets a fake configuration for the current process, using a temporary directory """ config = Config.getInstance() temp = tempfile.mkdtemp(prefix="indico_") self._info('Using %s as temporary dir' % temp) os.mkdir(os.path.join(temp, 'log')) os.mkdir(os.path.join(temp, 'archive')) indicoDist = pkg_resources.get_distribution('indico') htdocsDir = indicoDist.get_resource_filename('indico', 'indico/htdocs') etcDir = indicoDist.get_resource_filename('indico', 'etc') # minimal defaults defaults = { 'Debug': True, 'BaseURL': 'http://localhost:8000', 'BaseSecureURL': '', 'AuthenticatorList': [('Local', {})], 'SmtpServer': ('localhost', 58025), 'SmtpUseTLS': 'no', 'DBConnectionParams': ('127.0.0.1', TestConfig.getInstance().getFakeDBPort()), 'LogDir': os.path.join(temp, 'log'), 'XMLCacheDir': os.path.join(temp, 'cache'), 'HtdocsDir': htdocsDir, 'ArchiveDir': os.path.join(temp, 'archive'), 'UploadedFilesTempDir': os.path.join(temp, 'tmp'), 'ConfigurationDir': etcDir } defaults.update(custom) # set defaults config.reset(defaults) Config.setInstance(config) self._cfg = config # Update assets environment core_env.directory = core_env.directory.replace( '/opt/indico/htdocs', config.getHtdocsDir()) core_env.load_path = [ path.replace('/opt/indico/htdocs', config.getHtdocsDir()) for path in core_env.load_path ] core_env.url_mapping = { path.replace('/opt/indico/htdocs', config.getHtdocsDir()): url for path, url in core_env.url_mapping.iteritems() } core_env.config['PYSCSS_LOAD_PATHS'] = [ x.replace('/opt/indico/htdocs', config.getHtdocsDir()) for x in core_env.config['PYSCSS_LOAD_PATHS'] ] # re-configure logging and template generator, so that paths are updated from MaKaC.common import TemplateExec from MaKaC.common.logger import Logger TemplateExec.mako = TemplateExec._define_lookup() Logger.reset()