本文整理汇总了Python中aeneas.logger.Logger.write方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.write方法的具体用法?Python Logger.write怎么用?Python Logger.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aeneas.logger.Logger
的用法示例。
在下文中一共展示了Logger.write方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AbstractCLIProgram
# 需要导入模块: from aeneas.logger import Logger [as 别名]
# 或者: from aeneas.logger.Logger import write [as 别名]
#.........这里部分代码省略.........
# set log file path, if requested
log_path = None
for flag in [u"-l", u"--log"]:
log_path = self.has_option_with_value(flag, actual_arguments=False)
if log_path is not None:
args.remove("%s=%s" % (flag, log_path))
elif flag in set_args:
handler, log_path = gf.tmp_file(suffix=u".log", root=self.rconf[RuntimeConfiguration.TMP_PATH])
args.remove(flag)
if log_path is not None:
self.log_file_path = log_path
# if no actual arguments left, print help
if (len(args) < 1) and (show_help):
return self.print_help(short=True)
# store actual arguments
self.actual_arguments = args
# create logger
self.logger = Logger(tee=self.verbose, tee_show_datetime=self.very_verbose)
self.log([u"Formal arguments: %s", self.formal_arguments])
self.log([u"Actual arguments: %s", self.actual_arguments])
self.log([u"Runtime configuration: '%s'", self.rconf.config_string()])
# perform command
exit_code = self.perform_command()
self.log([u"Execution completed with code %d", exit_code])
# output log if requested
if self.log_file_path is not None:
self.log([u"User requested saving log to file '%s'", self.log_file_path])
self.logger.write(self.log_file_path)
if self.use_sys:
self.print_info(u"Log written to file '%s'" % self.log_file_path)
return self.exit(exit_code)
def has_option(self, target):
"""
Return ``True`` if the actual arguments include
the specified ``target`` option or,
if ``target`` is a list of options,
at least one of them.
:param target: the option or a list of options
:type target: Unicode string or list of Unicode strings
:rtype: bool
"""
if isinstance(target, list):
target_set = set(target)
else:
target_set = set([target])
return len(target_set & set(self.actual_arguments)) > 0
def has_option_with_value(self, prefix, actual_arguments=True):
"""
Check if the actual arguments include an option
starting with the given ``prefix`` and having a value,
e.g. ``--format=ogg`` for ``prefix="--format"``.
:param prefix: the option prefix
:type prefix: Unicode string
:param actual_arguments: if ``True``, check among actual arguments;
otherwise check among formal arguments