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


Python logging.critical方法代码示例

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


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

示例1: log_login

# 需要导入模块: import logging [as 别名]
# 或者: from logging import critical [as 别名]
def log_login(function):
        def wrapper(parser, reddit):
            print("\nLogging in...")

            try:
                function(parser, reddit)
                logging.info("Successfully logged in as u/%s." % reddit.user.me())
                logging.info("")
            except PrawcoreException as error:
                Titles.Titles.p_title(error)
                logging.critical("LOGIN FAILED.")
                logging.critical("PRAWCORE EXCEPTION: %s.\n" % error)
                parser.exit()

        return wrapper

    ### Wrapper for logging rate limit errors. 
开发者ID:JosephLai241,项目名称:URS,代码行数:19,代码来源:Logger.py

示例2: load_equivalences

# 需要导入模块: import logging [as 别名]
# 或者: from logging import critical [as 别名]
def load_equivalences(paths):
  """Loads equivalences from a text file.

  Args:
    paths: sequence of paths to the text files of equivalences; id0,id1 per
      line, or id0,id1,x,y,z.

  Returns:
    NX graph object representing the equivalences
  """
  equiv_graph = nx.Graph()

  for path in paths:
    with open(path, "r") as f:
      reader = pd.read_csv(
          f, sep=",", engine="c", comment="#", chunksize=4096, header=None)
      for chunk in reader:
        if len(chunk.columns) not in (2, 5):
          logging.critical("Unexpected # of columns (%d), want 2 or 5",
                           len(chunk.columns))

        edges = chunk.values[:, :2]
        equiv_graph.add_edges_from(edges)

  return equiv_graph 
开发者ID:google,项目名称:ffn,代码行数:27,代码来源:object_utils.py

示例3: __schedule_requests

# 需要导入模块: import logging [as 别名]
# 或者: from logging import critical [as 别名]
def __schedule_requests():
    """
    Schedule requests
    """
    try:
        throttler_mode = config_core.get('throttler', 'mode', default='DEST_PER_ACT', use_cache=False)
        direction, all_activities = get_parsed_throttler_mode(throttler_mode)
        result_dict = __get_request_stats(all_activities, direction)
        if direction == 'destination' or direction == 'source':
            for rse_id in result_dict:
                rse_name = result_dict[rse_id]['rse']
                availability = get_rse(rse_id).availability
                # dest_rse is not blacklisted for write or src_rse is not blacklisted for read
                if (direction == 'destination' and availability & 2) or (direction == 'source' and availability & 4):
                    if all_activities:
                        __release_all_activities(result_dict[rse_id], direction, rse_name, rse_id)
                    else:
                        __release_per_activity(result_dict[rse_id], direction, rse_name, rse_id)
    except Exception:
        logging.critical("Failed to schedule requests, error: %s" % (traceback.format_exc())) 
开发者ID:rucio,项目名称:rucio,代码行数:22,代码来源:throttler.py

示例4: _retrial

# 需要导入模块: import logging [as 别名]
# 或者: from logging import critical [as 别名]
def _retrial(func, *args, **kwargs):
    """
    Retrial method
    """
    delay = 0
    while True:
        try:
            return func(*args, **kwargs)
        except DataIdentifierNotFound as error:
            logging.warning(error)
            return 1
        except DatabaseException as error:
            logging.error(error)
            if exp(delay) > 600:
                logging.error('Cannot execute %s after %i attempt. Failing the job.' % (func.__name__, delay))
                raise
            else:
                logging.error('Failure to execute %s. Retrial will be done in %d seconds ' % (func.__name__, exp(delay)))
            time.sleep(exp(delay))
            delay += 1
        except Exception:
            exc_type, exc_value, exc_traceback = exc_info()
            logging.critical(''.join(format_exception(exc_type, exc_value, exc_traceback)).strip())
            raise 
开发者ID:rucio,项目名称:rucio,代码行数:26,代码来源:transmogrifier.py

示例5: run

# 需要导入模块: import logging [as 别名]
# 或者: from logging import critical [as 别名]
def run(self):
        while not STOPPED_BY_INTERRUPT:
            try:
                currentRun = _Worker.working_queue.get_nowait()
            except queue.Empty:
                return

            try:
                logging.debug('Executing run "%s"', currentRun.identifier)
                self.execute(currentRun)
                logging.debug('Finished run "%s"', currentRun.identifier)
            except SystemExit as e:
                logging.critical(e)
            except BenchExecException as e:
                logging.critical(e)
            except BaseException:
                logging.exception("Exception during run execution")
            self.run_finished_callback()
            _Worker.working_queue.task_done() 
开发者ID:sosy-lab,项目名称:benchexec,代码行数:21,代码来源:localexecution.py

示例6: _setup_cgroup_memory_limit

# 需要导入模块: import logging [as 别名]
# 或者: from logging import critical [as 别名]
def _setup_cgroup_memory_limit(self, memlimit, cgroups, pid_to_kill):
        """Start memory-limit handler.
        @return None or the memory-limit handler for calling cancel()
        """
        if memlimit is not None:
            try:
                oomThread = oomhandler.KillProcessOnOomThread(
                    cgroups=cgroups,
                    pid_to_kill=pid_to_kill,
                    callbackFn=self._set_termination_reason,
                )
                oomThread.start()
                return oomThread
            except OSError as e:
                logging.critical(
                    "OSError %s during setup of OomEventListenerThread: %s.",
                    e.errno,
                    e.strerror,
                )
        return None 
开发者ID:sosy-lab,项目名称:benchexec,代码行数:22,代码来源:runexecutor.py

示例7: swf_event_to_object

# 需要导入模块: import logging [as 别名]
# 或者: from logging import critical [as 别名]
def swf_event_to_object(event_dict):
    """
    takes an event dictionary from botocore and converts it into a specific
    event instance.
    """
    try:
        event_class = _event_type_name_to_class[event_dict['eventType']]
    except KeyError:
        # we cannot guarantee we do the right thing in the decider if there's an unsupported event type.
        logging.critical("Event type '%' is not implemented. Cannot continue processing decisions!",
                         event_dict['eventType'])
        raise NotImplementedError(
            "Event type '{}' is not implemented. Cannot continue processing decisions!".format(event_dict['eventType']))

    return event_class(event_dict['eventId'],
                       event_dict['eventTimestamp'],
                       event_dict[event_class.attribute_key]) 
开发者ID:boto,项目名称:botoflow,代码行数:19,代码来源:events.py

示例8: tearDown

# 需要导入模块: import logging [as 别名]
# 或者: from logging import critical [as 别名]
def tearDown(self, *args, **kwargs):
        if self.cli_process is not None:
            try:
                self.cli_process.terminate()
                self.cli_process.wait(5)
            except TimeoutExpired:
                try:
                    self.cli_process.kill()
                    self.cli_process.wait(5)
                except Exception as e:
                    logging.critical("cannot stop subprocess {}: {}".format(self.cli_process, e))

            if self.cli_process.returncode != 0:
                self.fail("subprocess {} returned exit code {}".format(' '.join(self.cli_args), self.cli_process.returncode))

        if self.stdout_reader_thread is not None:
            self.stdout_reader_thread.join(5)
            if self.stdout_reader_thread.is_alive():
                logging.error("reader thread not stopping...")

        if self.stderr_reader_thread is not None:
            self.stderr_reader_thread.join(5)
            if self.stderr_reader_thread.is_alive():
                logging.error("reader thread not stopping...") 
开发者ID:IntegralDefense,项目名称:ACE,代码行数:26,代码来源:test_ace.py

示例9: stop_threaded_execution

# 需要导入模块: import logging [as 别名]
# 或者: from logging import critical [as 别名]
def stop_threaded_execution(self):
        if not self.is_threaded:
            return

        logging.info("stopping threaded execution for {}".format(self))

        self.threaded_execution_stop_event.set()
        start = datetime.datetime.now()
        while True:
            self.threaded_execution_thread.join(5)
            if not self.threaded_execution_thread.is_alive():
                break

            logging.error("thread {} is not stopping".format(self.threaded_execution_thread))

            # have we been waiting for a really long time?
            if (datetime.datetime.now() - start).total_seconds() >= saq.EXECUTION_THREAD_LONG_TIMEOUT:
                logging.critical("execution thread {} is failing to stop - process dying".format(
                                  self.threaded_execution_thread))
                # suicide
                os._exit(1)

        logging.debug("threaded execution module {} has stopped ({})".format(self, self.threaded_execution_thread)) 
开发者ID:IntegralDefense,项目名称:ACE,代码行数:25,代码来源:__init__.py

示例10: create_analysis

# 需要导入模块: import logging [as 别名]
# 或者: from logging import critical [as 别名]
def create_analysis(self, observable):
        """Initializes and adds the generated Analysis for this module to the given Observable. 
           Returns the generated Analysis."""
        # have we already created analysis for this observable?
        if self.generated_analysis_type is None:
            logging.critical("called create_analysis on {} which does not actually create Analysis".format(self))
            return None

        analysis = observable.get_analysis(self.generated_analysis_type)
        if analysis:
            logging.debug("returning existing analysis {} in call to create analysis from {} for {}".format(
                          analysis, self, observable))
            return analysis
        
        # otherwise we create and initialize a new one
        analysis = self.generated_analysis_type()
        analysis.initialize_details()
        observable.add_analysis(analysis)
        return analysis

    # XXX this is not supported at all 
开发者ID:IntegralDefense,项目名称:ACE,代码行数:23,代码来源:__init__.py

示例11: verify_environment

# 需要导入模块: import logging [as 别名]
# 或者: from logging import critical [as 别名]
def verify_environment(self):
        self.verify_config_exists('whitelist_path')
        self.verify_path_exists(self.config['whitelist_path'])
        self.verify_config_exists('regex_path')
        self.verify_path_exists(self.config['regex_path'])
        self.verify_config_exists('blacklist_path')
        self.verify_path_exists(self.config['blacklist_path'])
        self.verify_config_exists('uncommon_network_threshold')
        self.verify_config_exists('user-agent')
        self.verify_config_exists('timeout')
        self.verify_config_exists('max_download_size')
        self.verify_config_exists('max_file_name_length')
        self.verify_config_exists('cooldown_period')
        self.verify_config_exists('update_brocess')
        self.verify_config_exists('proxies')
        
        for name in self.config['proxies'].split(','):
            if name == 'GLOBAL':
                continue

            if 'proxy_{}'.format(name) not in saq.CONFIG:
                logging.critical("invalid proxy name {} in crawlphish config".format(name)) 
开发者ID:IntegralDefense,项目名称:ACE,代码行数:24,代码来源:url.py

示例12: main

# 需要导入模块: import logging [as 别名]
# 或者: from logging import critical [as 别名]
def main():  # pragma: no cover
    args = parse_arguments(*sys.argv[1:])

    logging.basicConfig(level=logging.INFO, format='%(message)s')

    config_filenames = tuple(collect.collect_config_filenames(args.config_paths))
    if len(config_filenames) == 0:
        logger.critical('No files to validate found')
        sys.exit(1)

    found_issues = False
    for config_filename in config_filenames:
        try:
            validate.parse_configuration(config_filename, validate.schema_filename())
        except (ValueError, OSError, validate.Validation_error) as error:
            logging.critical('{}: Error parsing configuration file'.format(config_filename))
            logging.critical(error)
            found_issues = True

    if found_issues:
        sys.exit(1)
    else:
        logger.info(
            'All given configuration files are valid: {}'.format(', '.join(config_filenames))
        ) 
开发者ID:witten,项目名称:borgmatic,代码行数:27,代码来源:validate_config.py

示例13: __get_auth_token

# 需要导入模块: import logging [as 别名]
# 或者: from logging import critical [as 别名]
def __get_auth_token(self):
        request_data = '{"username":"%s","password":"%s"}' % (self.username, self.password)
        for connection_url in self.urls:
            try:
                response = self.session.post('%s/_open/auth' % connection_url, data=request_data)
                if response.ok:
                    json_data = response.content
                    if json_data:
                        data_dict = json_mod.loads(json_data.decode("utf-8"))
                        return data_dict.get('jwt')
            except requests_exceptions.ConnectionError:
                if connection_url is not self.urls[-1]:
                    logging.critical("Unable to connect to %s trying another", connection_url)
                else:
                    logging.critical("Unable to connect to any of the urls: %s", self.urls)
                    raise 
开发者ID:ArangoDB-Community,项目名称:pyArango,代码行数:18,代码来源:jwauth.py

示例14: test_handling_crash_of_watchdog

# 需要导入模块: import logging [as 别名]
# 或者: from logging import critical [as 别名]
def test_handling_crash_of_watchdog(instr_workbench, caplog):
    """Test handling that we can close even if the observer fail to join.

    """
    instr_workbench.register(InstrContributor1())

    # Test starting
    p = instr_workbench.get_plugin('exopy.instruments')

    o = p._observer
    j = o.join

    def false_join():
        import logging
        logging.critical('Crash')
        raise RuntimeError()

    o.join = false_join

    p.stop()
    j()
    assert any(r.levelname == 'CRITICAL' for r in caplog.records) 
开发者ID:Exopy,项目名称:exopy,代码行数:24,代码来源:test_plugin.py

示例15: get_wopi_test_endpoint

# 需要导入模块: import logging [as 别名]
# 或者: from logging import critical [as 别名]
def get_wopi_test_endpoint(wopi_discovery_service_url):
    logging.info("WOPI Discovery Service Url: " + wopi_discovery_service_url)
    discovery_service_response = requests.get(wopi_discovery_service_url)

    try:
        discovery_service_response.raise_for_status()
    except requests.exceptions.HTTPError as exception:
        print(Fore.RED + "Failed to retrieve WOPI Discovery Service XML: Check Logs for more information")
        logging.critical("Failed to retrieve WOPI Discovery Service XML - HTTP ErrorCode: ", exception.Code)
        sys.exit(1)

    try:
        discovery_xml = ElementTree.fromstring(discovery_service_response.content)
        wopi_test_endpoint_url = discovery_xml.find(WOPITESTAPPLICATION_NODE_PATH).attrib[
            WOPITESTAPPLICATION_URLSRC_ATTRIBUTE]
    except Exception as exception:
        print(Fore.RED + "Failed to parse WOPI Discovery Service XML: Check Logs for more information")
        logging.critical("Failed to parse WOPI Discovery Service XML - Exception Details:", exception)
        sys.exit(1)

    return wopi_test_endpoint_url[:wopi_test_endpoint_url.find('?')] 
开发者ID:microsoft,项目名称:wopi-validator-cli-python,代码行数:23,代码来源:WopiValidatorExecutor.py


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