本文整理汇总了Python中cylc.suite_logging.LOG.exception方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.exception方法的具体用法?Python LOG.exception怎么用?Python LOG.exception使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cylc.suite_logging.LOG
的用法示例。
在下文中一共展示了LOG.exception方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _run_command_init
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import exception [as 别名]
def _run_command_init(cls, ctx, callback=None, callback_args=None):
"""Prepare and launch shell command in ctx."""
try:
if ctx.cmd_kwargs.get('stdin_file_paths'):
if len(ctx.cmd_kwargs['stdin_file_paths']) > 1:
stdin_file = TemporaryFile()
for file_path in ctx.cmd_kwargs['stdin_file_paths']:
stdin_file.write(open(file_path, 'rb').read())
stdin_file.seek(0)
else:
stdin_file = open(
ctx.cmd_kwargs['stdin_file_paths'][0], 'rb')
elif ctx.cmd_kwargs.get('stdin_str'):
stdin_file = TemporaryFile()
stdin_file.write(ctx.cmd_kwargs.get('stdin_str'))
stdin_file.seek(0)
else:
stdin_file = open(os.devnull)
proc = Popen(
ctx.cmd, stdin=stdin_file, stdout=PIPE, stderr=PIPE,
# Execute command as a process group leader,
# so we can use "os.killpg" to kill the whole group.
preexec_fn=os.setpgrp,
env=ctx.cmd_kwargs.get('env'),
shell=ctx.cmd_kwargs.get('shell'))
except (IOError, OSError) as exc:
if exc.filename is None:
exc.filename = ctx.cmd[0]
LOG.exception(exc)
ctx.ret_code = 1
ctx.err = str(exc)
cls._run_command_exit(ctx, callback, callback_args)
return None
else:
LOG.debug(ctx.cmd)
return proc