本文整理汇总了Python中loguru.logger.warning方法的典型用法代码示例。如果您正苦于以下问题:Python logger.warning方法的具体用法?Python logger.warning怎么用?Python logger.warning使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类loguru.logger
的用法示例。
在下文中一共展示了logger.warning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range_diff
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import warning [as 别名]
def range_diff(
range_list_1: typing.List[VideoCutRange],
range_list_2: typing.List[VideoCutRange],
*args,
**kwargs,
) -> typing.Dict:
# 1. stage length compare
self_stable_range_count = len(range_list_1)
another_stable_range_count = len(range_list_2)
if self_stable_range_count != another_stable_range_count:
logger.warning(
f"stage counts not equal: {self_stable_range_count} & {another_stable_range_count}"
)
# 2. stage content compare
# TODO will load these pictures in memory at the same time
data = dict()
for self_id, each_self_range in enumerate(range_list_1):
temp = dict()
for another_id, another_self_range in enumerate(range_list_2):
temp[another_id] = each_self_range.diff(
another_self_range, *args, **kwargs
)
data[self_id] = temp
return data
示例2: write
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import warning [as 别名]
def write(self,msg,level='info'):
"Write out a message"
fname = inspect.stack()[2][3] #May be use a entry-exit decorator instead
d = {'caller_func': fname}
if level.lower()== 'debug':
logger.debug("{module} | {msg}",module=d['caller_func'],msg=msg)
elif level.lower()== 'info':
logger.info("{module} | {msg}",module=d['caller_func'],msg=msg)
elif level.lower()== 'warn' or level.lower()=='warning':
logger.warning("{module} | {msg}",module=d['caller_func'],msg=msg)
elif level.lower()== 'error':
logger.error("{module} | {msg}",module=d['caller_func'],msg=msg)
elif level.lower()== 'critical':
logger.critical("{module} | {msg}",module=d['caller_func'],msg=msg)
else:
logger.critical("Unknown level passed for the msg: {}", msg)
示例3: format_pytest_with_black
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import warning [as 别名]
def format_pytest_with_black(*python_paths: Text) -> NoReturn:
logger.info("format pytest cases with black ...")
try:
if is_support_multiprocessing() or len(python_paths) <= 1:
subprocess.run(["black", *python_paths])
else:
logger.warning(
f"this system does not support multiprocessing well, format files one by one ..."
)
[subprocess.run(["black", path]) for path in python_paths]
except subprocess.CalledProcessError as ex:
capture_exception(ex)
logger.error(ex)
sys.exit(1)
except FileNotFoundError:
err_msg = """
missing dependency tool: black
install black manually and try again:
$ pip install black
"""
logger.error(err_msg)
sys.exit(1)
示例4: ensure_cli_args
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import warning [as 别名]
def ensure_cli_args(args: List) -> List:
""" ensure compatibility with deprecated cli args in v2
"""
# remove deprecated --failfast
if "--failfast" in args:
logger.warning(f"remove deprecated argument: --failfast")
args.pop(args.index("--failfast"))
# convert --report-file to --html
if "--report-file" in args:
logger.warning(f"replace deprecated argument --report-file with --html")
index = args.index("--report-file")
args[index] = "--html"
args.append("--self-contained-html")
# keep compatibility with --save-tests in v2
if "--save-tests" in args:
logger.warning(
f"generate conftest.py keep compatibility with --save-tests in v2"
)
args.pop(args.index("--save-tests"))
_generate_conftest_for_summary(args)
return args
示例5: on_post_setup
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import warning [as 别名]
def on_post_setup(self, _):
"""Finalizes dependency structure for the pipelines."""
# Unsourced pipelines might occur when generic components register
# modifiers to values that aren't required in a simulation.
unsourced_pipelines = [p for p, v in self._pipelines.items() if not v.source]
if unsourced_pipelines:
logger.warning(f"Unsourced pipelines: {unsourced_pipelines}")
# register_value_producer and register_value_modifier record the
# dependency structure for the pipeline source and pipeline modifiers,
# respectively. We don't have enough information to record the
# dependency structure for the pipeline itself until now, where
# we say the pipeline value depends on its source and all its
# modifiers.
for name, pipe in self._pipelines.items():
dependencies = []
if pipe.source:
dependencies += [f'value_source.{name}']
else:
dependencies += [f'missing_value_source.{name}']
for i, m in enumerate(pipe.mutators):
mutator_name = self._get_modifier_name(m)
dependencies.append(f'value_modifier.{name}.{i+1}.{mutator_name}')
self.resources.add_resources('value', [name], pipe._call, dependencies)
示例6: rank_consequence_type
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import warning [as 别名]
def rank_consequence_type(self) -> int:
"""Rank the severeness of its consequence type (CSQ column ``Consequence``).
Severe consequence type has smaller rank (smallest being 0). Ranking is based on the
order in :attr:`ALL_CONSEQUENCE_TYPES`. When the CSQ has multiple consequence types
separated by ``&``, return the smallest rank of all the types. When the consequence type
is not known, return the biggest possible rank + 1.
"""
ranks: List[int] = []
for ct in self.consequence_types:
try:
rank = ALL_CONSEQUENCE_TYPES.index(ct)
except ValueError:
# Assign unknown consequence type to the lowest rank
rank = len(ALL_CONSEQUENCE_TYPES)
logger.warning(
"Got unknown consequence type: {ct}; assign its rank = {rank}",
ct=ct,
rank=rank,
)
ranks.append(rank)
return min(ranks)
示例7: _read_pp2_gene_list
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import warning [as 别名]
def _read_pp2_gene_list(self) -> None:
"""Read gene list for PP2 module.
Load :attr:`pp2_genes`
from :attr:`self.config.PP2_gene_list <.CharGerConfig.PP2_gene_list>`.
Skip PP2 module if not provided.
"""
gene_list_pth = self.config.PP2_gene_list
# Disable PP2 module if no list is provided
if gene_list_pth is None:
logger.warning(
"CharGer cannot make PP2 calls without the given gene list. "
"Disable PP2 module"
)
self._acmg_module_availability["PP2"] = ModuleAvailability.INVALID_SETUP
return
logger.info(f"Read PP2 gene list from {gene_list_pth}")
self.pp2_genes = set(l.strip() for l in read_lines(gene_list_pth))
logger.info(f"Marked {len(self.pp2_genes):,d} genes for PP2")
示例8: _read_bp1_gene_list
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import warning [as 别名]
def _read_bp1_gene_list(self) -> None:
"""Read gene list for BP1 module.
Load :attr:`bp1_genes`
from :attr:`self.config.BP1_gene_list <.CharGerConfig.BP1_gene_list>`.
Skip BP1 module if not provided.
"""
gene_list_pth = self.config.BP1_gene_list
# Disable BP1 module if no list is provided
if gene_list_pth is None:
logger.warning(
"CharGer cannot make BP1 calls without the given gene list. "
"Disable BP1 module"
)
self._acmg_module_availability["BP1"] = ModuleAvailability.INVALID_SETUP
return
logger.info(f"Read BP1 gene list from {gene_list_pth}")
self.bp1_genes = set(l.strip() for l in read_lines(gene_list_pth))
logger.info(f"Marked {len(self.bp1_genes):,d} genes for BP1")
示例9: init_backends
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import warning [as 别名]
def init_backends():
init_environment()
# populate available backend modules
global BACKENDS
BACKENDS = {}
import numpy
if numpy.__name__ == 'bohrium':
logger.warning('Running veros with "python -m bohrium" is discouraged '
'(use "--backend bohrium" instead)')
import numpy_force
numpy = numpy_force
BACKENDS['numpy'] = numpy
try:
import bohrium
except ImportError:
logger.warning('Could not import Bohrium (Bohrium backend will be unavailable)')
BACKENDS['bohrium'] = None
else:
BACKENDS['bohrium'] = bohrium
示例10: read_restart
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import warning [as 别名]
def read_restart(self, vs, infile):
restart_vars = {var: vs.variables[var] for var in self.restart_variables}
restart_data = {var: getattr(vs, var) for var in self.restart_variables}
attributes, variables = self.read_h5_restart(vs, restart_vars, infile)
for key, arr in restart_data.items():
try:
restart_var = variables[key]
except KeyError:
logger.warning('Not reading restart data for variable {}: '
'no matching data found in restart file'
.format(key))
continue
if not arr.shape == restart_var.shape:
logger.warning('Not reading restart data for variable {}: '
'restart data dimensions do not match model '
'grid'.format(key))
continue
arr[...] = restart_var
for attr in self.restart_attributes:
try:
setattr(vs, attr, attributes[attr])
except KeyError:
logger.warning('Not reading restart data for attribute {}: '
'attribute not found in restart file'
.format(attr))
示例11: _get_solver_class
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import warning [as 别名]
def _get_solver_class():
ls = rs.linear_solver
def _get_best_solver():
if rst.proc_num > 1:
try:
from .solvers.petsc import PETScSolver
except ImportError:
logger.warning('PETSc linear solver not available, falling back to SciPy')
else:
return PETScSolver
from .solvers.scipy import SciPySolver
return SciPySolver
if ls == 'best':
return _get_best_solver()
elif ls == 'petsc':
from .solvers.petsc import PETScSolver
return PETScSolver
elif ls == 'scipy':
from .solvers.scipy import SciPySolver
return SciPySolver
raise ValueError('unrecognized linear solver %s' % ls)
示例12: auto_reload_mixin
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import warning [as 别名]
def auto_reload_mixin(func):
@click.option(
"--autoreload", is_flag=True, default=False, help="Reload application on file changes"
)
@functools.wraps(func)
def wrapper(autoreload: bool, *args, **kwargs):
if autoreload and aiohttp_autoreload:
logger.warning(
"Application started in live-reload mode. Please disable it in production!"
)
aiohttp_autoreload.start()
elif autoreload and not aiohttp_autoreload:
click.echo("`aiohttp_autoreload` is not installed.", err=True)
return func(*args, **kwargs)
return wrapper
示例13: create_super_user
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import warning [as 别名]
def create_super_user(user_id: int, remove: bool) -> bool:
user = await User.query.where(User.id == user_id).gino.first()
if not user:
logger.error("User is not registered in bot")
raise ValueError("User is not registered in bot")
logger.info(
"Loaded user {user}. It's registered at {register_date}.",
user=user.id,
register_date=user.created_at,
)
await user.update(is_superuser=not remove).apply()
if remove:
logger.warning("User {user} now IS NOT superuser", user=user_id)
else:
logger.warning("User {user} now IS superuser", user=user_id)
return True
示例14: _get_free_qdisc_id
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import warning [as 别名]
def _get_free_qdisc_id(device: str) -> int:
process = run(
f"tc qdisc show dev {device}", stdout=subprocess.PIPE, universal_newlines=True,
)
ids = set()
for line in process.stdout.splitlines():
match = QDISC_ID_REGEX.match(line)
if not match:
logger.warning("Failed to parse line: {!r}", line)
continue
id_string = match.group(1)
try:
id_ = int(id_string)
except ValueError:
# This should only happen for the ingress QDisc
logger.debug(
"Failed to parse QDisc ID as base 10 integer on line: {!r}", line
)
id_ = int(id_string, 16)
ids.add(id_)
return _find_free_id(ids)
示例15: _get_free_class_id
# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import warning [as 别名]
def _get_free_class_id(device: str, qdisc_id: int) -> int:
process = run(
f"tc class show dev {device}", stdout=subprocess.PIPE, universal_newlines=True,
)
ids = set()
for line in process.stdout.splitlines():
match = CLASS_ID_REGEX.match(line)
if not match:
logger.warning("Failed to parse line: {!r}", line)
continue
groups = match.groupdict()
if int(groups["qdisc_id"]) == qdisc_id:
ids.add(int(groups["class_id"]))
return _find_free_id(ids)