本文整理汇总了Python中aeneas.validator.Validator.check_container_from_wizard方法的典型用法代码示例。如果您正苦于以下问题:Python Validator.check_container_from_wizard方法的具体用法?Python Validator.check_container_from_wizard怎么用?Python Validator.check_container_from_wizard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aeneas.validator.Validator
的用法示例。
在下文中一共展示了Validator.check_container_from_wizard方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from aeneas.validator import Validator [as 别名]
# 或者: from aeneas.validator.Validator import check_container_from_wizard [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
示例2: load_job_from_container
# 需要导入模块: from aeneas.validator import Validator [as 别名]
# 或者: from aeneas.validator.Validator import check_container_from_wizard [as 别名]
def load_job_from_container(self, container_path, config_string=None):
"""
Validate the given container, and, if it is well formed,
load the job from it.
If ``config_string`` is ``None``,
the container must contain a configuration file;
otherwise use the provided config string
(i.e., the wizard case).
Return ``True`` if the job has been loaded successfully,
``False`` otherwise.
:param container_path: the path to the input container
:type container_path: string (path)
:param config_string: the configuration string (from wizard)
:type config_string: string
:rtype: bool
"""
self._log("Loading job from container...")
# validate container
self._log("Validating container...")
validator = Validator(logger=self.logger)
if config_string == None:
validator_result = validator.check_container(container_path)
else:
validator_result = validator.check_container_from_wizard(
container_path,
config_string
)
if not validator_result.passed:
self._log("Validating container: failed")
self._log("Loading job from container: failed")
return False
self._log("Validating container: succeeded")
try:
# create working directory where the input container
# will be decompressed
self.working_directory = tempfile.mkdtemp(dir=gf.custom_tmp_dir())
self._log("Created working directory '%s'" % self.working_directory)
# decompress
self._log("Decompressing input container...")
input_container = Container(container_path, logger=self.logger)
input_container.decompress(self.working_directory)
self._log("Decompressing input container... done")
# create job from the working directory
self._log("Creating job from working directory...")
working_container = Container(
self.working_directory,
logger=self.logger
)
analyzer = AnalyzeContainer(working_container, logger=self.logger)
if config_string == None:
self.job = analyzer.analyze()
else:
self.job = analyzer.analyze_from_wizard(config_string)
self._log("Creating job from working directory... done")
# set absolute path for text file and audio file
# for each task in the job
self._log("Setting absolute paths for tasks...")
for task in self.job.tasks:
task.text_file_path_absolute = gf.norm_join(
self.working_directory,
task.text_file_path
)
task.audio_file_path_absolute = gf.norm_join(
self.working_directory,
task.audio_file_path
)
self._log("Setting absolute paths for tasks... done")
# return
self._log("Loading job from container: succeeded")
return True
except:
# failure: clean and return
self.clean()
self._log("Loading job from container: failed")
return False