本文整理汇总了Python中cylc.suite_logging.LOG.debug方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.debug方法的具体用法?Python LOG.debug怎么用?Python LOG.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cylc.suite_logging.LOG
的用法示例。
在下文中一共展示了LOG.debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _set_state
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import debug [as 别名]
def _set_state(self, status):
"""Set, log and record task status (normal change, not forced - don't
update task_events table)."""
if self.status == self.hold_swap:
self.hold_swap = None
if status == self.status and self.hold_swap is None:
return
o_status, o_hold_swap = self.status, self.hold_swap
if status == TASK_STATUS_HELD:
self.hold_swap = self.status
elif (self.hold_swap == TASK_STATUS_HELD and
status not in TASK_STATUSES_FINAL):
self.hold_swap = status
status = TASK_STATUS_HELD
elif self.hold_swap:
self.hold_swap = None
self.status = status
self.time_updated = get_current_time_string()
flags.iflag = True
# Log
message = str(o_status)
if o_hold_swap:
message += " (%s)" % o_hold_swap
message += " => %s" % self.status
if self.hold_swap:
message += " (%s)" % self.hold_swap
LOG.debug(message, itask=self.identity)
示例2: poll_task_jobs
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import debug [as 别名]
def poll_task_jobs(self, suite, itasks, poll_succ=True, msg=None):
"""Poll jobs of specified tasks.
Any job that is or was submitted or running can be polled, except for
retrying tasks - which would poll (correctly) as failed. And don't poll
succeeded tasks by default.
This method uses _poll_task_jobs_callback() and
_manip_task_jobs_callback() as help/callback methods.
_poll_task_job_callback() executes one specific job.
"""
to_poll_tasks = []
pollable_statuses = set([
TASK_STATUS_SUBMITTED, TASK_STATUS_RUNNING, TASK_STATUS_FAILED])
if poll_succ:
pollable_statuses.add(TASK_STATUS_SUCCEEDED)
for itask in itasks:
if itask.state.status in pollable_statuses:
to_poll_tasks.append(itask)
else:
LOG.debug("skipping %s: not pollable, "
"or skipping 'succeeded' tasks" % itask.identity)
if to_poll_tasks:
if msg is not None:
LOG.info(msg)
self._run_job_cmd(
self.JOBS_POLL, suite, to_poll_tasks,
self._poll_task_jobs_callback)
示例3: report
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import debug [as 别名]
def report(self, request, server_obj):
"""Log client requests with identifying information.
In debug mode log all requests including task messages. Otherwise log
all user commands, and just the first info request from each client.
"""
if threading.current_thread().__class__.__name__ == '_MainThread':
# Server methods may be called internally as well as by clients.
return
auth_user, prog_name, user, host, uuid, priv_level = get_client_info()
name = server_obj.__class__.__name__
log_me = (
cylc.flags.debug or
name in ["SuiteCommandServer",
"ExtTriggerServer",
"BroadcastServer"] or
(name not in ["SuiteIdServer", "TaskMessageServer"] and
uuid not in self.clients))
if log_me:
LOG.debug(
self.__class__.LOG_CONNECT_ALLOWED_TMPL % (
user, host, prog_name, priv_level, uuid)
)
LOG.info(
self.__class__.LOG_COMMAND_TMPL % (
request, user, host, prog_name, uuid))
if name == "SuiteIdServer":
self._num_id_requests += 1
self.report_id_requests()
self.clients[uuid] = datetime.datetime.utcnow()
self._housekeep()
示例4: _housekeep
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import debug [as 别名]
def _housekeep(self):
"""Forget inactive clients."""
for uuid, client_info in self.clients.copy().items():
if time() - client_info['time'] > self.CLIENT_FORGET_SEC:
try:
del self.clients[uuid]
except KeyError:
pass
LOG.debug(self.LOG_FORGET_TMPL % uuid)
示例5: signout
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import debug [as 别名]
def signout(self):
"""Forget client, where possible."""
uuid = _get_client_info()[4]
try:
del self.clients[uuid]
except KeyError:
return False
else:
LOG.debug(self.LOG_FORGET_TMPL % uuid)
return True
示例6: _housekeep
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import debug [as 别名]
def _housekeep(self):
"""Forget inactive clients."""
for uuid in self.clients.keys():
dtime = self.clients[uuid]
if (self._total_seconds(datetime.datetime.utcnow() - dtime) >
self.__class__.CLIENT_FORGET_SEC):
del self.clients[uuid]
LOG.debug(
self.__class__.LOG_FORGET_TMPL % uuid)
示例7: __init__
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import debug [as 别名]
def __init__(self, pool_size=None):
self.pool_size = (
pool_size or
GLOBAL_CFG.get(["process pool size"]) or
multiprocessing.cpu_count())
# (The Pool class defaults to cpu_count anyway, but does not
# expose the result via its public interface).
LOG.debug(
"Initializing process pool, size %d" % self.pool_size)
self.pool = multiprocessing.Pool(processes=self.pool_size)
self.results = {}
示例8: _housekeep
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import debug [as 别名]
def _housekeep(self):
"""Forget inactive clients."""
for uuid, dtime in self.clients.copy().items():
if (self._total_seconds(datetime.datetime.utcnow() - dtime) >
self.__class__.CLIENT_FORGET_SEC):
try:
del self.clients[uuid]
except KeyError:
pass
LOG.debug(
self.__class__.LOG_FORGET_TMPL % uuid)
示例9: _remote_host_select_callback
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import debug [as 别名]
def _remote_host_select_callback(self, proc_ctx, cmd_str):
"""Callback when host select command exits"""
self.ready = True
if proc_ctx.ret_code == 0 and proc_ctx.out:
# Good status
LOG.debug(proc_ctx)
self.remote_host_str_map[cmd_str] = proc_ctx.out.splitlines()[0]
else:
# Bad status
LOG.error(proc_ctx)
self.remote_host_str_map[cmd_str] = TaskRemoteMgmtError(
TaskRemoteMgmtError.MSG_SELECT, (cmd_str, None), cmd_str,
proc_ctx.ret_code, proc_ctx.out, proc_ctx.err)
示例10: _manip_task_jobs_callback
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import debug [as 别名]
def _manip_task_jobs_callback(
ctx, suite, itasks, summary_callback, more_callbacks=None):
"""Callback when submit/poll/kill tasks command exits."""
if ctx.ret_code:
LOG.error(ctx)
else:
LOG.debug(ctx)
tasks = {}
# Note for "kill": It is possible for a job to trigger its trap and
# report back to the suite back this logic is called. If so, the task
# will no longer be TASK_STATUS_SUBMITTED or TASK_STATUS_RUNNING, and
# its output line will be ignored here.
for itask in itasks:
if itask.point is not None and itask.submit_num:
submit_num = "%02d" % (itask.submit_num)
tasks[(str(itask.point), itask.tdef.name, submit_num)] = itask
handlers = [(BatchSysManager.OUT_PREFIX_SUMMARY, summary_callback)]
if more_callbacks:
for prefix, callback in more_callbacks.items():
handlers.append((prefix, callback))
out = ctx.out
if not out:
out = ""
# Something is very wrong here
# Fallback to use "job_log_dirs" list to report the problem
job_log_dirs = ctx.cmd_kwargs.get("job_log_dirs", [])
for job_log_dir in job_log_dirs:
point, name, submit_num = job_log_dir.split(os.sep, 2)
itask = tasks[(point, name, submit_num)]
out += (BatchSysManager.OUT_PREFIX_SUMMARY +
"|".join([ctx.timestamp, job_log_dir, "1"]) + "\n")
for line in out.splitlines(True):
for prefix, callback in handlers:
if line.startswith(prefix):
line = line[len(prefix):].strip()
try:
path = line.split("|", 2)[1] # timestamp, path, status
point, name, submit_num = path.split(os.sep, 2)
itask = tasks[(point, name, submit_num)]
callback(suite, itask, ctx, line)
except (KeyError, ValueError):
if cylc.flags.debug:
LOG.warning('Unhandled %s output: %s' % (
ctx.cmd_key, line))
LOG.warning(traceback.format_exc())
示例11: _remote_init_callback
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import debug [as 别名]
def _remote_init_callback(self, proc_ctx, host, owner, tmphandle):
"""Callback when "cylc remote-init" exits"""
self.ready = True
tmphandle.close()
if proc_ctx.ret_code == 0:
for status in (REMOTE_INIT_DONE, REMOTE_INIT_NOT_REQUIRED):
if status in proc_ctx.out:
# Good status
LOG.debug(proc_ctx)
self.remote_init_map[(host, owner)] = status
return
# Bad status
LOG.error(TaskRemoteMgmtError(
TaskRemoteMgmtError.MSG_INIT,
(host, owner), ' '.join(quote(item) for item in proc_ctx.cmd),
proc_ctx.ret_code, proc_ctx.out, proc_ctx.err))
LOG.error(proc_ctx)
self.remote_init_map[(host, owner)] = REMOTE_INIT_FAILED
示例12: _run_command
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import debug [as 别名]
def _run_command(ctx):
"""Execute a shell command and capture its output and exit status."""
LOG.debug(ctx)
if (SuiteProcPool.STOP_JOB_SUBMISSION.value and
ctx.cmd_key == SuiteProcPool.JOBS_SUBMIT):
ctx.err = "job submission skipped (suite stopping)"
ctx.ret_code = SuiteProcPool.JOB_SKIPPED_FLAG
ctx.timestamp = get_current_time_string()
return ctx
try:
stdin_file = None
if ctx.cmd_kwargs.get('stdin_file_paths'):
stdin_file = TemporaryFile()
for file_path in ctx.cmd_kwargs['stdin_file_paths']:
for line in open(file_path):
stdin_file.write(line)
stdin_file.seek(0)
elif ctx.cmd_kwargs.get('stdin_str'):
stdin_file = PIPE
proc = Popen(
ctx.cmd, stdin=stdin_file, stdout=PIPE, stderr=PIPE,
env=ctx.cmd_kwargs.get('env'), shell=ctx.cmd_kwargs.get('shell'))
except IOError as exc:
if cylc.flags.debug:
traceback.print_exc()
ctx.ret_code = 1
ctx.err = str(exc)
except OSError as exc:
if exc.filename is None:
exc.filename = ctx.cmd[0]
if cylc.flags.debug:
traceback.print_exc()
ctx.ret_code = 1
ctx.err = str(exc)
else:
ctx.out, ctx.err = proc.communicate(ctx.cmd_kwargs.get('stdin_str'))
ctx.ret_code = proc.wait()
ctx.timestamp = get_current_time_string()
return ctx
示例13: _prep_submit_task_job_error
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import debug [as 别名]
def _prep_submit_task_job_error(self, suite, itask, dry_run, action, exc):
"""Helper for self._prep_submit_task_job. On error."""
LOG.debug("submit_num %s" % itask.submit_num)
LOG.debug(traceback.format_exc())
LOG.error(exc)
log_task_job_activity(
SuiteProcContext(self.JOBS_SUBMIT, action, err=exc, ret_code=1),
suite, itask.point, itask.tdef.name, submit_num=itask.submit_num)
if not dry_run:
# Perist
self.suite_db_mgr.put_insert_task_jobs(itask, {
'is_manual_submit': itask.is_manual_submit,
'try_num': itask.get_try_num(),
'time_submit': get_current_time_string(),
'batch_sys_name': itask.summary.get('batch_sys_name'),
})
itask.is_manual_submit = False
self.task_events_mgr.process_message(
itask, CRITICAL, self.task_events_mgr.EVENT_SUBMIT_FAILED)
示例14: log_task_job_activity
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import debug [as 别名]
def log_task_job_activity(ctx, suite, point, name, submit_num=None):
"""Log an activity for a task job."""
ctx_str = str(ctx)
if not ctx_str:
return
if isinstance(ctx.cmd_key, tuple): # An event handler
submit_num = ctx.cmd_key[-1]
job_activity_log = get_task_job_activity_log(
suite, point, name, submit_num)
try:
with open(job_activity_log, "ab") as handle:
handle.write(ctx_str + '\n')
except IOError as exc:
# This happens when there is no job directory, e.g. if job host
# selection command causes an submission failure, there will be no job
# directory. In this case, just send the information to the suite log.
LOG.debug(exc)
LOG.info(ctx_str)
if ctx.cmd and ctx.ret_code:
LOG.error(ctx_str)
elif ctx.cmd:
LOG.debug(ctx_str)
示例15: _check_access_priv_and_report
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import debug [as 别名]
def _check_access_priv_and_report(
self, required_privilege_level, log_info=True):
"""Check access privilege and log requests with identifying info.
In debug mode log all requests including task messages. Otherwise log
all user commands, and just the first info command from each client.
Return:
dict: containing the client session
"""
self._check_access_priv(required_privilege_level)
command = inspect.currentframe().f_back.f_code.co_name
auth_user, prog_name, user, host, uuid = _get_client_info()
priv_level = self._get_priv_level(auth_user)
LOG.debug(self.__class__.LOG_CONNECT_ALLOWED_TMPL % (
user, host, prog_name, priv_level, uuid))
if cylc.flags.debug or uuid not in self.clients and log_info:
LOG.info(self.__class__.LOG_COMMAND_TMPL % (
command, user, host, prog_name, uuid))
self.clients.setdefault(uuid, {})
self.clients[uuid]['time'] = time()
self._housekeep()
return self.clients[uuid]