No need to maintain two different pieces of logic - a `utcnow()` for
Python < 3.11 and `now(datetime.UTC)` for Python >= 3.11.
`datetime.timezone.utc` existed long before datetime.UTC and that's what
the `utcnow` facade should use.
This means that all the `utcnow()` will always have `tzinfo=UTC`
regardless of the Python version.
There's still a problem with the `utcnow()`-generated timestamps that
have been generated by previous versions of Python and stored on the db.
Therefore, when the code performs comparisons with timestamps fetched
from the db, it should always explicitly do a `.replace(tzinfo=utc)` to
ensure that we always compare offset-aware datetime representations.
See blog post for technical details:
https://manganiello.blog/wheres-my-time-again
The new API no longer returns a list of numeric values alone. Instead,
it returns a tuple where the first element is the raw audio, and the
second element contains extra info on the rendered phonemes.
`datetime.utcnow` may be deprecated on Python >= 3.12, but
`datetime.UTC` isn't present on older Python versions.
Added a `platypush.utils.utcnow()` method as a workaround compatible
with both.
`assistant` contains the assistant plugin object that triggered the
event, but you can't create event hook conditions on attributes that are
plugins.
The event should also store a `plugin` attribute which contains the
unique plugin name, so hooks like these can be built:
```
from platypush import hook
from platypush.events.assistant import ConversationStartEvent
@when(ConversationStartEvent, plugin="assistant.google")
def on_google_conversation_start():
...
```
It wouldn't be possible to construct a hook condition like the one above
on the plugin object reported on the `assistant` attribute.
`datetime.utcnow` may be deprecated on Python >= 3.12, but
`datetime.UTC` isn't present on older Python versions.
Added a `platypush.utils.utcnow()` method as a workaround compatible
with both.
`assistant` contains the assistant plugin object that triggered the
event, but you can't create event hook conditions on attributes that are
plugins.
The event should also store a `plugin` attribute which contains the
unique plugin name, so hooks like these can be built:
```
from platypush import hook
from platypush.events.assistant import ConversationStartEvent
@when(ConversationStartEvent, plugin="assistant.google")
def on_google_conversation_start():
...
```
It wouldn't be possible to construct a hook condition like the one above
on the plugin object reported on the `assistant` attribute.
Even though `platypush.events` is just a symlink to
`platypush.message.event`, imports from those two modules will be
treated as different imports, thus hook conditions build on
`platypush.events` imports will never match.
Even though `platypush.events` is just a symlink to
`platypush.message.event`, imports from those two modules will be
treated as different imports, thus hook conditions build on
`platypush.events` imports will never match.
Weird errors seem to happen on Twine on that image:
```
Traceback (most recent call last):
File "/usr/bin/twine", line 5, in <module>
from twine.__main__ import main
File "/usr/lib/python3.11/site-packages/twine/__init__.py", line 32, in <module>
import importlib.metadata
File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 17, in <module>
from . import _adapters, _meta
File "/usr/lib/python3.11/importlib/metadata/_adapters.py", line 3, in <module>
import email.message
File "/usr/lib/python3.11/email/message.py", line 15, in <module>
from email import utils
File "/usr/lib/python3.11/email/utils.py", line 28, in <module>
import random
File "/usr/lib/python3.11/random.py", line 49, in <module>
from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
ImportError: Error relocating /usr/lib/python3.11/lib-dynload/math.cpython-311-x86_64-linux-musl.so: _PyModule_Add: symbol not found
```