示例#1
0
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
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
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
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
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
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
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)