當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。