Commit Graph

1962 Commits

Author SHA1 Message Date
Eric Callahan a88468eb79
refactor: convert websockets into a component
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-13 15:15:15 -05:00
Eric Callahan d506c9241f
refactor: convert application into a component
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-13 15:15:14 -05:00
Eric Callahan 94b1896e28
server: add support for python dependency recovery
It is possible that older versions of Moonraker's update_manager
will fail in its attempt to update python packages.  This can lead
to missing modules when the new version of Moonraker is loaded.

When a `ModuleNotFound` error is received during a call to
"load_component" Moonraker will attempt to install its
missing dependencies.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2024-01-13 15:15:14 -05:00
Eric Callahan 01ad427d75
build: bump dependency versions
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-13 15:15:13 -05:00
Eric Callahan cf99b78489
app_deploy: use pip_utils for python package updates
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-13 15:15:13 -05:00
Eric Callahan 20871e2171
pip_utils: utilities for managing python packages via pip
This module implements both syncronous and async calls
to pip, separating it from the rest of the application.  The
syncronous implementation has no dependencies on Moonraker.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-13 15:15:12 -05:00
Eric Callahan f1de614027
shell_command: refactor retrires to attempts
This is consistent with the http_client.  The argument "attempts" is more
accurate than retries, as the first attempt is not a retry.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-11 16:51:41 -05:00
Eric Callahan eee1eda6bc
shell_command: add run_cmd_async method to factory
This builds and runs an async command request, providing
a shortcut similar to "exec_cmd".

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-11 16:51:11 -05:00
Eric Callahan 3008a13efb
update_manager: fix web_deploy persistent_files
If the destination file exists it is necessary to explicitly use
the filename to overwrite.  Otherwise an error is generated.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-10 12:00:36 -05:00
Eric Callahan ea6df41f05
gpio: fix initial state for inverted gpios
The python-periphery library XORs the initial value based on
whether or not its inverted.  This requires consumers to set
the direction to "high" for inverted pins that are off, and
"low" otherwise.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-10 06:22:39 -05:00
Eric Callahan 27a0295218
eventloop: remove deprecated uvloop method
Starting in Python 3.12 uvloop.install() is deprecated.  Directly
set the event_loop_policy as advised by the documentation.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-07 19:51:48 -05:00
Eric Callahan 6e6388d673
update_manager: fix race condition
Previously the Klipper repo location can be changed outside of
the lock.  If the location of the Klipper path is moved while an autorefresh is occurring it is possible for Moonraker to call refresh
and/or notify_update_refreshed before the repo has been initialized.

This commit moves the re-assignment of the "klipper" updated inside
the lock.  In addition AppDeploy._is_valid is now defined in the
__init__() method.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-06 11:54:33 -05:00
Eric Callahan 84a8538597
build: fix pdm build regression
Use shutil.copytree to copy folders in the "scripts" path.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-01 05:51:09 -05:00
Eric Callahan 54dc887254
build: bump zeroconf to 0.131.0
Add a local fallback link with a pure python wheel to
prevent build issues on systems where cython wheels are
not available.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-31 11:18:25 -05:00
Eric Callahan ca595163bb
server: log launch arguments:
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-29 20:13:29 -05:00
Eric Callahan 5585884d26
app: resolve soft restart issues
Clear the API cache when closing to purge stale callbacks.  In addition,
explicitly delte the server object after the eventloop stops.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-29 08:22:50 -05:00
Eric Callahan c4d15e40a8
install: speedup zeroconf install
Export SKIP_CYTHON prior to intalling Moonraker's python requirements.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-28 16:37:09 -05:00
Eric Callahan 36b5b9f4dd
update_manager: bump pip version
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-28 16:37:00 -05:00
Eric Callahan 19422819da
app_deploy: add support for pip environment vars
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-28 08:05:43 -05:00
Eric Callahan f7d5f11cf8
database: fix get_batch for older versions of lmdb
Some distros have older versions of py-lmdb installed
that do not implement "Cursor.getmulti()".  Add a  workaround for "get_batch()".

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-28 06:02:09 -05:00
Eric Callahan 5c5e91cb3d
database: log lmdb versions
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-28 05:50:03 -05:00
Eric Callahan c226e9c1e4
docs: note history changes in changelog
Singed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-27 07:48:20 -05:00
Eric Callahan 09b6a33ae4
history: add check for interrupted jobs
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-27 07:37:31 -05:00
Eric Callahan ee0c641b08
docs: update webcam documentation
Add tables specifying known values for the "icon"
and "service" options.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-24 19:44:16 -05:00
Eric Callahan cc5dea716b
docs: note gpio and button behavior changes user_changes.md
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-24 07:53:00 -05:00
Eric Callahan dbbb07c68e
confighelper: clean up warnings
Don't generate additional "unparsed option" warnings when
a component fails to load.  When an error is encountered,
include the original error message in the subsequent
ConfigError.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-23 15:22:23 -05:00
Eric Callahan ad1666bb2c
confighelper: add getgpioevent method
Use the ConfigHelper as an intermediary to register GPIO event
pins.  This allows for parsing exceptions to be captured and
properly re-raised as Config Errors.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-23 11:42:32 -05:00
Eric Callahan e620d2dcd7
gpio: improve pin parsing
Use a regular expression to parse pins.  This simplifies flag
extraction and pin verification.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-23 11:37:45 -05:00
Eric Callahan 06a3f932ba
docs: update gpio documentation
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-22 18:19:59 -05:00
Eric Callahan 2298f6b5a7
gpio: improve event debounce procedure
Use a traditional debouncing method, waiting for a specified
debounce period before triggering events.  Consumers may
choose to futher ignore events based on the the duration
between events.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-22 18:19:59 -05:00
Eric Callahan 78d7a4f560
build: remove gpiod deps, add python-periphery
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-22 18:19:58 -05:00
Eric Callahan 5d079d8c26
gpio: migrate from gpiod to python-periphery
The libgpiod library has breaks API compatibility with version 2.
Given that not all distributions ship gpiod and its unique nature
as a system package, replace it with a wrapper that directly
accesses the GPIO character device.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-22 18:19:58 -05:00
wollew 7fc571643d
power: enable HTTP port option for Zigbee/Hue devices
Signed-off-by: Wolfgang Miller-Reichling <wolfgang+github@miller-reichling.de>
2023-12-22 18:19:05 -05:00
Eric Callahan 088d9ee59a
docs: update power documentation
Note that currently only Gen 1 shelly devices are supported.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-22 16:53:52 -05:00
Eric Callahan 90e2ab6fcf
docs: add JSON-RPC over HTTP documentation
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-22 16:51:57 -05:00
Eric Callahan aa16dd671b
app: add jsonrpc HTTP endpoint
Add a POST /server/jsonrpc endpoint that processes jsonrpc
requests from the body.  This allows developers familiar with
the JSON-RPC API to use it in places where a websocket is not
desiriable.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-16 16:21:24 -05:00
Eric Callahan 6dbcdf537f
app: improve endpoint registration logging
Only log registration when verbose (debug) logging is enabled.
In addition, log endpoint removal.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-16 16:21:23 -05:00
Eric Callahan 94989b39dc
app: raise an exception on duplicate endpoint registration
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-16 16:21:23 -05:00
Eric Callahan b3b60757aa
authorization: remove "permitted_paths" attribute
Track authentication requirements in the API Definition.  This
eliminates the need to look up the authentication component
to disable auth on an endpoint.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-16 16:21:22 -05:00
Eric Callahan eed759e111
klippy_apis: allow subscription requests from transports
The default behavior of the subscribe API shares all subscription
requests.  API Transports require their own subscription.  Add
a method to facilitate this request.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-16 16:21:22 -05:00
Eric Callahan bfeb096f31
jsonrpc: share one instance among all transports
This change refactors the APIDefiniton into a dataclass, allowing
defs to be shared directly among HTTP and RPC requests.  In
addition, all transports now share one instance of JSONRPC,
removing duplicate registration.  API Defintiions are registered
with the RPC Dispatcher, and it validates the Transport type.
In addition tranports may perform their own validation prior
to request execution.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-16 16:21:21 -05:00
Eric Callahan 8b2d9b26f5
app: streamline endpoint registration
Refactor endpoint registration to reduce duplicated code.
Rename some APIDefinition attributes for clarity.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-16 16:21:21 -05:00
Eric Callahan 7de61eb113
klippy_connection: track connection state with an enum
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-16 16:21:21 -05:00
Eric Callahan b18e9cc222
all: Replace strings with RequestType flags
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-16 16:21:20 -05:00
Eric Callahan 6e8b720d17
job_state: combine events into a single handler
Emit a single event where the first argument contains
a "JobEvent" enumeration that describes the particular
event.  This reduces the number of callbacks registered
by JobState consumers and allows them react to multiple
state changes in the same callback.

The individual events remain for compatibility, however
they are deprecated.  Current modules should be updated
to use the "job_state:state_changed" event and new modules
must use this event.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-16 16:21:20 -05:00
Eric Callahan 7deb9fac4c
common: add RequestType and TransportType flags
These flags replace strings as constants used to register and
identify Request Types (ie: GET, POST) and API Transport
Types.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-16 16:21:19 -05:00
Eric Callahan 42357891a3
docs: add "check_klipper_config_path" documentation
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-16 15:31:35 -05:00
Eric Callahan 3b53d9532d
file_manager: add option to opt out of klipper check
Some installations do not have Klipper's configuration
in the data path's "config" folder.  Provide a way to
opt out of this check.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-16 15:25:38 -05:00
Eric Callahan 6d8cb762ff
file_manager: relax registration requirements
Use EAFP techniques to test for directory read permission
during registration.  If access fails continue with registration.
This allows users to potentially fix an issue without restarting.
Inotify failures always require a restart to resolve.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-15 10:53:09 -05:00
Eric Callahan 9ad8fed81e
spoolman: register announcement feed
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-02 07:44:40 -05:00