本文整理汇总了Python中aquilon.config.Config.has_section方法的典型用法代码示例。如果您正苦于以下问题:Python Config.has_section方法的具体用法?Python Config.has_section怎么用?Python Config.has_section使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aquilon.config.Config
的用法示例。
在下文中一共展示了Config.has_section方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: discover_network_types
# 需要导入模块: from aquilon.config import Config [as 别名]
# 或者: from aquilon.config.Config import has_section [as 别名]
def discover_network_types(dbapi_con, connection_record): # pylint: disable=W0613
config = Config()
if not config.has_option("broker", "default_network_type"): # pragma: no cover
raise InternalError("The default_network_type option is missing from "
"the [broker] section in the configuration.")
default_type = config.get("broker", "default_network_type")
default_section = "network_" + default_type
if not config.has_section(default_section): # pragma: no cover
raise InternalError("The default network type is %s, but there's no "
"section named [%s] in the configuration." %
(default_type, default_section))
nettypes = {}
# This function should be called only once, but you never know...
if Network.network_type_map:
return
for section in config.sections():
if not section.startswith("network_"):
continue
name = section[8:]
nettypes[name] = NetworkProperties(config, name)
LOGGER.info("Configured network type %s", name)
Network.network_type_map = nettypes
Network.default_network_props = nettypes[default_type]
示例2: and
# 需要导入模块: from aquilon.config import Config [as 别名]
# 或者: from aquilon.config.Config import has_section [as 别名]
opts = parser.parse_args()
if not os.path.exists(opts.config):
print >> sys.stderr, "configfile %s does not exist" % opts.config
sys.exit(1)
if os.environ.get("AQDCONF") and (os.path.realpath(opts.config)
!= os.path.realpath(os.environ["AQDCONF"])):
force_yes("""Will ignore AQDCONF variable value:
%s
and use
%s
instead.""" % (os.environ["AQDCONF"], opts.config))
config = Config(configfile=opts.config)
if not config.has_section("unittest"):
config.add_section("unittest")
if not config.has_option("unittest", "srcdir"):
config.set("unittest", "srcdir", SRCDIR)
if opts.coverage:
config.set("unittest", "coverage", "True")
if opts.profile:
config.set("unittest", "profile", "True")
hostname = config.get("unittest", "hostname")
if hostname.find(".") < 0:
print >> sys.stderr, """
Some regression tests depend on the config value for hostname to be
fully qualified. Please set the config value manually since the default
on this system (%s) is a short name.
""" % hostname