コード例 #1
0
ファイル: replica_db.py プロジェクト: painter1/replication
def __get_config(section, key):
    try:
        return metaconfig.get_config('replication').get(section, key)
    except:
        log.error("Cannot find %s in section %s", key, section,exc_info=True)
        #jfp was log.error("Cannot find %s in section %s", key, section,exec_inf=True)
        raise
コード例 #2
0
# See the LICENSE file in the source distribution of this software for
# the full license text.


from drslib.cmip5 import make_translator
from drslib import p_cmip5
from drslib import drs_tree
import gen_drs

import os, shutil
import metaconfig
import tempfile

LISTING = 'multi_product.ls'

config = metaconfig.get_config('drslib')
shelve_dir = config.get('p_cmip5', 'shelve-dir')
drs_root = '/cmip5'
vtrans = make_translator(drs_root)

def setup_module():
    global p_cmip5, listing, tmpdir, dt

    tmpdir = tempfile.mkdtemp(prefix='drs_tree-product-')

    print 'TMPDIR  ',tmpdir
    shelves = p_cmip5.init._find_shelves(shelve_dir)

    config_file = os.path.join(os.path.dirname(__file__), 'ukmo_sample.ini')
    listing = os.path.join(os.path.dirname(__file__), LISTING)
    gen_drs.write_listing(tmpdir, listing)
コード例 #3
0
ファイル: harvest_cmip5.py プロジェクト: painter1/replication
import time, datetime
import logging

from replication.model import p2p

logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__) 

Base = declarative_base()

##WORK AROUNDS---
# Set _database to "postgres", "mysql", or "sqllite" to avoid reading the config file twice
_database = None
if _database is None:
    import metaconfig
    _conf = metaconfig.get_config('cmip5_status')
    _dburl = _conf.get('db','dburl')
    _database = _dburl.split('://')[0]

# For Postgres:
if _database.startswith("postgres"):
    try:
        from sqlalchemy.dialects.postgresql import BIGINT as MyBigInteger
    except:
        from sqlalchemy.databases.postgres import PGBigInteger as MyBigInteger
# For MySQL:
elif _database=="mysql":
    from sqlalchemy.databases.mysql import MSBigInteger as MyBigInteger, MSDouble as MyDouble
# For SQLlite:
elif _database=="sqllite":
    MyBigInteger = types.Integer
コード例 #4
0
ファイル: replica_db.py プロジェクト: painter1/replication
files_dir1 = replica_root1                               # on gdo2: /css01-cmip5/scratch
files_dir2 = replica_root2                               # on gdo2: /css02-cmip5/scratch

def __get_config(section, key):
    try:
        return metaconfig.get_config('replication').get(section, key)
    except:
        log.error("Cannot find %s in section %s", key, section,exc_info=True)
        #jfp was log.error("Cannot find %s in section %s", key, section,exec_inf=True)
        raise

##WORK AROUNDS---
# Set _database to "postgres", "mysql", or "sqllite" to avoid reading the config file twice
_database = "postgres"
if _database is None:
    _conf = metaconfig.get_config('replication')
    _dburl = _conf.get('db','dburl')
    _database = __get_config('db', 'dburl').split('://')[0]

# For Postgres:
if _database=="postgres" or _database=="postgresql":
    try:
        from sqlalchemy.dialects.postgresql import BIGINT as MyBigInteger
        _database = "postgresql"
    except:
        from sqlalchemy.databases.postgres import PGBigInteger as MyBigInteger
# For MySQL:
elif _database=="mysql":
    from sqlalchemy.databases.mysql import MSBigInteger as MyBigInteger, MSDouble as MyDouble
# For SQLlite:
elif _database=="sqllite":
コード例 #5
0
ファイル: test_global.py プロジェクト: cedadev/metaconfig
def test_1():
    config = get_config('p1')
    assert config.get('foo', 'a') == '42'