コード例 #1
0
ファイル: etl_core.py プロジェクト: YauHsien/some_ETL
def list_config(cusid, tech, key, mod_name):
    path = wic.find_config_file_path()
    logger(__name__).info('show "{}"'.format(path))
    json_data = File.load_JSON(path, mod_name)
    for k in json_data:
        if File.is_path(json_data[k]):
            if not File.exists(json_data[k]):
                logger(__name__).warning('bad path: "{}"'.format(
                    str(json_data[k])))
    return JSON.to_yaml(json_data, key)
コード例 #2
0
ファイル: etl_core.py プロジェクト: YauHsien/some_ETL
def get_config(cusid, tech, mod_name):
    path = wic.find_config_file_path()
    #logger(__name__).debug(path)
    try:
        return File.load_JSON(path, mod_name)
    except:
        return {
            RESTRICT.CONFIG_PATH: pathlib.Path(Default.CONFIG_PATH),
            RESTRICT.CONFIG_FOLDER: Default.CONFIG_FOLDER,
            RESTRICT.DATA_PATH: pathlib.Path(Default.DATA_PATH)
        }
コード例 #3
0
ファイル: ds_core.py プロジェクト: YauHsien/some_ETL
def set_config(cusid, tech, key, value, mod_name):
    path = wic.find_DS_config_file_path()
    json_data = File.load_JSON(path, mod_name)
    if key is not None and key.upper() in json_data:
        key1 = key.upper()
        if key1 == 'PORT':
            try:
                json_data[key1] = int(value)
                File.dump_JSON(path, json_data, mod_name)
            except Exception as e:
                logger(__name__).warning('bad value "{}": {} {}'.format(
                    value, type(e), e))
        else:
            json_data[key1] = value
            File.dump_JSON(path, json_data, mod_name)
コード例 #4
0
ファイル: etl_core.py プロジェクト: YauHsien/some_ETL
def set_config(cusid, tech, key, value, mod_name):
    if key is not None:
        path = wic.find_config_file_path()
        json_data = File.load_JSON(path, mod_name)
        key1 = key.upper()
        if key1 in json_data:
            if key1.endswith('_PATH'):
                logger(__name__).info('varifying path "{}"...'.format(value))
                try:
                    pathlib.Path(value).resolve()
                    json_data[key1] = value
                except Exception as e:
                    logger(__name__).warning('bad path: {} {}'.format(
                        type(e), e))
            else:
                json_data[key1] = value
            File.dump_JSON(path, json_data, mod_name)
コード例 #5
0
ファイル: db_core.py プロジェクト: YauHsien/some_ETL
def set_config(cusid, tech, key, value, mod_name):
    path = wic.find_DB_config_file_path()
    json_data = File.load_JSON(path, mod_name)
    if key is not None:
        m = re.match('(\w+)[.](\w+)', key)
        if m is None:
            key1 = key.upper()
            if key1 in json_data and type(json_data[key1]) is not dict:
                json_data[key1] = value
                File.dump_JSON(path, json_data, mod_name)
        else:
            key1, key2 = m.group(1).upper(), m.group(2).upper()
            if key1 in json_data and key2 in json_data[key1]:
                if key2 == 'TABLE' and key1 in ['PM', 'CM', 'DC']:
                    logger(__name__).warning(
                        '{}.TABLE: fixed to any table ("*")'.format(key1))
                    json_data[key1][key2] = '*'
                elif key2 == 'PORT':
                    json_data[key1][key2] = int(value)
                else:
                    json_data[key1][key2] = value
                File.dump_JSON(path, json_data, mod_name)
コード例 #6
0
ファイル: ds_core.py プロジェクト: YauHsien/some_ETL
def list_config(cusid, tech, key, mod_name):
    path = wic.find_DS_config_file_path()
    logger(__name__).info('show "{}"'.format(path))
    json_data = File.load_JSON(path, mod_name)
    return JSON.to_yaml(json_data, key)
コード例 #7
0
ファイル: ds_core.py プロジェクト: YauHsien/some_ETL
def get_config(cusid, tech, mod_name):
    path = wic.find_DS_config_file_path()
    try:
        return File.load_JSON(path, mod_name)
    except:  # if system is not initialized
        return customer.get_defaultDS_config_all(cusid, tech)