本文整理汇总了Python中ConfigParser.ConfigParser._sections["slash2"]["timeout"]方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigParser._sections["slash2"]["timeout"]方法的具体用法?Python ConfigParser._sections["slash2"]["timeout"]怎么用?Python ConfigParser._sections["slash2"]["timeout"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigParser.ConfigParser
的用法示例。
在下文中一共展示了ConfigParser._sections["slash2"]["timeout"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import _sections["slash2"]["timeout"] [as 别名]
#.........这里部分代码省略.........
except ImportError:
logging.basicConfig(level=level,
format=fmtstr,
datefmt='%H:%M'
)
#Setup file log
if args.log_file:
fch = logging.FileHandler(args.log_file)
fch.setLevel(level)
fch.setFormatter(
logging.Formatter("%(asctime)s [%(levelname)s] %(message)s")
)
log.addHandler(fch)
#Check for config file
conf = ConfigParser()
if len(conf.read(args.config_file)) == 0:
log.fatal("Unable to read configuration file!")
sys.exit(1)
#Required sections; check for their existence
sections = {
"tsuite": [
"rootdir",
"logbase"
],
"slash2": [
"conf",
"mds_gdb", "ion_gdb", "mnt_gdb"
],
"tests": [
"tsetdir",
"excluded"
],
"mongo": [
"host"
]
}
#Building from source or svn
if args.source == "svn":
sections["svn"] = [
"svnroot"
]
else:
sections["source"] = [
"srcroot"
]
#Apply configuration overrides
if args.overrides:
overreg = re.compile(r"^(\w+):(\w+)=(.+?)$")
for override in args.overrides:
match = overreg.match(override)
if match:
section, key, value = match.groups()
if section not in conf._sections or key not in conf._sections[section]:
print "Override {0} does not override an existing config value!".format(override)
sys.exit(1)
conf._sections[section][key] = value
#Check that the required sections exist
missing = check_subset(list(sections), list(conf._sections))
if len(missing) != 0:
log.fatal("Configuration file is missing sections!")
log.fatal("Missing: {}".format(", ".join(missing)))
sys.exit(1)
#Check that all the fields listed are present
#in each section
for section in sections:
missing = check_subset(
sections[section],
conf._sections[section]
)
if len(missing) != 0:
log.fatal("Missing fields in {} section!".format(section))
log.fatal("Missing: {}".format(", ".join(missing)))
sys.exit(1)
if "timeout" not in conf._sections["slash2"]:
conf._sections["slash2"]["timeout"] = None
log.info("Configuration file loaded successfully!")
tsetdir = conf._sections["tests"]["tsetdir"]
tsets = []
try:
#Consider all directories in tset_dir to have tsets to be ran
tsets = [tset for tset in os.listdir(tsetdir) \
if os.path.isdir(os.path.join(tsetdir, tset)) and not tset.startswith(".")]
except OSError, e:
log.critical("Unable to gather tset sets from the tseting directory!")
sys.exit(1)