Commit graph

3159 commits

Author SHA1 Message Date
f0255549c8
[utils] Added utils.to_yaml action. 2023-10-18 22:50:52 +02:00
c7acc03c8f
[inspect] Added get_enabled_plugins and get_enabled_backends actions. 2023-10-18 22:10:32 +02:00
c05d887551
[application] Added application.install action.
It can be used to programmatically install extensions.
2023-10-18 19:33:00 +02:00
e2e349a2ad
[Automatic] Updated UI files 2023-10-18 01:01:06 +00:00
922297bf58
[Extensions UI] Support for initializing an extension from URL. 2023-10-18 03:00:54 +02:00
137855b4fc
[Entities UI] Fixed collapse toggling logic. 2023-10-18 03:00:54 +02:00
26b912fae4
[Execute UI]
- If an action is passed over the URL, then initialize the UI with it.

- Added link from the actions back to their plugins.
2023-10-18 03:00:54 +02:00
e5d84242bb
[Extensions UI] Action URLs now point to the Execute panel. 2023-10-18 03:00:53 +02:00
6f01c35a0f
[UI] Added utilities to get and set args on the URL fragment. 2023-10-18 03:00:53 +02:00
a30c07fbb5
[Execute UI] Make sure that the list of arguments doesn't overflow. 2023-10-18 03:00:53 +02:00
0c54c8f885
[UI] Refresh the loaded panel when the URL fragment changes. 2023-10-18 03:00:53 +02:00
6289eb47ab
[Extensions UI] Added Actions and Events sections to Doc. 2023-10-18 03:00:53 +02:00
6383030e96
[Extensions UI] Added notifications in case of install errors. 2023-10-18 03:00:52 +02:00
3107df5eba
[UI Nav] Moved Extensions panel from the plugins list to the footer. 2023-10-18 03:00:52 +02:00
81e99a0e22
[shell] Better buffering for the output sent to websockets. 2023-10-18 03:00:52 +02:00
a652bd9df8
[Extensions UI] Install extensions deps from the UI.
- Added `Install` button
- Added interactive output panel
2023-10-18 03:00:52 +02:00
033317e0a7
[Extensions UI] Passing config_file to the configuration tab. 2023-10-18 03:00:51 +02:00
66cba233e5
[config] Added config.get_config_file action. 2023-10-18 03:00:51 +02:00
20a2203e7e
[Shell plugin] Added support for async output over websockets. 2023-10-18 03:00:51 +02:00
2806e943c3
[Extensions UI] Added Install tab. 2023-10-18 03:00:51 +02:00
e40a74f11c
Added install_cmds to the JSON representation of a manifest. 2023-10-18 03:00:50 +02:00
9769520e88
[UI] Use .min.css file for the Highlight.js styles. 2023-10-18 03:00:50 +02:00
3366732fa8
[UI] Expand Tab width on mobile. 2023-10-18 03:00:50 +02:00
12f7b190b9
[Automatic] Updated UI files 2023-10-16 00:30:42 +00:00
99e98f70f4
[Integrations UI] Added configuration tab. 2023-10-16 02:30:30 +02:00
b19725c72c
[Automatic] Updated UI files 2023-10-15 23:18:08 +00:00
398d64c53f
[Integrations UI] Added new Integrations panel. 2023-10-16 01:16:10 +02:00
0055acad9d
[UI] Fixed Autocomplete behaviour on empty filter. 2023-10-16 01:12:56 +02:00
c88a9da3e6
[UI] Refactored layout classes. 2023-10-16 01:12:05 +02:00
d1afb88b80
[Reflection] Expand RST extensions from object docstrings too. 2023-10-16 00:21:49 +02:00
0fe1c2768b
[Fix] Some minor docstring indentation fixes. 2023-10-16 00:20:39 +02:00
e242b2134e
[Automatic] Updated UI files 2023-10-14 12:38:25 +00:00
3cfd72b649
[UI Nav] Ensure that entities and execute tabs are always on top. 2023-10-14 14:38:08 +02:00
6d53a3f80f
[Automatic] Updated UI files 2023-10-14 12:09:13 +00:00
a3643c285e
[UI] A friendlier representation of an integration's name. 2023-10-14 14:02:17 +02:00
0aecb50590
[Entities UI] Don't hide variables with null values.
Otherwise, the `variables` panel will still appear, but empty, and
offering no way of actually removing or resetting those variables.
2023-10-14 14:02:17 +02:00
01c7d230f1
[Entities UI] Added Expand/Collapse and Hide actions to groups.
Also, replaced all the deprecated `::v-deep` SCSS notations with
`:deep`.
2023-10-14 14:02:17 +02:00
dbe19042bc
[Automatic] Updated UI files 2023-10-13 21:13:00 +00:00
891e05a219
[Execute UI] Added syntax highlight to JSON and shell snippets. 2023-10-13 23:12:04 +02:00
8b9ac59167
parse_numpy should also catch AttributeError. 2023-10-12 03:24:03 +02:00
12f38281e1
[Automatic] Updated UI files 2023-10-12 00:58:53 +00:00
e382ad7650 Invert @ensure_initialized and @action annotations.
Otherwise, we won't be able to access the wrapped function from the
inspection logic.
2023-10-12 00:57:31 +00:00
0a13b4605e
[Execute panel] Procedures merged into actions.
Plus, a last big refactor/redesign for the panel's components.
2023-10-12 02:49:51 +02:00
e760f8e23a
[Execute panel] Introduced a common Response component. 2023-10-11 16:57:04 +02:00
b47e729012
[Execute panel] Added cURL snippet modal. 2023-10-11 16:38:38 +02:00
fc21e9740b
[Execute panel] Better rendering of responses and errors. 2023-10-11 15:28:49 +02:00
21820bb185
Big refactor of the Execute panel. 2023-10-11 14:31:46 +02:00
1b6e9b4df9
Fixed a broken docstring reference. 2023-10-10 22:18:36 +02:00
ff07623803
Auto-focus the first parameter after selecting an action. 2023-10-10 21:31:14 +02:00
07f0535504
Migrated Execute panel to the new Autocomplete widget. 2023-10-10 21:13:54 +02:00
a717235453
Added autofocus support to Autocomplete element. 2023-10-10 20:51:09 +02:00
923eb7cadb
Autocomplete is now its own component. 2023-10-10 18:42:41 +02:00
f6bf9438b9
Several improvements for the Execute panel. 2023-10-10 01:45:35 +02:00
434855ffdd
A better logic to process relative references in docstrings. 2023-10-10 01:35:37 +02:00
5726c6985f
Added utility function to get the defining class of a method. 2023-10-10 01:35:01 +02:00
2af304f478
Replaced radio buttons on the Execute panel with buttons. 2023-10-10 00:40:20 +02:00
84efef710e
Added Tabs and Tab UI elements. 2023-10-10 00:39:27 +02:00
0c818d3fe0
.. schema:: JSON arguments should be comma-separated. 2023-10-10 00:38:23 +02:00
b225b056b0
ParseContext should also process kwonlyargs. 2023-10-10 00:37:08 +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
1e93af86f4
Fixed some broken docstring references. 2023-10-09 01:33:45 +02:00
53bdcb9604
A major rewrite of the inspect plugin.
- The `inspect` plugin and the Sphinx inspection extensions now use the
  same underlying logic.

- Moved all the common inspection logic under
  `platypush.common.reflection`.

- Faster scanning of the available integrations and components through a
  pool of threads.

- Added `doc_url` parameters.

- Migrated events and responses metadata scanning logic.

- Now expanding some custom Sphinx tag instead of returning errors when
  running outside of the Sphinx context - it includes `:class:`,
  `:meth:` and `.. schema::`.
2023-10-09 01:33:45 +02:00
9acd71944c
Skip numpy types serialization errors on Message.Encoder. 2023-10-09 01:33:45 +02:00
e5a5ac5ffb
Added doc_url parameter to integration metadata. 2023-10-09 01:33:45 +02:00
d872835093
New API to check if a table class exists before defining it.
- Check if it's part of the metadata through a function call rather than
  checking `Base.metadata` in every single module.

- Make it possible to override them (mostly for doc generation logic
  that needs to be able to import those classes).

- Make it possible to extend them.
2023-10-09 01:33:44 +02:00
608844ca0c
[WIP] Large refactor of the inspection plugin and models. 2023-10-09 01:33:44 +02:00
841643f3ff
Added cachedir to configuration. 2023-10-09 01:33:44 +02:00
40557f5d5d
Replaced one more occurrence of <type> | None syntax. 2023-10-09 01:33:44 +02:00
4da3c13976
First WIP commit for the new Integrations panel. 2023-10-09 01:33:44 +02:00
4d52fd35b9
Skip None responses in the RSS plugin. 2023-10-04 22:08:11 +02:00
40d3ad1150
Removed <type> | None type hints.
They break on Python < 3.10.
2023-10-03 01:15:13 +02:00
3086dd86fc
LINT+Black+stability fixes for some plugins that hadn't been touched in a while.
- media.mplayer
- media.omxplayer
- media.vlc
- music.mpd
- music.snapcast
2023-10-01 22:55:06 +02:00
2aefc4e5c8
Several improvements for the Google integrations.
1. Improved documentation. Every plugin now reports the exact steps to
   get the integration up and running with the right API scopes.

2. All Google plugins now have a standard process to get (and reuse) the
   client secret. Except for PubSub, Translate and Maps (which have
   their own flows), all the Google plugins now read the client secrets
   from `<WORKDIR>/credentials/google/client_secret.json` by default.

3. Black/LINT for some of those plugins, which hadn't been touched in a
   while.

4. The interface to pass API scopes is now leaner. It's now possible to
   pass a scope directly as e.g. `calendar.readonly` rather than
   `https://www.googleapis.com/auth/calendar.readonly`.

5. Improved the logic to retrieve the right scope tokens file. If e.g.
   an integration requires the role `A`, and a credentials file exists
   for the roles `A` and `B`, then this file will be used rather than
   prompting the user to authenticate again.
2023-10-01 15:37:20 +02:00
5ca3757834
A more readable configuration for the calendar plugin.
The old type configuration
(`platypush.plugins.calendar.name.CalendarNamePlugin`) is a bit clunky.

Instead, since the type will always be a plugin, we should encourage
the use of `calendar.name` directly to identify the type.
2023-10-01 01:09:15 +02:00
966a6ce29e
httplib2 should be an explicit dependency for Google integrations.
Plus, some misc LINT/Black chores.
2023-10-01 00:52:59 +02:00
a7bb81553c
Regex fix. 2023-09-30 15:11:09 +02:00
9e489bb5cf
Propagate the default/required properties of a parameter upon merge. 2023-09-30 14:57:11 +02:00
1732bfa82c
Fixed _default_docstring regex. 2023-09-30 14:36:08 +02:00
532f5479b3
Added full YAML example for chat.irc configuration. 2023-09-30 14:34:54 +02:00
ecffbf29bf
Skip vararg/varkw parameters from the config snippet. 2023-09-30 13:53:33 +02:00
4f5ccda353
Better documentation for the calendar plugin. 2023-09-30 13:31:41 +02:00
c82f7bbfbe
Ignore the default docstring text for __init__.
If no docstring is specified for a constructor, Python usually pre-fills
a standard text - "Initialize self. See help(type(self))".

We don't need this default text in our plugins documentation.
2023-09-30 13:29:49 +02:00
15d06fa5c2
Improved docstring parser logic. 2023-09-30 12:35:31 +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
905d6632e0
Misc documentation improvements. 2023-09-29 18:09:15 +02:00
0a3ec4b9f1
Merge branch 'master' into 311/auto-generate-deps-docs 2023-09-28 01:25:29 +02:00
b76f141b61
Catch response write errors in the MQTT callback.
If the client that forwarded the request is no longer available (either
because an exception or a timeout was raised) then its I/O buffer and
event loop may be closed.

In this case, the response callback should handle and report the
exception, and still set the event, so that any other threads waiting
for the response can move on.
2023-09-27 11:23:55 +02:00
ca7f042ccc
We shouldn't call dateutil.parser if t has already been deserialized to a datetime. 2023-09-27 11:20:10 +02:00
c311987741
Removed typing.Final from some of the most commonly used modules.
`typing.Final` is not defined on Python < 3.8.
2023-09-26 23:50:10 +02:00
9298f52443
Moved BluetoothPlugin to __init__.py.
This is for consistency with other plugins, that all have their main
plugin class definition inside of `__init__.py`.
2023-09-24 19:21:53 +02:00
c3337ccc6c
[#311] Docs deps autogen sphinx plugin.
Added an `add_dependencies` plugin to the Sphinx build process that
parses the manifest files of the scanned backends and plugins and
automatically generates the documentation for the required dependencies
and triggered events.

This means that those dependencies are no longer required to be listed
in the docstring of the class itself.

Also in this commit:

- Black/LINT for some integrations that hadn't been touched in a long
  time.

- Deleted some leftovers from previous refactors (deprecated
  `backend.mqtt`, `backend.zwave.mqtt`, `backend.http.request.rss`).

- Deleted deprecated `inotify` backend - replaced by `file.monitor` (see
  #289).
2023-09-24 17:00:08 +02:00
059f7a4b11 Merge branch 'master' into 316/rpm-support 2023-09-23 16:21:48 +02:00
2b981f6b68
Added python-croniter dependency to Fedora.
Plus, some clean up of the variables on .drone.yaml.
2023-09-23 16:20:28 +02:00
b797add90d
Modify shebang header for Mercury JS script.
The RPM build process wants an absolute path.
2023-09-23 16:16:13 +02:00
a872d6f554
Added Fedora to the available Docker base images. 2023-09-22 19:02:13 +02:00
79e24461cb
Coalesce to empty list if zigbee.mqtt.devices returns null. 2023-09-22 17:00:53 +02:00
55965e962c
Store the Philips Hue bridge configuration under our workdir.
By default, the `phue` library will store the file containing the token
and the bridge configuration under `~/.python_hue`.

That's outside of our application folder, and it can't easily be copied
around or added to Docker volumes.

We should instead have it under `<WORKDIR>/light.hue/config.json`, in
line with what the other plugins do, and if `~/.python_hue` is available
but `<WORKDIR>/light.hue/config.json` isn't then we should copy the
legacy file to the new one.
2023-09-22 16:58:44 +02:00
761f2768cb
[#316] Added RPM dependencies. 2023-09-21 23:20:06 +02:00
453b6becae
FIX: We shouldn't expand cfgfile if it's empty. 2023-09-21 01:18:15 +02:00
bdbe263905
Added croniter to system dependencies.
The python-croniter package has now been added both to Arch's and
Debian's official repos, so we can install it via pacman or apt rather
than pip.
2023-09-21 01:07:49 +02:00
648b4224bb
[#285] Removed old covid19 backend.
Those endpoints aren't even working anymore.

Closes: #285
2023-09-21 00:26:35 +02:00
5d6d37785e
[#288] Removed legacy http.poll backend.
Closes: #288
2023-09-20 23:53:12 +02:00
7ba9a8930a
[#291] Removed deprecated light.hue backend.
Closes: #291
2023-09-20 23:46:40 +02:00
a6efaad26d
[#306] Removed Travis CI integration.
I've tried my best to keep it around, but the endpoints seem to be
broken, they no longer have a link to their API v3 documentation, and
the API Explorer that was supposed to be in the dashboard is gone.
2023-09-20 23:31:58 +02:00
3970470e17 Removed typing-inspect dependenccy 2023-09-18 14:25:50 +02:00
3e8d6bb01e Removed typing-extensions dependency.
The package isn't present on older versions of Debian.
2023-09-18 14:05:39 +02:00
07c88c9530
Added logic to prevent socket leakage from paho-mqtt upon client stop. 2023-09-17 23:43:56 +02:00
3f4168eb69
Support for new Quality enumeration constants on tidalapi. 2023-09-17 22:40:26 +02:00
c6cda86b1c
LINT/regex fix for ESP plugin. 2023-09-17 17:10:40 +02:00
4c4a33dc7c
Added Bluetooth example configuration to sample config.yaml. 2023-09-17 03:25:21 +02:00
46167a6c2a
Removed legacy zwave backend. 2023-09-17 02:46:24 +02:00
190cfa21b5
Fixed documentation references to some non-existing events. 2023-09-17 02:41:55 +02:00
0421325b26
Support to register/unregister custom handlers on the bus. 2023-09-17 02:29:11 +02:00
2e004c1a1e
get_all_plugins should use Message.Encoder for encoding the response.
Some plugin information may include enums, tuples and other types that
aren't serializable by the default JSON serializer.
2023-09-17 02:11:52 +02:00
fa2b84a269
Updated example configuration for mqtt and mqtt-based plugins. 2023-09-16 15:26:07 +02:00
2fcd623c51
Migrated zwave.mqtt integration.
Merged the zwave.mqtt plugin with the listener and removed the
leftovers of the legacy zwave plugin.
2023-09-16 03:58:19 +02:00
52cb1afb4b
Don't break words in entity value frames. 2023-09-16 02:58:17 +02:00
e947cb1e67
Updated web dist files 2023-09-15 16:22:40 +02:00
4223576016
We should always update the entities cache on addEntity.
Updating the entity cache only when we receive an event from a root
entity means that we lose events sent by individual child entities.
2023-09-15 00:45:38 +02:00
1020b63da7
All EntityMixin components should be allowed to emit loading events. 2023-09-15 00:34:29 +02:00
2c93049ee5
Catch all the exceptions in a plugin action wrapper.
The @action decorator should capture all the exceptions,
log them and return them on `Response.errors`.

This ensures that uncaught exceptions from plugin
actions won't unwind out of control, and also that they
are logged and treated consistently across all the
integrations.
2023-09-14 23:08:23 +02:00
ac72b2f7a8
Fixed management of state on zigbee.mqtt.
Before the merge of the plugin and the listener those components
used to have their own separate state, which led to inconsistencies.
2023-09-14 23:05:27 +02:00
5a514fdcce
Only support the run_topic logic on the MQTT plugin.
Plugins that extend `MqttPlugin` shouldn't run messages as
requests, even if the parent MQTT plugin is configured to
do so.
2023-09-14 01:09:03 +02:00
4cb5aa7acb
Prepend the class name to the string used to generate the MQTT client_id hash.
If we include the class name by default then we won't have to
explicitly modify the client_id in the implementation classes
in order to prevent clashes.
2023-09-14 01:06:53 +02:00
3104a59f44
Better processing of configuration file parameters.
- Do `abspath`+`expanduser` on the configuration file path before
  checking if it exists.

- If the path doesn't exist, but the user explicitly passed a
  configuration file, then copy/create the default configuration
  under the specified directory.
2023-09-14 00:24:52 +02:00
ddd8f1afdc
base_topic param in zigbee.mqtt renamed to topic_prefix.
This is for sake of consistency with other integrations (like
`zwave.mqtt`) that also use the same parameter name for the MQTT topic
prefix.
2023-09-07 21:32:56 +02:00
8ab7b6bebc
Removed deprecated zigbee.mqtt backend.
Closes: #322
2023-09-06 02:54:48 +02:00
3de510da68
Migrated zigbee.mqtt integration.
The plugin has been migrated to the new `mqtt` API and the legacy
listener that extended `MqttBackend` has been removed and merged into
the plugin.
2023-09-06 02:44:56 +02:00
33a1ef39e4
Refactored and merged backend.mqtt logic into mqtt plugin. 2023-09-06 02:43:45 +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
f1acff00e9
Put the join back on CommandStream.__exit__.
We want to give the process a bit of slack between the terminate and the
close, or we'll be guaranteed to get race conditions upon close.
2023-09-04 11:01:34 +02:00
b3c82fe0d1
More resilient termination logic for CommandStream. 2023-09-04 02:47:18 +02:00
c69f97c0a5
Updated default config.yaml.
The new configuration:

- Enables `backend.http` by default
- Removes the extra `config.auto.yaml` dependency
- Includes many more examples, lots of updates for existing examples,
  and extensive comments.
2023-09-04 02:22:46 +02:00
07c2eee890
Changed (fixed) default location for config dir if not existing.
Following some common UNIX conventions, if no configuration file is
specified and none exists under the default locations, then a new
configuration directory should be created under:

```
- if root: /etc/platypush
- else:
  - if XDG_CONFIG_HOME:
    - $XDG_CONFIG_HOME/platypush
  - else:
    - ~/.config/platypush
```
2023-09-04 02:19:13 +02:00
b6c0ff799b
Rewritten the http.webpage plugin. 2023-09-03 17:33:25 +02:00
669f2eb2d2
LINT/black for tts.mimic3 plugin. 2023-09-02 12:40:34 +02:00
snyk-bot
46c40f6fa6
fix: upgrade sass from 1.64.2 to 1.65.1
Snyk has created this PR to upgrade sass from 1.64.2 to 1.65.1.

See this package in npm:
https://www.npmjs.com/package/sass

See this project in Snyk:
https://app.snyk.io/org/blacklight/project/96bfd125-5816-4d9e-83c6-94d1569ab0f1?utm_source=github&utm_medium=referral&page=upgrade-pr
2023-09-01 23:15:47 +00:00
35416f3ee3
Some LINT on the old http.request.rss plugin. 2023-09-02 01:01:16 +02:00
9aaf2559fa
Added utils.is_root method. 2023-08-31 23:21:32 +02:00
e6b5abe909
Added SIGTERM handler for clean termination in Docker contexts. 2023-08-31 02:09:23 +02:00
4dd713ffd2
Refactored Platydock and Platyvenv.
The two scripts now share the same command interface, behaviour and base
class.

Also, Platydock now builds a Docker image instead of just printing a
Dockerfile, unless the `--print` option is passed.
2023-08-31 01:16:56 +02:00
429658e7c8
Refactored PackageManager classes.
Instead of having a custom `get_installed` callable field, with
replicated code for each package manager, the field has now been
promoted to a class method containing the common logic, and the
instances now expect a `list` field (base command to list the installed
packages using the specified package manager) and a `parse_list_line`
callback field (to extract the base package name given a raw line from
the command above).

Also, we shouldn't run the list command if we're running within a Docker
context - the host and container environments will be different.
2023-08-28 01:26:19 +02:00
86e5f74645
platyvenv should generate (and document) a run.sh helper script. 2023-08-27 23:20:03 +02:00
9e6430a9ac Clone git repo if platyvenv is not running from a srcdir 2023-08-23 20:02:04 +02:00
dafd65dc21
Added new platyvenv Python script. 2023-08-23 11:55:25 +02:00
f230fa79bb
to_pkg_install_commands should skip already installed sys packages. 2023-08-23 11:51:53 +02:00
449821673c
Added PackageManager.get_installed. 2023-08-23 10:50:29 +02:00
b10ccdb313
Added get_src_root utility function. 2023-08-23 02:53:31 +02:00
1ef0d804db
Added full_command argument to to_pip_install_commands.
This is useful if we just want to get the list of pip dependencies and
create our own pip command.
2023-08-23 02:19:54 +02:00
2bff4c9cf1
Exclude python-* system packages when installing in a venv. 2023-08-23 02:17:19 +02:00