当前位置: 首页>>代码示例>>Python>>正文


Python LOG.warning方法代码示例

本文整理汇总了Python中cylc.suite_logging.LOG.warning方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.warning方法的具体用法?Python LOG.warning怎么用?Python LOG.warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cylc.suite_logging.LOG的用法示例。


在下文中一共展示了LOG.warning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _job_cmd_out_callback

# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import warning [as 别名]
 def _job_cmd_out_callback(self, suite, itask, cmd_ctx, line):
     """Callback on job command STDOUT/STDERR."""
     if cmd_ctx.cmd_kwargs.get("host") and cmd_ctx.cmd_kwargs.get("user"):
         user_at_host = "(%(user)[email protected]%(host)s) " % cmd_ctx.cmd_kwargs
     elif cmd_ctx.cmd_kwargs.get("host"):
         user_at_host = "(%(host)s) " % cmd_ctx.cmd_kwargs
     elif cmd_ctx.cmd_kwargs.get("user"):
         user_at_host = "(%(user)[email protected]) " % cmd_ctx.cmd_kwargs
     else:
         user_at_host = ""
     try:
         timestamp, _, content = line.split("|")
     except ValueError:
         pass
     else:
         line = "%s %s" % (timestamp, content)
     job_activity_log = self.task_events_mgr.get_task_job_activity_log(
         suite, itask.point, itask.tdef.name)
     try:
         with open(job_activity_log, "ab") as handle:
             if not line.endswith("\n"):
                 line += "\n"
             handle.write(user_at_host + line)
     except IOError as exc:
         LOG.warning("%s: write failed\n%s" % (job_activity_log, exc))
         LOG.warning(user_at_host + line, itask=itask)
开发者ID:m214089,项目名称:cylc,代码行数:28,代码来源:task_job_mgr.py

示例2: check_job_time

# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import warning [as 别名]
 def check_job_time(self, itask, now):
     """Check/handle job timeout and poll timer"""
     can_poll = self.check_poll_time(itask, now)
     if itask.timeout is None or now <= itask.timeout:
         return can_poll
     # Timeout reached for task, emit event and reset itask.timeout
     if itask.state.status == TASK_STATUS_RUNNING:
         time_ref = itask.summary['started_time']
         event = 'execution timeout'
     elif itask.state.status == TASK_STATUS_SUBMITTED:
         time_ref = itask.summary['submitted_time']
         event = 'submission timeout'
     msg = event
     try:
         msg += ' after %s' % intvl_as_str(itask.timeout - time_ref)
     except (TypeError, ValueError):
         # Badness in time_ref?
         pass
     itask.timeout = None  # emit event only once
     if msg and event:
         LOG.warning(msg, itask=itask)
         self.setup_event_handlers(itask, event, msg)
         return True
     else:
         return can_poll
开发者ID:jonnyhtw,项目名称:cylc,代码行数:27,代码来源:task_events_mgr.py

示例3: _process_message_started

# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import warning [as 别名]
    def _process_message_started(self, itask, event_time):
        """Helper for process_message, handle a started message."""
        if itask.job_vacated:
            itask.job_vacated = False
            LOG.warning("Vacated job restarted", itask=itask)
        self.pflag = True
        itask.state.reset_state(TASK_STATUS_RUNNING)
        itask.set_summary_time('started', event_time)
        self.suite_db_mgr.put_update_task_jobs(itask, {
            "time_run": itask.summary['started_time_string']})
        if itask.summary['execution_time_limit']:
            execution_timeout = itask.summary['execution_time_limit']
        else:
            execution_timeout = self._get_events_conf(
                itask, 'execution timeout')
        try:
            itask.timeout_timers[TASK_STATUS_RUNNING] = (
                itask.summary['started_time'] + float(execution_timeout))
        except (TypeError, ValueError):
            itask.timeout_timers[TASK_STATUS_RUNNING] = None

        # submission was successful so reset submission try number
        if TASK_STATUS_SUBMIT_RETRYING in itask.try_timers:
            itask.try_timers[TASK_STATUS_SUBMIT_RETRYING].num = 0
        self.setup_event_handlers(itask, 'started', 'job started')
        self.set_poll_time(itask)
开发者ID:arjclark,项目名称:cylc,代码行数:28,代码来源:task_events_mgr.py

示例4: _report_connection_if_denied

# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import warning [as 别名]
 def _report_connection_if_denied(self):
     """Log an (un?)successful connection attempt."""
     prog_name, user, host, uuid = _get_client_info()[1:]
     connection_denied = self._get_client_connection_denied()
     if connection_denied:
         LOG.warning(self.__class__.LOG_CONNECT_DENIED_TMPL % (
             user, host, prog_name, uuid))
开发者ID:arjclark,项目名称:cylc,代码行数:9,代码来源:httpserver.py

示例5: remote_tidy

# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import warning [as 别名]
    def remote_tidy(self):
        """Remove suite contact files from initialised remotes.

        Call "cylc remote-tidy".
        This method is called on suite shutdown, so we want nothing to hang.
        Timeout any incomplete commands after 10 seconds.

        Also remove UUID file on suite host ".service/uuid".
        """
        # Remove UUID file
        uuid_fname = os.path.join(
            self.suite_srv_files_mgr.get_suite_srv_dir(self.suite),
            FILE_BASE_UUID)
        try:
            os.unlink(uuid_fname)
        except OSError:
            pass
        # Issue all SSH commands in parallel
        procs = {}
        for (host, owner), init_with_contact in self.remote_init_map.items():
            if init_with_contact != REMOTE_INIT_DONE:
                continue
            cmd = ['timeout', '10', 'cylc', 'remote-tidy']
            if is_remote_host(host):
                cmd.append('--host=%s' % host)
            if is_remote_user(owner):
                cmd.append('--user=%s' % owner)
            if cylc.flags.debug:
                cmd.append('--debug')
            cmd.append(os.path.join(glbl_cfg().get_derived_host_item(
                self.suite, 'suite run directory', host, owner)))
            procs[(host, owner)] = (
                cmd,
                Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=open(os.devnull)))
        # Wait for commands to complete for a max of 10 seconds
        timeout = time() + 10.0
        while procs and time() < timeout:
            for (host, owner), (cmd, proc) in procs.copy().items():
                if proc.poll() is None:
                    continue
                del procs[(host, owner)]
                out, err = proc.communicate()
                if proc.wait():
                    LOG.warning(TaskRemoteMgmtError(
                        TaskRemoteMgmtError.MSG_TIDY,
                        (host, owner), ' '.join(quote(item) for item in cmd),
                        proc.ret_code, out, err))
        # Terminate any remaining commands
        for (host, owner), (cmd, proc) in procs.items():
            try:
                proc.terminate()
            except OSError:
                pass
            out, err = proc.communicate()
            if proc.wait():
                LOG.warning(TaskRemoteMgmtError(
                    TaskRemoteMgmtError.MSG_TIDY,
                    (host, owner), ' '.join(quote(item) for item in cmd),
                    proc.ret_code, out, err))
开发者ID:arjclark,项目名称:cylc,代码行数:61,代码来源:task_remote_mgr.py

示例6: recover_pub_from_pri

# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import warning [as 别名]
 def recover_pub_from_pri(self):
     """Recover public database from private database."""
     if self.pub_dao.n_tries >= self.pub_dao.MAX_TRIES:
         self.copy_pri_to_pub()
         LOG.warning(
             "%(pub_db_name)s: recovered from %(pri_db_name)s" % {
                 "pub_db_name": self.pub_dao.db_file_name,
                 "pri_db_name": self.pri_dao.db_file_name})
         self.pub_dao.n_tries = 0
开发者ID:arjclark,项目名称:cylc,代码行数:11,代码来源:suite_db_mgr.py

示例7: put_command

# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import warning [as 别名]
 def put_command(self, ctx, callback, callback_args=None):
     """Queue a new shell command to execute."""
     try:
         result = self.pool.apply_async(_run_command, [ctx])
     except AssertionError as exc:
         LOG.warning("%s\n  %s\n %s" % (
             str(exc),
             "Rejecting command (pool closed)",
             ctx.cmd))
     else:
         self.results[id(result)] = (result, callback, callback_args)
开发者ID:m214089,项目名称:cylc,代码行数:13,代码来源:mp_pool.py

示例8: poll_task_jobs

# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import warning [as 别名]
 def poll_task_jobs(self, suite, itasks, warn_skips=False):
     """Poll jobs of specified tasks."""
     active_itasks = []
     for itask in itasks:
         if itask.state.status in TASK_STATUSES_ACTIVE:
             active_itasks.append(itask)
         elif warn_skips:  # and not active
             LOG.warning(
                 '%s: skip poll, task not pollable' % itask.identity)
     self._run_job_cmd(
         self.JOBS_POLL, suite, active_itasks,
         self._poll_task_jobs_callback)
开发者ID:m214089,项目名称:cylc,代码行数:14,代码来源:task_job_mgr.py

示例9: execute_queued_items

# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import warning [as 别名]
 def execute_queued_items(self):
     """Execute queued items for each table."""
     try:
         for table in self.tables.values():
             # DELETE statements may have varying number of WHERE args so we
             # can only executemany for each identical template statement.
             for stmt, stmt_args_list in table.delete_queues.items():
                 self._execute_stmt(stmt, stmt_args_list)
             # INSERT statements are uniform for each table, so all INSERT
             # statements can be executed using a single "executemany" call.
             if table.insert_queue:
                 self._execute_stmt(table.get_insert_stmt(), table.insert_queue)
             # UPDATE statements can have varying number of SET and WHERE
             # args so we can only executemany for each identical template
             # statement.
             for stmt, stmt_args_list in table.update_queues.items():
                 self._execute_stmt(stmt, stmt_args_list)
         # Connection should only be opened if we have executed something.
         if self.conn is None:
             return
         self.conn.commit()
     except sqlite3.Error:
         if not self.is_public:
             raise
         self.n_tries += 1
         LOG.warning(
             "%(file)s: write attempt (%(attempt)d) did not complete\n"
             % {"file": self.db_file_name, "attempt": self.n_tries}
         )
         if self.conn is not None:
             try:
                 self.conn.rollback()
             except sqlite3.Error:
                 pass
         return
     else:
         # Clear the queues
         for table in self.tables.values():
             table.delete_queues.clear()
             del table.insert_queue[:]  # list.clear avail from Python 3.3
             table.update_queues.clear()
         # Report public database retry recovery if necessary
         if self.n_tries:
             LOG.warning(
                 "%(file)s: recovered after (%(attempt)d) attempt(s)\n"
                 % {"file": self.db_file_name, "attempt": self.n_tries}
             )
         self.n_tries = 0
     finally:
         # Note: This is not strictly necessary. However, if the suite run
         # directory is removed, a forced reconnection to the private
         # database will ensure that the suite dies.
         self.close()
开发者ID:oliver-sanders,项目名称:cylc,代码行数:55,代码来源:rundb.py

示例10: kill_task_jobs

# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import warning [as 别名]
    def kill_task_jobs(self, suite, itasks):
        """Kill jobs of active tasks, and hold the tasks.

        If items is specified, kill active tasks matching given IDs.

        """
        to_kill_tasks = []
        for itask in itasks:
            if itask.state.status in TASK_STATUSES_ACTIVE:
                itask.state.set_held()
                to_kill_tasks.append(itask)
            else:
                LOG.warning('skipping %s: task not killable' % itask.identity)
        self._run_job_cmd(
            self.JOBS_KILL, suite, to_kill_tasks,
            self._kill_task_jobs_callback)
开发者ID:jonnyhtw,项目名称:cylc,代码行数:18,代码来源:task_job_mgr.py

示例11: _process_message_started

# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import warning [as 别名]
    def _process_message_started(self, itask, event_time):
        """Helper for process_message, handle a started message."""
        if itask.job_vacated:
            itask.job_vacated = False
            LOG.warning("Vacated job restarted", itask=itask)
        self.pflag = True
        if itask.state.reset_state(TASK_STATUS_RUNNING):
            self.setup_event_handlers(itask, 'started', 'job started')
        itask.set_summary_time('started', event_time)
        self._reset_job_timers(itask)
        self.suite_db_mgr.put_update_task_jobs(itask, {
            "time_run": itask.summary['started_time_string']})

        # submission was successful so reset submission try number
        if TASK_STATUS_SUBMIT_RETRYING in itask.try_timers:
            itask.try_timers[TASK_STATUS_SUBMIT_RETRYING].num = 0
开发者ID:jonnyhtw,项目名称:cylc,代码行数:18,代码来源:task_events_mgr.py

示例12: report_connection_if_denied

# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import warning [as 别名]
 def report_connection_if_denied(self):
     """Log an (un?)successful connection attempt."""
     try:
         (auth_user, prog_name, user, host, uuid,
          priv_level) = get_client_info()
     except Exception:
         LOG.warning(
             self.__class__.LOG_CONNECT_DENIED_TMPL % (
                 "unknown", "unknown", "unknown", "unknown")
         )
         return
     connection_denied = get_client_connection_denied()
     if connection_denied:
         LOG.warning(
             self.__class__.LOG_CONNECT_DENIED_TMPL % (
                 user, host, prog_name, uuid)
         )
开发者ID:m214089,项目名称:cylc,代码行数:19,代码来源:client_reporter.py

示例13: _check_access_priv

# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import warning [as 别名]
    def _check_access_priv(self, required_privilege_level):
        """Raise an exception if client privilege is insufficient.

        (See the documentation above for the boolean version of this function).

        """
        auth_user, prog_name, user, host, uuid = _get_client_info()
        priv_level = self._get_priv_level(auth_user)
        if (PRIVILEGE_LEVELS.index(priv_level) <
                PRIVILEGE_LEVELS.index(required_privilege_level)):
            err = self.CONNECT_DENIED_PRIV_TMPL % (
                priv_level, required_privilege_level,
                user, host, prog_name, uuid)
            LOG.warning(err)
            # Raise an exception to be sent back to the client.
            raise cherrypy.HTTPError(403, err)
        return True
开发者ID:arjclark,项目名称:cylc,代码行数:19,代码来源:httpserver.py

示例14: kill_task_jobs

# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import warning [as 别名]
    def kill_task_jobs(self, suite, itasks, warn_skips=False):
        """Kill jobs of active tasks, and hold the tasks.

        If items is specified, kill active tasks matching given IDs.

        """
        active_itasks = []
        for itask in itasks:
            if itask.state.status in TASK_STATUSES_ACTIVE:
                itask.state.set_held()
                active_itasks.append(itask)
            elif warn_skips:  # and not active
                LOG.warning(
                    '%s: skip kill, task not killable' % itask.identity)
        self._run_job_cmd(
            self.JOBS_KILL, suite, active_itasks,
            self._kill_task_jobs_callback)
开发者ID:m214089,项目名称:cylc,代码行数:19,代码来源:task_job_mgr.py

示例15: _manip_task_jobs_callback

# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import warning [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())
开发者ID:m214089,项目名称:cylc,代码行数:47,代码来源:task_job_mgr.py


注:本文中的cylc.suite_logging.LOG.warning方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。