forked from platypush/platypush
Replaced warnings.warn
with logging.warnings
.
I couldn't find an easy and reliable way of routing `warnings.warn` to `logging`. Closes: #281
This commit is contained in:
parent
87a902bfa3
commit
17b6b02986
6 changed files with 37 additions and 45 deletions
15
CHANGELOG.md
15
CHANGELOG.md
|
@ -1,13 +1,22 @@
|
|||
# Changelog
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- [[#281](https://git.platypush.tech/platypush/platypush/issues/281)]
|
||||
replaced `warnings.warn` with `logging.warning`, as there is no easy and
|
||||
reliable way of routing `warnings.warn` to `logging`.
|
||||
|
||||
## [1.1.0] - 2024-06-06
|
||||
|
||||
- [#405] Fixed timezone/timestamp rendering issues for `calendar.ical` events.
|
||||
- [#403] Included inherited actions in plugins docs.
|
||||
- [[#405](https://git.platypush.tech/platypush/platypush/issues/405)] Fixed
|
||||
timezone/timestamp rendering issues for `calendar.ical` events.
|
||||
- [[#403]((https://git.platypush.tech/platypush/platypush/issues/403))]
|
||||
Included inherited actions in plugins docs.
|
||||
|
||||
## [1.0.7] - 2024-06-02
|
||||
|
||||
- [#384] Added `assistant.openai` and `tts.openai` plugins.
|
||||
- [[#384]((https://git.platypush.tech/platypush/platypush/issues/384))] Added
|
||||
`assistant.openai` and `tts.openai` plugins.
|
||||
|
||||
## [1.0.6] - 2024-06-01
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import asyncio
|
||||
import logging
|
||||
import threading
|
||||
import warnings
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from functools import wraps
|
||||
|
@ -168,11 +167,7 @@ class RunnablePlugin(Plugin):
|
|||
self._thread: Optional[threading.Thread] = None
|
||||
|
||||
if kwargs.get('poll_seconds') is not None:
|
||||
warnings.warn(
|
||||
'poll_seconds is deprecated, use poll_interval instead',
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
self.logger.warning('poll_seconds is deprecated, use poll_interval instead')
|
||||
|
||||
if self.poll_interval is None:
|
||||
self.poll_interval = kwargs['poll_seconds']
|
||||
|
|
|
@ -17,8 +17,6 @@ from typing import (
|
|||
Set,
|
||||
Union,
|
||||
)
|
||||
import warnings
|
||||
|
||||
from platypush.config import Config
|
||||
from platypush.context import get_bus
|
||||
from platypush.entities import Entity, LightEntityManager
|
||||
|
@ -86,11 +84,7 @@ class LightHuePlugin(RunnablePlugin, LightEntityManager):
|
|||
|
||||
poll_seconds = kwargs.pop('poll_seconds', None)
|
||||
if poll_seconds is not None:
|
||||
warnings.warn(
|
||||
'poll_seconds is deprecated, use poll_interval instead',
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
self.logger.warning('poll_seconds is deprecated, use poll_interval instead')
|
||||
|
||||
if poll_interval is None:
|
||||
poll_interval = poll_seconds
|
||||
|
@ -1156,12 +1150,16 @@ class LightHuePlugin(RunnablePlugin, LightEntityManager):
|
|||
temperature=entity.get('state', {}).get('ct'),
|
||||
colormode=entity.get('colormode'),
|
||||
reachable=entity.get('state', {}).get('reachable'),
|
||||
x=entity['state']['xy'][0]
|
||||
if entity.get('state', {}).get('xy')
|
||||
else None,
|
||||
y=entity['state']['xy'][1]
|
||||
if entity.get('state', {}).get('xy')
|
||||
else None,
|
||||
x=(
|
||||
entity['state']['xy'][0]
|
||||
if entity.get('state', {}).get('xy')
|
||||
else None
|
||||
),
|
||||
y=(
|
||||
entity['state']['xy'][1]
|
||||
if entity.get('state', {}).get('xy')
|
||||
else None
|
||||
),
|
||||
effect=entity.get('state', {}).get('effect'),
|
||||
**(
|
||||
{
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from collections.abc import Collection
|
||||
import time
|
||||
from typing import List, Optional, Union
|
||||
import warnings
|
||||
|
||||
from platypush.context import get_bus
|
||||
from platypush.entities.distance import DistanceSensor
|
||||
|
@ -45,10 +44,8 @@ class SensorHcsr04Plugin(GpioPlugin, SensorPlugin):
|
|||
|
||||
measurement_interval = kwargs.pop('measurement_interval', None)
|
||||
if measurement_interval is not None:
|
||||
warnings.warn(
|
||||
self.logger.warning(
|
||||
'measurement_interval is deprecated, use poll_interval instead',
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
poll_interval = measurement_interval
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from dataclasses import asdict
|
||||
import warnings
|
||||
from typing import Iterable, List, Optional, Union
|
||||
|
||||
from platypush.plugins import RunnablePlugin, action
|
||||
|
@ -184,10 +183,8 @@ class SoundPlugin(RunnablePlugin):
|
|||
blocksize = blocksize or self.output_blocksize
|
||||
|
||||
if file:
|
||||
warnings.warn(
|
||||
self.logger.warning(
|
||||
'file is deprecated, use resource instead',
|
||||
DeprecationWarning,
|
||||
stacklevel=1,
|
||||
)
|
||||
if not resource:
|
||||
resource = file
|
||||
|
@ -232,10 +229,8 @@ class SoundPlugin(RunnablePlugin):
|
|||
"""
|
||||
Deprecated alias for :meth:`.record`.
|
||||
"""
|
||||
warnings.warn(
|
||||
self.logger.warning(
|
||||
'sound.stream_recording is deprecated, use sound.record instead',
|
||||
DeprecationWarning,
|
||||
stacklevel=1,
|
||||
)
|
||||
|
||||
return self.record(*args, **kwargs)
|
||||
|
@ -319,10 +314,8 @@ class SoundPlugin(RunnablePlugin):
|
|||
"""
|
||||
Deprecated alias for :meth:`.record`.
|
||||
"""
|
||||
warnings.warn(
|
||||
self.logger.warning(
|
||||
'sound.recordplay is deprecated, use sound.record with `play_audio=True` instead',
|
||||
DeprecationWarning,
|
||||
stacklevel=1,
|
||||
)
|
||||
|
||||
kwargs['play_audio'] = True
|
||||
|
@ -398,10 +391,8 @@ class SoundPlugin(RunnablePlugin):
|
|||
Deprecated alias for :meth:`.status`.
|
||||
"""
|
||||
|
||||
warnings.warn(
|
||||
self.logger.warning(
|
||||
'sound.query_streams is deprecated, use sound.status instead',
|
||||
DeprecationWarning,
|
||||
stacklevel=1,
|
||||
)
|
||||
|
||||
return self.status()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import warnings
|
||||
import logging
|
||||
|
||||
from marshmallow import Schema, fields, pre_dump, post_dump
|
||||
|
||||
|
@ -6,6 +6,8 @@ from platypush.context import get_plugin
|
|||
|
||||
from . import MediaArtistSchema, MediaCollectionSchema, MediaVideoSchema
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class JellyfinSchema(Schema):
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -20,9 +22,10 @@ class JellyfinSchema(Schema):
|
|||
@post_dump
|
||||
def gen_img_url(self, data: dict, **_) -> dict:
|
||||
if 'image' in self.fields:
|
||||
plugin = get_plugin('media.jellyfin')
|
||||
assert plugin, 'The media.jellyfin plugin is not configured'
|
||||
data['image'] = (
|
||||
get_plugin('media.jellyfin').server
|
||||
+ f'/Items/{data["id"]}' # type: ignore
|
||||
plugin.server + f'/Items/{data["id"]}' # type: ignore
|
||||
'/Images/Primary?fillHeight=333&fillWidth=222&quality=96'
|
||||
)
|
||||
|
||||
|
@ -43,9 +46,8 @@ class JellyfinSchema(Schema):
|
|||
|
||||
if not video_format:
|
||||
if not available_containers:
|
||||
warnings.warn(
|
||||
f'The media ID {data["Id"]} has no available video containers',
|
||||
stacklevel=2,
|
||||
logger.warning(
|
||||
'The media ID %s has no available video containers', data["Id"]
|
||||
)
|
||||
|
||||
return data
|
||||
|
|
Loading…
Reference in a new issue