本文整理汇总了Python中aeneas.validator.Validator.check_contents_txt_config_file方法的典型用法代码示例。如果您正苦于以下问题:Python Validator.check_contents_txt_config_file方法的具体用法?Python Validator.check_contents_txt_config_file怎么用?Python Validator.check_contents_txt_config_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aeneas.validator.Validator
的用法示例。
在下文中一共展示了Validator.check_contents_txt_config_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from aeneas.validator import Validator [as 别名]
# 或者: from aeneas.validator.Validator import check_contents_txt_config_file [as 别名]
def main():
""" Entry point """
if len(sys.argv) < 3:
usage()
return
validator = Validator()
mode = sys.argv[1]
result = None
msg = ""
if mode == "config":
if sys.argv[2].endswith(".txt"):
try:
config_file = open(sys.argv[2], "r")
config_contents = config_file.read()
config_file.close()
result = validator.check_contents_txt_config_file(config_contents, True)
msg = "TXT configuration"
except:
print "[ERRO] Unable to read file %s" % sys.argv[2]
elif sys.argv[2].endswith(".xml"):
try:
config_file = open(sys.argv[2], "r")
config_contents = config_file.read()
config_file.close()
result = validator.check_contents_xml_config_file(config_contents)
msg = "XML configuration"
except:
print "[ERRO] Unable to read file %s" % sys.argv[2]
else:
usage()
return
elif mode == "container":
result = validator.check_container(sys.argv[2])
msg = "container"
elif mode == "job":
result = validator.check_job_configuration(sys.argv[2])
msg = "job configuration string"
elif mode == "task":
result = validator.check_task_configuration(sys.argv[2])
msg = "task configuration string"
elif mode == "wizard":
if len(sys.argv) < 4:
usage()
return
result = validator.check_container_from_wizard(sys.argv[2], sys.argv[3])
msg = "container + configuration string from wizard"
else:
usage()
return
if result.passed:
print "[INFO] Valid %s" % msg
if len(result.warnings) > 0:
for warning in result.warnings:
print "[WARN] " + warning
else:
print "[INFO] Invalid %s" % msg
for error in result.errors:
print "[ERRO] " + error