Commit graph

73 commits

Author SHA1 Message Date
c9a5c29a4a
🐛 A proper cross-version solution for the utcnow() issue.
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
2024-06-01 01:34:47 +02:00
4e82dd17bb
🐛 Partial revert of c18768e61f
`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.
2024-05-31 19:52:32 +02:00
c49b4ca273
platypush.run should also support procedures in the format procedure.<name>. 2024-05-24 20:20:25 +02:00
9cf95125a6 [WIP] Added streaming support to camera.pi using new picamera2 API 2024-02-22 22:52:52 +01:00
f6cb1fa4a7 Added utils.get_default_downloads_dir. 2023-11-03 20:54:46 +00:00
d5514d7f27 Added utils.is_debug_enabled. 2023-10-31 00:44:05 +00:00
c7acc03c8f
[inspect] Added get_enabled_plugins and get_enabled_backends actions. 2023-10-18 22:10:32 +02:00
d1afb88b80
[Reflection] Expand RST extensions from object docstrings too. 2023-10-16 00:21:49 +02:00
5726c6985f
Added utility function to get the defining class of a method. 2023-10-10 01:35:01 +02:00
52e353dc14
Expose the wrapped function in @action.
Added a `wrapped` "hidden" parameter to the function returned by the
`@action` decorator.

We need this to access the underlying decorated function when e.g. we
need to access its specs or decorators.
2023-10-09 22:35:08 +02:00
608844ca0c
[WIP] Large refactor of the inspection plugin and models. 2023-10-09 01:33:44 +02:00
343972b520
New IntegrationMetadata generic util class.
This object is in charge of parsing all the metadata of a
plugin/backend.
2023-09-30 02:28:20 +02:00
b746d0b402
Moved get_message_response to platypush.utils.
It is general-purpose enough to be used by all the integrations, not
only by the HTTP backend.
2023-09-05 13:03:30 +02:00
9aaf2559fa
Added utils.is_root method. 2023-08-31 23:21:32 +02:00
b10ccdb313
Added get_src_root utility function. 2023-08-23 02:53:31 +02:00
1825b492b3
Replaced Config.workdir with Config.get_workdir().
Again, Python < 3.9 doesn't like class properties.
2023-08-19 13:21:24 +02:00
7157936b87
Added get_remaining_timeout utility function. 2023-08-14 23:17:50 +02:00
dc1a152433
Added get_default_pid_file utility method. 2023-08-14 10:47:25 +02:00
e9a568fdd2
Unified interface to retrieve the Redis bus configuration.
A common `utils.get_redis_conf` has been created to handle the cascade
fallback logic used to retrive the default Redis configuration.
2023-07-24 01:04:13 +02:00
3e3d47aa44
Check first the configuration of the Redis plugin and then that of the backend. 2023-07-24 00:26:49 +02:00
0dc380fa94
Removed dependency from prctl.
Also, black'd and LINT-fixed some files that hadn't been touched in a
while.
2023-07-23 19:17:30 +02:00
61ea3d79e4
Large refactor for the inspect plugin.
More common logic has been extracted and all the methods and classes
have been documented and black'd.
2023-05-17 00:05:22 +02:00
42d468c895
get_lock should raise a TimeoutError if lock.acquire is False 2023-03-31 22:31:32 +02:00
1efaff878e
Rewritten serial plugin.
`backend.serial` has been removed and the polling logic merged into the
`serial` plugin.

The `serial` plugin now supports the new entity engine as well.
2023-03-31 14:31:45 +02:00
fde834c1b1
More LINT fixes + refactors 2023-02-05 22:00:50 +01:00
4849e14414
LINT fixes for the utils module + additional documentation 2023-02-05 18:05:41 +01:00
5a47308516
Merge branch 'master' into 29-generic-entities-support 2022-12-10 15:57:28 +01:00
5ba3fa1b5b FIX: Parenthesized context managers are only available in Python >= 3.10
Since Parenthesized context managers are only supported on very recent
versions of Python (thanks black for breaking back-compatibility), we
should still use the old multiline syntax - it's not worth breaking
compatibility with Python >= 3.6 and < 3.10 just to avoid typing a
backslash.
2022-12-08 12:28:36 +01:00
ba1681fc22 Merge branch 'master' into 29-generic-entities-support 2022-11-21 12:36:01 +01:00
a2c8e27bd8 Removed PyJWT dependency.
PyJWT is a very brittle and cumbersome dependency that expects several
cryptography libraries to be already installed on the system, and it can
lead to hard-to-debug errors when ported to different systems.

Moreover, it installs the whole `cryptography` package, which is several
MBs in size, takes time to compile, and it requires a Rust compiler to
be present on the target machine.

Platypush will now use the Python-native `rsa` module to handle JWT
tokens.
2022-11-21 12:30:38 +01:00
26ffc0b0e1
Use Redis instead of an in-process map to store the entity/plugin registry
This is particularly useful when we want to access the registry from
another process, like the web server or an external script.
2022-04-07 00:18:11 +02:00
1914322fda
FIX: get_plugin methods should never swallow errors in case of failed initialization 2022-02-07 01:47:38 +01:00
64c402b1c0 [#115] Added google.maps.get_travel_time method 2021-10-16 22:35:37 +02:00
3bfc5b83ef Moved to manifest files for describing plugins and backends and their dependencies 2021-09-16 17:53:40 +02:00
35c4a30a63 Added music.spotify plugin and refactored MusicPlugin 2021-07-17 22:14:15 +02:00
1f6c7aae60 get_redis() should be a general utility method 2021-06-26 11:14:26 +02:00
2a78f81a7b Major LINT fixes 2021-04-05 00:58:44 +02:00
56f8d85feb Migrated switches web panel and refactored switch plugins to expose a more consistent interface 2021-02-19 02:54:12 +01:00
b3c28f6773 Added support for JWT token-based authentication 2021-02-12 22:43:34 +01:00
Fabio Manganiello
85f56cf98c New media panel [WIP] 2021-01-14 00:15:35 +01:00
Fabio Manganiello
1c84659e34 Support for Python cronjobs in scripts folder - closes #156 2020-10-13 23:25:27 +02:00
Fabio Manganiello
c269c62fe6 Refactored logging names 2020-09-27 01:33:38 +02:00
Fabio Manganiello
09f9e974b1 Camera plugins refactor 2020-09-25 17:19:43 +02:00
Fabio Manganiello
0cd28f7499 If the response contains errors in run() then raise a RuntimeError, otherwise return the output instead of the Response object 2020-04-10 00:06:36 +02:00
Fabio Manganiello
7b79e4b669 Support for multiple positional arguments on utils.run() 2020-04-09 23:50:08 +02:00
Fabio Manganiello
0dae03551f Implemented interface for custom Python scripts, procedures and hooks [closes #131] 2020-04-08 23:22:54 +02:00
Fabio Manganiello
c3c88b23fe Added ESP8266/ESP32 integration (closes #108) 2020-01-17 21:16:14 +01:00
Fabio Manganiello
26ee3fc75c Changed nav bar text to icons 2019-07-01 22:26:04 +02:00
Fabio Manganiello
3bd9bec660 MIME type utils method now compatible with multiple version of python-magic 2019-06-21 13:40:45 +02:00
Fabio Manganiello
4cd2e6949f New media webplugin WIP 2019-06-21 02:13:14 +02:00