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


Python config.items方法代码示例

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


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

示例1: __init__

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import items [as 别名]
def __init__(self, libjars_in_hdfs=None, input_format=None):
        libjars_in_hdfs = libjars_in_hdfs or []
        config = configuration.get_config()
        streaming_jar = config.get('hadoop', 'streaming-jar', '/tmp/hadoop-streaming.jar')

        if config.has_section('job-conf'):
            job_confs = dict(config.items('job-conf'))
        else:
            job_confs = {}

        super(MapReduceJobRunner, self).__init__(
            streaming_jar,
            input_format=input_format,
            libjars_in_hdfs=libjars_in_hdfs,
            jobconfs=job_confs,
        ) 
开发者ID:edx,项目名称:edx-analytics-pipeline,代码行数:18,代码来源:mapreduce.py

示例2: create_config

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import items [as 别名]
def create_config(parser):
    options = parse_arguments(parser)

    # 1) read the default config at "~/.pyepm"
    config = c.read_config()

    # 2) read config from file
    cfg_fn = getattr(options, 'config')
    if cfg_fn:
        if not os.path.exists(cfg_fn):
            c.read_config(cfg_fn)  # creates default
        config.read(cfg_fn)

    # 3) apply cmd line options to config
    for section in config.sections():
        for a, v in config.items(section):
            if getattr(options, a, None) is not None:
                config.set(section, a, getattr(options, a))

    # set config_dir
    config_dir.set(config.get('misc', 'config_dir'))

    return config 
开发者ID:etherex,项目名称:pyepm,代码行数:25,代码来源:pyepm.py

示例3: get_oneview_config

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import items [as 别名]
def get_oneview_config():
    return dict(get_config().items('oneview_config')) 
开发者ID:HewlettPackard,项目名称:oneview-redfish-toolkit,代码行数:4,代码来源:config.py

示例4: get_oneview_multiple_ips

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import items [as 别名]
def get_oneview_multiple_ips():
    ips_config = dict(get_config().items('oneview_config'))['ip'].split(",")
    list_ips = [ip.strip() for ip in ips_config]
    return list_ips 
开发者ID:HewlettPackard,项目名称:oneview-redfish-toolkit,代码行数:6,代码来源:config.py

示例5: get_credentials

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import items [as 别名]
def get_credentials():
    return dict(get_config().items('credentials')) 
开发者ID:HewlettPackard,项目名称:oneview-redfish-toolkit,代码行数:4,代码来源:config.py

示例6: get_cherrypy_config

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import items [as 别名]
def get_cherrypy_config():
    cherrypy_config = dict(get_config().items('cherrypy_config'))

    for key, val in cherrypy_config.items():
        if val.isdigit() or (val.startswith('-') and val[1:].isdigit()):
            cherrypy_config[key] = int(val)

    return cherrypy_config 
开发者ID:HewlettPackard,项目名称:oneview-redfish-toolkit,代码行数:10,代码来源:config.py

示例7: get_composition_settings

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import items [as 别名]
def get_composition_settings():
    return dict(get_config().items('redfish-composition')) 
开发者ID:HewlettPackard,项目名称:oneview-redfish-toolkit,代码行数:4,代码来源:config.py

示例8: parse_monitoring_args

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import items [as 别名]
def parse_monitoring_args(self, args_str, args, sm_args, _rev_tags_dict, base_obj):
        config = ConfigParser.SafeConfigParser()
        config.read([args.config_file])
        try:
            if dict(config.items("MONITORING")).keys():
                # Handle parsing for monitoring
                monitoring_args = self.parse_args(args_str, "MONITORING")
                if monitoring_args:
                    self._smgr_log.log(self._smgr_log.DEBUG, "Monitoring arguments read from config.")
                    self.monitoring_args = monitoring_args
                else:
                    self._smgr_log.log(self._smgr_log.DEBUG, "No monitoring configuration set.")
            else:
                self._smgr_log.log(self._smgr_log.DEBUG, "No monitoring configuration set.")
        except ConfigParser.NoSectionError:
            self._smgr_log.log(self._smgr_log.DEBUG, "No monitoring configuration set.")
        if self.monitoring_args:
            try:
                if self.monitoring_args.monitoring_plugin:
                    module_components = str(self.monitoring_args.monitoring_plugin).split('.')
                    monitoring_module = __import__(str(module_components[0]))
                    monitoring_class = getattr(monitoring_module, module_components[1])
                    if sm_args.collectors:
                        self.server_monitoring_obj = monitoring_class(1, self.monitoring_args.monitoring_frequency,
                                                                      sm_args.listen_ip_addr,
                                                                      sm_args.listen_port, sm_args.collectors,
                                                                      sm_args.http_introspect_port, _rev_tags_dict)
                        self.monitoring_config_set = True
                else:
                    self._smgr_log.log(self._smgr_log.ERROR,
                                       "Analytics IP and Monitoring API misconfigured, monitoring aborted")
                    self.server_monitoring_obj = base_obj
            except ImportError as ie:
                self._smgr_log.log(self._smgr_log.ERROR,
                                   "Configured modules are missing. Server Manager will quit now.")
                self._smgr_log.log(self._smgr_log.ERROR, "Error: " + str(ie))
                raise ImportError
        else:
            self.server_monitoring_obj = base_obj
        return self.server_monitoring_obj 
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:42,代码来源:server_mgr_mon_base_plugin.py

示例9: parse_inventory_args

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import items [as 别名]
def parse_inventory_args(self, args_str, args, sm_args, _rev_tags_dict, base_obj):
        config = ConfigParser.SafeConfigParser()
        config.read([args.config_file])
        try:
            if dict(config.items("INVENTORY")).keys():
                # Handle parsing for monitoring
                inventory_args = self.parse_args(args_str, "INVENTORY")
                if inventory_args:
                    self._smgr_log.log(self._smgr_log.DEBUG, "Inventory arguments read from config.")
                    self.inventory_args = inventory_args
                else:
                    self._smgr_log.log(self._smgr_log.DEBUG, "No inventory configuration set.")
            else:
                self._smgr_log.log(self._smgr_log.DEBUG, "No inventory configuration set.")
        except ConfigParser.NoSectionError:
            self._smgr_log.log(self._smgr_log.DEBUG, "No inventory configuration set.")

        if self.inventory_args:
            try:
                if self.inventory_args.inventory_plugin:
                    module_components = str(self.inventory_args.inventory_plugin).split('.')
                    inventory_module = __import__(str(module_components[0]))
                    inventory_class = getattr(inventory_module, module_components[1])
                    if sm_args.collectors:
                        self.server_inventory_obj = inventory_class(sm_args.listen_ip_addr, sm_args.listen_port,
                                                                    sm_args.http_introspect_port, _rev_tags_dict)
                        self.inventory_config_set = True
                else:
                    self._smgr_log.log(self._smgr_log.ERROR,
                                       "Iventory API misconfigured, inventory aborted")
                    self.server_inventory_obj = base_obj
            except ImportError:
                self._smgr_log.log(self._smgr_log.ERROR,
                                   "Configured modules are missing. Server Manager will quit now.")
                raise ImportError
        else:
            self.server_inventory_obj = base_obj
        return self.server_inventory_obj 
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:40,代码来源:server_mgr_mon_base_plugin.py

示例10: get_config

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import items [as 别名]
def get_config(service_conf, section=''):
    config = ConfigParser.ConfigParser()
    config.read(service_conf)

    conf_items = dict(config.items('common')) if config.has_section('common') else {}
    if section and config.has_section(section):
       conf_items.update(config.items(section))
    return conf_items 
开发者ID:zhixingchou,项目名称:Adminset_Zabbix,代码行数:10,代码来源:util.py

示例11: write_file

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import items [as 别名]
def write_file(name,para):
    with open('/var/lib/cobbler/kickstarts/%s'%name,'a+') as f:
        for k,v in para.items():
	    if k == "swap":
		line = "part %s --size=%s\n"%(k,v)
	    else:
                line = "part %s --fstype ext4 --size=%s\n"%(k,v)
            f.write(line)
	    addline = "%pre\n$SNIPPET('log_ks_pre')\n$SNIPPET('kickstart_start')\n$SNIPPET('pre_install_network_config')\n$SNIPPET('pre_anamon')\n%post\n%end\n"
	f.write(addline) 
开发者ID:zhixingchou,项目名称:Adminset_Zabbix,代码行数:12,代码来源:util.py

示例12: parse_args

# 需要导入模块: from logging import config [as 别名]
# 或者: from logging.config import items [as 别名]
def parse_args(self, args_str, section):
        # Source any specified config/ini file
        # Turn off help, so we print all options in response to -h
        conf_parser = argparse.ArgumentParser(add_help=False)

        conf_parser.add_argument(
            "-c", "--config_file",
            help="Specify config file with the parameter values.",
            metavar="FILE")
        args, remaining_argv = conf_parser.parse_known_args(args_str)

        if args.config_file:
            config_file = args.config_file
        else:
            config_file = _DEF_SMGR_CFG_FILE
        config = ConfigParser.SafeConfigParser()
        config.read([config_file])
        parser = argparse.ArgumentParser(
            # Inherit options from config_parser
            # parents=[conf_parser],
            # print script description with -h/--help
            description=__doc__,
            # Don't mess with format of description
            formatter_class=argparse.RawDescriptionHelpFormatter,
        )
        if section == "MONITORING":
            for key in dict(config.items("MONITORING")).keys():
                if key in self.MonitoringCfg.keys():
                    self.MonitoringCfg[key] = dict(config.items("MONITORING"))[key]
                else:
                    self._smgr_log.log(self._smgr_log.DEBUG, "Configuration set for invalid parameter: %s" % key)
            self._smgr_log.log(self._smgr_log.DEBUG,
                               "Arguments read from monitoring config file %s" % self.MonitoringCfg)
            parser.set_defaults(**self.MonitoringCfg)
        elif section == "INVENTORY":
            for key in dict(config.items("INVENTORY")).keys():
                if key in self.InventoryCfg.keys():
                    self.InventoryCfg[key] = dict(config.items("INVENTORY"))[key]
                else:
                    self._smgr_log.log(self._smgr_log.DEBUG, "Configuration set for invalid parameter: %s" % key)
            self._smgr_log.log(self._smgr_log.DEBUG,
                               "Arguments read from inventory config file %s" % self.InventoryCfg)
            parser.set_defaults(**self.InventoryCfg)
        return parser.parse_args(remaining_argv) 
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:46,代码来源:server_mgr_mon_base_plugin.py


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