925 Commits

Author SHA1 Message Date
Eric Callahan
994123e92e
update_manager: use ZipDeploy to instantate web types
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-21 08:24:05 -05:00
Eric Callahan
8010c51521
app_deploy: add support for web types
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-21 08:24:05 -05:00
Eric Callahan
55454a300e
zip_deploy: bring up for usage
This performs a significant refactor to the ZipDeploy class, making it near identiical to WebClientDeploy.  Zipped applications have the same
"release_info" requirement as web clients.  Unlike web clients, they may also
configure the dependency and service options available to git repos.

The ZipDeploy class can also support we clients, eliminating duplicate code
and the need to keep web_deploy.py.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-21 08:24:04 -05:00
Eric Callahan
daad786072
git_deploy: move generic dependency methods to app_deploy
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-21 08:24:04 -05:00
Eric Callahan
d410731faa
spoolman: add a status notification
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-21 08:24:03 -05:00
Eric Callahan
a5128f06ad
spoolman: add a status endpoint
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-21 08:24:02 -05:00
Eric Callahan
d4316d9878
spoolman: refactor tracking
Use a python dict to act as a queue for reporting used filament
per spool.  This eliminates the need for locks and resolves
potential issues with spool changes when the Spoolman
service is not available.

In addition, add support for tracking multiple tools

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-21 08:24:02 -05:00
Eric Callahan
3102391234
spoolman: implement alternate proxy responses
The exisiting implementation of spoolman's proxy endpoint
returns responses and errors exactly as they are received
by spoolman.  This creates a problem of ambiguity, as the
frontend cannot easily diffentiate between an error returned
by Moonraker and an error returned by Spoolman.

This implements a "v2" alternate response to proxy requests.
All requests to spoolman will return success, with responses
wrapped in a top level object.  Successful requests will be
returned in a "spoolman_response" object, errors in a
"spoolman_error" object.

Initially v2 responses will be opt-in to prevent breaking existing
spoolman implementations.  However, as of this commit the v1
response is deprecated and will be removed in a future version
of Moonraker.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-21 08:24:01 -05:00
Eric Callahan
e9ad278286
spoolman: use loop time rather than datetime
The loop time is monotonic and can't be affected by
changes to the system clock.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-21 08:24:00 -05:00
Eric Callahan
b836d618c9
spoolman: add a websocket connect
Connect to the spoolman sevice via websocket to receive
spool events.  In addition, this gives Moonraker a persistent
connection to know when the service is available.

Signed-off-by:  Eric Callahan  <arksine.code@gmail.com>
2024-01-21 08:24:00 -05:00
Eric Callahan
a23187b4af
authorization: fix access.refresh regression
Allow expired JWTs for HTTP endpoints that do not require authentication.
This is technically an error by the client, as it should not provide
invalid JWTs for an endpoint, however Moonraker previously allowed
this as the token was not verified on unathenticated endpoints.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-20 06:21:36 -05:00
Eric Callahan
66de18f9b6
spoolman: really fix type checking this time
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-16 13:57:20 -05:00
Eric Callahan
8d6def7e41
spoolman: type checking fix
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-16 13:53:21 -05:00
Eric Callahan
c196f7548c
update_manager: workaround zipfile permission issues
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-16 12:35:38 -05:00
Eric Callahan
15fed2e819
spoolman: check for deleted spools
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-16 11:57:53 -05:00
Eric Callahan
374516a00a
spoolman: remove class variables
Variables should be contained within the spoolman instance, as in the
future it could be desirable to support multiple instances.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-16 07:58:22 -05:00
Eric Callahan
c4f1d251c3
klippy_connection: add support for service info fallback
If Klipper is using systemd socket activation to generate its
unix socket the PID reported by PEERCRED will be 1, that of
systemd itself.  Klipper now reports its process id in the
"info" endpoint, use that as a fallback to retreive service info.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2024-01-15 12:20:05 -05:00
Eric Callahan
619a588683
application: add error handling to listen()
It is possible that Moonraker cannot bind to an address if its
already in use.  Handle bind errors and warn/log when they are
encountered.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-15 08:17:35 -05:00
Eric Callahan
7beca7a1a3
application: refactor HTTP routing
Moonraker dynamically registers its routes, so we cannot easily
use the routers provided by tornado.Application.  Previously
all routes went through tornado.Application, then went to
our mutable router.  This refactor avoids that by having our
mutable router contain the tornadoapp instance, only using
it to provide the application delegate.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-15 08:17:34 -05:00
Eric Callahan
35785be5dc
application: remove direct websockets import
Provide a method for websocket handler registration.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-15 06:03:43 -05:00
Eric Callahan
69f527b7c7
secrets: remove dependency on file_manager
It is desirable to use templates (and therefore secrets) in
the server's configuration options.  We need to defer loading
the "file_manager", remove its dependency from secrets.  When
the file_manager is loaded it will look up "secrets" and register
the file path as reserved.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-15 06:03:43 -05:00
Eric Callahan
60f4a82873
confighelper: avoid direct import of JinjaTemplate
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-15 06:03:35 -05:00
Eric Callahan
ddd735feba
refactor: convert klippy_connection into a component
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-13 15:15:15 -05:00
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
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
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
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
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
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
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
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
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
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
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