当前位置: 首页>>代码示例>>Python>>正文


Python config.get方法代码示例

本文整理汇总了Python中config.get方法的典型用法代码示例。如果您正苦于以下问题:Python config.get方法的具体用法?Python config.get怎么用?Python config.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在config的用法示例。


在下文中一共展示了config.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: response

# 需要导入模块: import config [as 别名]
# 或者: from config import get [as 别名]
def response(req, resp=None, code=None, message=None):
	level = "INFO"
	if code is None:
		# rsp needs to be set otherwise
		code = resp.status
	if message is None:
		message=resp.reason
	if code > 399:
		if  code < 500:
			level = "WARN"
		else:
			level = "ERROR"
	
	log_level = config.get("log_level")
	if log_level == "INFO" or (log_level == "WARN" and level != "INFO") or (log_level == "ERROR" and level == "ERROR"):
		print("{} RSP> <{}> ({}): {}".format(level, code, message, req.path)) 
开发者ID:HDFGroup,项目名称:hsds,代码行数:18,代码来源:hsds_logger.py

示例2: getEndpoints

# 需要导入模块: import config [as 别名]
# 或者: from config import get [as 别名]
def getEndpoints():
    docker_machine_ip = config.get("docker_machine_ip")
    req = "{}/nodestate/sn".format(config.get("head_endpoint")) 
    client = globals["client"]
    globals["request_count"] += 1
    async with client.get(req) as rsp:
        if rsp.status == 200:
            rsp_json = await rsp.json()
    nodes = rsp_json["nodes"]
    sn_endpoints = []
    docker_links = checkDockerLink()
    for node in nodes:
        if not node["host"]:
            continue
        if docker_links:
            # when running in docker, use the machine address as host
            host = "hsds_sn_{}".format(node["node_number"])
        elif docker_machine_ip:
            host = docker_machine_ip
        else:
            host = node["host"]
        url = "http://{}:{}".format(host, node["port"])
        sn_endpoints.append(url)
    log.info("{} endpoints".format(len(sn_endpoints)))
    globals["sn_endpoints"] = sn_endpoints 
开发者ID:HDFGroup,项目名称:hsds,代码行数:27,代码来源:import_ghcn_file.py

示例3: import_file

# 需要导入模块: import config [as 别名]
# 或者: from config import get [as 别名]
def import_file(filename):
    log.info("import_file: {}".format(filename))
    loop = globals["loop"]
    max_concurrent_tasks = config.get("max_concurrent_tasks")
    tasks = []
    with open(filename, 'r') as fh:
        for line in fh:
            line = line.rstrip()
            #loop.run_until_complete(import_line(line))
            tasks.append(asyncio.ensure_future(import_line(line)))
            if len(tasks) < max_concurrent_tasks:
                continue  # get next line
            # got a batch, move them out!
            loop.run_until_complete(asyncio.gather(*tasks))
            tasks = []
    # finish any remaining tasks
    loop.run_until_complete(asyncio.gather(*tasks))
    globals["files_read"] += 1 
开发者ID:HDFGroup,项目名称:hsds,代码行数:20,代码来源:import_ghcn_file.py

示例4: testInvalidFillValue

# 需要导入模块: import config [as 别名]
# 或者: from config import get [as 别名]
def testInvalidFillValue(self):
        # test Dataset with simple type and fill value that is incompatible with the type
        domain = self.base_domain + "/testInvalidFillValue.h5"
        helper.setupDomain(domain)
        print("testInvalidFillValue", domain)
        headers = helper.getRequestHeaders(domain=domain)

        # get domain
        req = helper.getEndpoint() + '/'
        rsp = requests.get(req, headers=headers)
        rspJson = json.loads(rsp.text)
        self.assertTrue("root" in rspJson)

        fill_value = 'XXXX'  # can't convert to int!
        # create the dataset
        req = self.endpoint + "/datasets"
        payload = {'type': 'H5T_STD_I32LE', 'shape': 10}
        payload['creationProperties'] = {'fillValue': fill_value }
        req = self.endpoint + "/datasets"
        rsp = requests.post(req, data=json.dumps(payload), headers=headers)
        self.assertEqual(rsp.status_code, 400)  # invalid param 
开发者ID:HDFGroup,项目名称:hsds,代码行数:23,代码来源:dataset_test.py

示例5: setupDomain

# 需要导入模块: import config [as 别名]
# 或者: from config import get [as 别名]
def setupDomain(domain, folder=False):
    endpoint = config.get("hsds_endpoint")
    headers = getRequestHeaders(domain=domain)
    req = endpoint + "/"
    rsp = requests.get(req, headers=headers)
    if rsp.status_code == 200:
        return  # already have domain
    if rsp.status_code != 404:
        # something other than "not found"
        raise ValueError(f"Unexpected get domain error: {rsp.status_code}")
    parent_domain = getParentDomain(domain)
    if parent_domain is None:
        raise ValueError(f"Invalid parent domain: {domain}")
    # create parent domain if needed
    setupDomain(parent_domain, folder=True)

    headers = getRequestHeaders(domain=domain)
    body=None
    if folder:
        body = {"folder": True}
        rsp = requests.put(req, data=json.dumps(body), headers=headers)
    else:
        rsp = requests.put(req, headers=headers)
    if rsp.status_code != 201:
        raise ValueError(f"Unexpected put domain error: {rsp.status_code}") 
开发者ID:HDFGroup,项目名称:hsds,代码行数:27,代码来源:helper.py

示例6: testBaseDomain

# 需要导入模块: import config [as 别名]
# 或者: from config import get [as 别名]
def testBaseDomain(self):
        # make a non-folder domain
        print("testBaseDomain", self.base_domain)
        headers = helper.getRequestHeaders(domain=self.base_domain)

        req = helper.getEndpoint() + '/'
        rsp = requests.get(req, headers=headers)
        self.assertEqual(rsp.status_code, 200)
        self.assertEqual(rsp.headers['content-type'], 'application/json; charset=utf-8')
        rspJson = json.loads(rsp.text)

        # verify that passing domain as query string works as well
        del headers["X-Hdf-domain"]
        req += "?host=" + self.base_domain
        rsp = requests.get(req, headers=headers)
        self.assertEqual(rsp.status_code, 200)
        self.assertEqual(rsp.headers['content-type'], 'application/json; charset=utf-8')

        # try using DNS-style domain name
        domain = helper.getDNSDomain(self.base_domain)
        params = { "host": domain }
        rsp = requests.get(req, params=params, headers=headers)
        self.assertEqual(rsp.status_code, 200)
        self.assertEqual(rsp.headers['content-type'], 'application/json; charset=utf-8') 
开发者ID:HDFGroup,项目名称:hsds,代码行数:26,代码来源:domain_test.py

示例7: testGetTopLevelDomain

# 需要导入模块: import config [as 别名]
# 或者: from config import get [as 别名]
def testGetTopLevelDomain(self):
        domain = "/home"
        print("testGetTopLevelDomain", domain)
        headers = helper.getRequestHeaders(domain=domain)

        req = helper.getEndpoint() + '/'
        rsp = requests.get(req, headers=headers)
        self.assertEqual(rsp.status_code, 200)
        rspJson = json.loads(rsp.text)
        self.assertFalse("root" in rspJson)  # no root group for folder domain
        self.assertTrue("owner" in rspJson)
        self.assertTrue("hrefs" in rspJson)
        self.assertTrue("class" in rspJson)
        self.assertEqual(rspJson["class"], "folder")
        domain = "test_user1.home"
        headers = helper.getRequestHeaders(domain=domain)

        req = helper.getEndpoint() + '/'
        rsp = requests.get(req, headers=headers)
        self.assertEqual(rsp.status_code, 200) 
开发者ID:HDFGroup,项目名称:hsds,代码行数:22,代码来源:domain_test.py

示例8: setupDomain

# 需要导入模块: import config [as 别名]
# 或者: from config import get [as 别名]
def setupDomain(domain):
    endpoint = config.get("hsds_endpoint")
    print("setupdomain: ", domain)
    headers = getRequestHeaders(domain=domain)
    req = endpoint + "/"
    rsp = requests.get(req, headers=headers)
    if rsp.status_code == 200:
        return  # already have domain
    if rsp.status_code != 404:
        # something other than "not found"
        raise ValueError("Unexpected get domain error: {}".format(rsp.status_code))

    parent_domain = getParentDomain(domain)
    if parent_domain is None:
        raise ValueError("Invalid parent domain: {}".format(domain))
    # create parent domain if needed
    setupDomain(parent_domain)  
     
    headers = getRequestHeaders(domain=domain)
    rsp = requests.put(req, headers=headers)
    if rsp.status_code != 201:
        raise ValueError("Unexpected put domain error: {}".format(rsp.status_code)) 
开发者ID:HDFGroup,项目名称:hsds,代码行数:24,代码来源:helper.py

示例9: getRequestHeaders

# 需要导入模块: import config [as 别名]
# 或者: from config import get [as 别名]
def getRequestHeaders(domain=None, username=None, password=None):
    if username is None:
        username = config.get("user_name")
    if password is None:
        password = config.get("user_password")
    headers = { }
    if domain is not None:
        headers['host'] = domain
    if username and password:
        auth_string = username + ':' + password
        auth_string = auth_string.encode('utf-8')
        auth_string = base64.b64encode(auth_string)
        auth_string = auth_string.decode('utf-8')
        auth_string = "Basic " + auth_string
        headers['Authorization'] = auth_string
    return headers 
开发者ID:HDFGroup,项目名称:hsds,代码行数:18,代码来源:helper.py

示例10: testReadHyperslab

# 需要导入模块: import config [as 别名]
# 或者: from config import get [as 别名]
def testReadHyperslab(self):

        dset_id = config.get("dset111_id")
        print("dset_id:", dset_id)

        # these are the properties of the /g1/g1.1/dset1.1.1. dataset in tall.h5
        dset_json = {"id": dset_id}
        dset_json["root"] = getRootObjId(dset_id)
        dset_json["type"] = {"class": "H5T_INTEGER", "base": "H5T_STD_I32BE"}
        dset_json["shape"] = {"class": "H5S_SIMPLE", "dims": [10, 10], "maxdims": [10, 10]}
        dset_json["layout"] = {"class": "H5D_CHUNKED", "dims": [10, 10]}

        chunk_id = 'c' + dset_id[1:] + "_0_0"

        params = {}
        params["dset_json"] = dset_json
        params["chunk_id"] = chunk_id
        params["bucket"] = config.get("bucket")
        loop = asyncio.get_event_loop()
        app = get_app(loop=loop)
         
        loop.run_until_complete(self.read_hyperslab_test(app, params))

        loop.close() 
开发者ID:HDFGroup,项目名称:hsds,代码行数:26,代码来源:readHyperslabTest.py

示例11: testReadPoints

# 需要导入模块: import config [as 别名]
# 或者: from config import get [as 别名]
def testReadPoints(self):

        dset_id = config.get("dset111_id")
        print("dset_id:", dset_id)

        # these are the properties of the /g1/g1.1/dset1.1.1. dataset in tall.h5
        dset_json = {"id": dset_id}
        dset_json["root"] = getRootObjId(dset_id)
        dset_json["type"] = {"class": "H5T_INTEGER", "base": "H5T_STD_I32BE"}
        dset_json["shape"] = {"class": "H5S_SIMPLE", "dims": [10, 10], "maxdims": [10, 10]}
        dset_json["layout"] = {"class": "H5D_CHUNKED", "dims": [10, 10]}

        chunk_id = 'c' + dset_id[1:] + "_0_0"

        params = {}
        params["dset_json"] = dset_json
        params["chunk_id"] = chunk_id
        params["bucket"] = config.get("bucket")
        loop = asyncio.get_event_loop()
        app = get_app(loop=loop)
        loop.run_until_complete(self.read_points_test(app, params))

        loop.close() 
开发者ID:HDFGroup,项目名称:hsds,代码行数:25,代码来源:readPointsTest.py

示例12: load_module_menus

# 需要导入模块: import config [as 别名]
# 或者: from config import get [as 别名]
def load_module_menus(self):
        global module_menus
        module_menus = {}
        #config.load()
        modules = config.get(['modules'], None)
        for module in modules:
            values = modules[module]
            if module != "launcher" and config.get(["modules", module, "auto_start"], 0) != 1:
                continue

            #version = values["current_version"]
            menu_path = os.path.join(root_path, module, "web_ui", "menu.json")
            if not os.path.isfile(menu_path):
                continue
                
            module_menu = json.load(file(menu_path, 'r'))          
            module_menus[module] = module_menu

        module_menus = sorted(module_menus.iteritems(), key=lambda (k,v): (v['menu_sort_id']))
        #for k,v in self.module_menus:
        #    logging.debug("m:%s id:%d", k, v['menu_sort_id']) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:23,代码来源:web_control.py

示例13: load_config

# 需要导入模块: import config [as 别名]
# 或者: from config import get [as 别名]
def load_config(self, config):
        if self._alert_configs is None:
            self._alert_configs = {}
        if self._log_configs is None:
            self._log_configs = []
        if self._rules is None:
            self._rules = []
        if self._regexes is None:
            self._regexes = {}
        if self._tests is None:
            self._tests = {}

        self._name = config.get("name",self._name)
        self._version = config.get("version",self._version)

        self._alert_configs.update(config.get("alert configs",[]))
        self._log_configs.extend(config.get("log configs",[]))

        self._regexes.update(config.get("regexes",{}))
        self._rules.extend(config.get("regex_rules",[]))

        self._tests.update(config.get("tests",{})) 
开发者ID:salesforce,项目名称:Providence,代码行数:24,代码来源:__init__.py

示例14: _if_rule

# 需要导入模块: import config [as 别名]
# 或者: from config import get [as 别名]
def _if_rule(self, data, rule, alert_callback):
        if_conditions = rule.get("if")
        then_rules = rule.get("then")
        else_rules = rule.get("else")

        if data is None or if_conditions is None:
            return

        if_condition_met = True
        for if_condition in if_conditions:
            if_condition = self._regexes.get(if_condition, if_condition)
            ignorecase = re.compile(if_condition, re.IGNORECASE | re.MULTILINE | re.DOTALL)
            if ignorecase.search(data) is None:
                if_condition_met = False
                break

        if if_condition_met:
            if then_rules is not None:
                for then_rule in then_rules:
                    self._process(data, then_rule, alert_callback)
        else:
            if else_rules is not None:
                for else_rule in else_rules:
                    self._process(data, else_rule, alert_callback) 
开发者ID:salesforce,项目名称:Providence,代码行数:26,代码来源:__init__.py

示例15: load_config

# 需要导入模块: import config [as 别名]
# 或者: from config import get [as 别名]
def load_config(self, config):
        if self._alert_configs is None:
            self._alert_configs = []
        if self._log_configs is None:
            self._log_configs = []
        if self._rules is None:
            self._rules = []
        if self._tests is None:
            self._tests = {}

        self._alert_configs += config.get("alert configs",[])
        self._log_configs += config.get("log configs",[])
        self._rules += config.get("regex_rules",[]) 
        self._tests.update(config.get("tests",{}))
        self._name = config.get("name",self._name)
        self._version = config.get("version",self._version) 
开发者ID:salesforce,项目名称:Providence,代码行数:18,代码来源:regexruleengine.py


注:本文中的config.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。