Commit Graph

1296 Commits

Author SHA1 Message Date
Eric Callahan 1327602ec3 secrets: add support for the data folder
The secrets module will now look for "moonraker.secrets"
in the data folder.  If the file does not exist the deprecated
"secrets_path" option will be used as a fallback.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-10-14 15:15:41 -04:00
Eric Callahan 524552eb84 database: add support for the data folder
Deprecate the "database_path" option.  If the database
does not exist, however the "database_path" does, it
will be used as a fallback.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-10-14 15:15:41 -04:00
Eric Callahan 480ebfac8e file_manager: add support for new "data_path"
The config and logs paths are no longer configurable,
they all exist as folders or symbolic links within the primary
data folder.  The gcode path no longer relies on Klipper to
specify the location, instead Klipper's virtual_sdcard path
shold be configured to the location of the "gcodes" folder
in the data path.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-10-14 15:15:41 -04:00
Eric Callahan b78cdf9660 moonraker: add data_path and alias command line arguments
Prepare to move away from configurable paths.  This will
resolve potential security vulnerabilities in the event that
a user's access is compromised.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-10-14 15:15:41 -04:00
Eric Callahan 91e48200d6
simplyprint: implement direct layer detection
Klipper now has the ability to report the current layer on
properly configured slicers.  Prefer this value if available,
otherwise fall back to layer detection.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-10-11 19:29:36 -04:00
Eric Callahan c48fe7307a
job_state: add layer_changed event
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-10-11 19:29:36 -04:00
Eric Callahan 48674a46e1
simplyprint: add support for configured ambient sensors
Users may specify a dedicated ambient sensor in the
[simplyprint] configuration.  If the specified sensor is
invalid or no sensor is specified ambient detection
will fall back to an estimate using the extruder.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-10-11 19:29:36 -04:00
Eric Callahan 785213b2b3
simplyprint: bring up AI stream to correct state
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-10-11 18:01:57 -04:00
Eric Callahan 6e121c2221
simplyprint: implement "webcam_stream" demand
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-10-11 06:07:32 -04:00
Eric Callahan d5fa40df87
simplyprint: implement ping timer
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-10-11 06:07:32 -04:00
Eric Callahan f8d15d3baa
simplyprint: remove keepalive
This will be replaced by a custom ping timer to the backend.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-10-11 06:07:31 -04:00
Eric Callahan 2e3188a48b
klippy_connection: socket credential fix
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-10-11 06:06:19 -04:00
Mathis Mensing cd19b51117 app: add jpg files to AUTHORIZED_EXTS
Signed-off-by: Mathis Mensing <github@matmen.dev>
2022-10-10 19:41:30 -04:00
Pedro Lamas 60b871adbe metadata: strip delimiting quotes in strings
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
2022-09-27 06:08:34 -04:00
SoftFever df24e3ea77 metadata: Add support to extract metadata from g-code files generated by Bambu Studio
Signed-off-by: Li Jiang <softfeverever@gmail.com>
2022-09-22 06:00:45 -04:00
Rogerio Goncalves 4806ffd2ae proc_stats: expose network packets, errors and drops
Signed-off-by: Rogerio Goncalves <rogerlz@gmail.com>
2022-09-21 05:38:06 -04:00
pataar 21bb17743f notify: add ability to notify using a remote action
Signed-off-by: Pieter Willekens <me@pataar.nl>
2022-09-21 05:36:55 -04:00
Eric Callahan 5d856b9c49
simplyprint: suppress write exceptions
Its possible for the websocket client to disconnect before
read_message() returns None.   Await all calls to write_message()
to handle websocket closed exceptions.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-09-05 05:59:02 -04:00
Eric Callahan d04e99a8ec
simplyprint: automated file reset bugfix
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-28 13:45:21 -04:00
Eric Callahan 7f2d43de3d
simplyprint: automate file reset for sp uploads
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-28 12:23:03 -04:00
Eric Callahan 3a03f48e0f
simplyprint: report error messages
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-28 11:16:52 -04:00
Eric Callahan 25e79c78b2
klippy_connection: report Klippy's state message
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-28 11:16:52 -04:00
Eric Callahan b52b0bd98a
webcam: improve default host handling
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-28 11:16:51 -04:00
Eric Callahan e8999363ed
confighelper: raise duplicate exceptions
Moonraker requires that the configuration be parsed in 'strict' mode,
ie: duplicate sections are not allowed within the same file and duplicate
options are not allowed within the same section.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-28 11:16:51 -04:00
Grant Harding 78605db001
webcam: fixed rotation param
Signed-off-by: Grant Harding gharding@gmail.com
2022-08-28 11:16:02 -04:00
Eric Callahan db7474aa88
machine: use sudo password for commands if available
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 06:30:28 -04:00
Eric Callahan 272f7b946d
machine: add endpoint to check sudo access
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:59:38 -04:00
Eric Callahan 59403e226b
git_deploy: line length fix
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:54:48 -04:00
Eric Callahan 25d99207f0
authorization: implement permitted path registration
Allow components to register paths that bypass authentication
requirements.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:25:20 -04:00
Eric Callahan fd5053ecac
app: improve debug logging
Dont log the full response when html is requested.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:22:23 -04:00
Eric Callahan 2314ea74c2
app: report asset path location
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:22:18 -04:00
Eric Callahan 942d595bc2
websockets: static type fix
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:21:56 -04:00
Eric Callahan e82fe46c11
moonraker: provide startup warnings as a list
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:20:58 -04:00
Eric Callahan 0d936d5af0
moonraker: track warnings by id
This makes it possible to remove warnings and prevent duplicates.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:20:33 -04:00
Eric Callahan 0dd8eee034
confighelper: add method to write the config to any folder
Signed-off-by:  Eric Callahan <arksine.cod@gmail.com>
2022-08-21 05:19:27 -04:00
Eric Callahan a4f9fbe298
confighelper: support config modification
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:19:12 -04:00
Eric Callahan a776f1f6dc
git_deploy: improved moved origin handling
Query the detected url and make sure it redirects to the
expected url.  This closes a security vulnerability
where a remote could be changed to an arbitrary repo's url.

The `moved_origin` option is no longer necessary, however it
is currently used as an additional check.  In the future it will be
deprecated.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:18:44 -04:00
Eric Callahan 4b25b04c4f
git_deploy: refuse recovery if repo is not verified
Close a security hole where an attacker could overwrite an existing repo
with any remote and run malicious code through an update.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:18:38 -04:00
Eric Callahan b5e7a5ba5a
update_manager: resolve pip location issues
If the supplied python executable is a symbolic link attempt
to read the location at which it points.   If this is a virtualenv
this should give us the correct pip location.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:18:16 -04:00
Eric Callahan c24fd7d11c
template: add support for UI templates
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:17:57 -04:00
Eric Callahan b7768671aa
http_client: report final resolved url in response
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:17:36 -04:00
Eric Callahan 12161d12f5
machine: improve private ip detection
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:16:06 -04:00
Eric Callahan 4efb6575b7
machine: report provider type and container info
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:15:19 -04:00
Eric Callahan c154d92499
machine: add support for setting a sudo password
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:13:44 -04:00
Eric Callahan a7b50a8068
machine: extract moonraker systemd unit info
This allows moonraker to validate and log the current unit file.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:13:31 -04:00
Eric Callahan cd24b116c6
utils: resolve the moonraker path to an absolute path
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:13:04 -04:00
Eric Callahan 66f9184c74
zeroconf: support binding to all interfaces
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-19 17:38:22 -04:00
Eric Callahan 97c8b05eee
app: support binding to all interfaces
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-19 12:21:41 -04:00
Eric Callahan 853de9e8cb
update_manager: resolve potential deadlocks on startup
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-18 07:17:54 -04:00
Eric Callahan 413e3b2f4f
simplyprint: add power device fallback
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-08 19:48:13 -04:00
Eric Callahan 3424f1b3e2
machine: fix IP detection broadcast setting
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-08 19:26:19 -04:00
Eric Callahan c4e370fcff
machine: improve LAN IP detection
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-08 19:20:56 -04:00
Pedro Lamas 8bbd269084 metadata: adds chamber temp support
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
2022-08-08 17:56:27 -04:00
Eric Callahan a9345d19fa
simplyprint: fix incorrect directive
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-08 17:37:35 -04:00
Eric Callahan 39f26dc31a
simplyprint: silence stream errors
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2022-08-08 17:02:20 -04:00
Eric Callahan 6e253b0d42
webcam: fix default host fallback
Fallback to the loopback if unable to determine the
local ip address.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-08 16:55:59 -04:00
Eric Callahan 0188b81d4a
dbus_manager: verify stat path exists
Signed-off-by:  Eric Callahan  <arksine.code@gmail.com>
2022-08-01 10:22:16 -04:00
Eric Callahan e0cf635d34
simplyprint: websocket write fix
Gracefully handle websocket closed conditions.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-07-30 15:16:52 -04:00
Eric Callahan c251a9d7ed
simplyprint: initial implementation
This adds initial support for connecting Moonraker to the SimplyPrint
service.  Currently the connection defaults to SimplyPrint's dev/test
endpoint, this will be changed prior to official release.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-07-28 08:06:49 -04:00
Eric Callahan cd8954e36c
metadata: Add support for Kiri:Moto and SimplyPrint
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-07-27 07:59:07 -04:00
Eric Callahan e264fa82b2
confighelper: don't overwrite option tracking
Its possible for any component to request a configuration
option from another component.  Don't overwrite the
inital value stored.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-07-26 19:34:40 -04:00
Eric Callahan a178a6cd01
confighelper: improve file parsing
Process included files in the order they are added.  This changes how
duplicate sections throughout included files are merged, options in
the last section to be parsed will take precedent.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-07-26 19:34:39 -04:00
Eric Callahan bdd0222a1c
machine: handle exception if iwgetid fails
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-07-24 17:16:34 -04:00
Eric Callahan 6b4020a6e9
moonraker: load webcam as a core component
This makes sure that the webcam APIs are always available.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-07-24 11:27:30 -04:00
Eric Callahan a3cae26e33
webcam: initial implememtation
The webcam module allows users to enter webcam configuration through
moonraker.conf while keeping compatibility with frontends that
store webcam data in the database.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-07-24 11:27:29 -04:00
Frank Tackitt 7cd29c068d
authorization: set private network CORS header
In the future, an `Access-Control-Request-Private-Network` header will be sent with
 these requests, and servers must respond with `Access-Control-Allow-Private-Network`.

This will start with the next Chrome version (104), and Mozilla has marked the
 standard as "worth prototyping", which often leads to final implementation.

Signed-off-by: Franklyn Tackitt <git@frank.af>
2022-07-19 14:25:18 -04:00
olli-t 9fea1634b1
power: fix Hue implementation
Signed-off-by: Oliver Tetz olli.codes.some.lines@gmail.com
2022-07-18 08:17:16 -04:00
Eric Callahan bcb7a55996
power: fix type/checking formatting for Hue device
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-07-17 06:38:38 -04:00
lie_ink 4d803ec9e5
power: add support for hue devices
Signed-off-by: Oliver Tetz <olli.codes.some.lines@gmail.com>
2022-07-17 06:26:26 -04:00
Eric Callahan 3080885257
update_manager: change default refresh interval
Check for updates every 7 days rather than every 28 days.  This
is in preparation of an upcoming beta release.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-07-17 06:13:50 -04:00
Eric Callahan 53a3c64186
moonraker: move loop creation to the eventloop module
Python 3.10 deprecates "get_event_loop()", so it is necessary to
create a new loop and set it as active at startup.  Previously
Moonraker only did this after a soft restart.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-07-16 19:41:09 -04:00
Eric Callahan d37f91c9c8
power: type checking fix
For legacy purposes its possible that "initialize()" may be an
awaitable.   Ignore the type as it consues mypy.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-29 12:06:36 -04:00
Eric Callahan 31d4335e3e
power: allow indefinite remote device init
Remote devices, such as the tplink smartplug and http
based devices, may not be immediately available when
Moonraker starts.  Previously this would result in an error.

Remote switches that requiring polling for state will now
reattempt initialization indefinitely.  This behavior brings
them in line with devices that are updated asynchronously.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-29 08:07:46 -04:00
Eric Callahan 835e49c10e
klippy_connection: log raw peercred data on error
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-29 06:01:48 -04:00
Eric Callahan 0a0993f9e0
server: sleep 1ms after calling component close methods
This allows any cancelled tasks to run through the eventloop
before loop.stop() is called.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2022-06-28 19:21:21 -04:00
Eric Callahan 09550af466
mqtt: resolve connection blocking issues
Override the paho-mqtt client "reconnect()" method with
a method capable of taking a connected socket.  This allows
Moonraker to connect the socket asynchronously, then finish
establishing the connection.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-28 19:21:21 -04:00
Eric Callahan 0b31d7d0b2
eventloop: add async create socket method
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-28 18:25:16 -04:00
Eric Callahan 371840a988
klippy_connection: increase the read buffer limit
Allow a buffer of up to 20 MiB to cover the reception of
a very large request.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-27 10:51:56 -04:00
Eric Callahan 1eaead1073
server: handle event exceptions
Don't allow exceptions to propagate beyond a call to
_process_event().  Make sure the future is not marked
as done prior to setting the result.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-27 10:51:49 -04:00
Eric Callahan 4bed314b0a
authorizaton: fix static type checks
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-17 17:56:47 -04:00
Eric Callahan 8266376f46
authorization: fix minor typing issues
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-17 17:07:58 -04:00
Luca Schöneberg 58fa361c8c
authorization: implement /access/info endpoint
Signed-off-by: Luca Schöneberg <luca-schoeneberg@outlook.com>
2022-06-17 11:19:12 -04:00
Eric Callahan d19471fd4d
announcements: implement list feeds endpoint
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-12 06:10:29 -04:00
Eric Callahan 14ec8472ef
ldap: fix group validation
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-11 17:06:54 -04:00
Eric Callahan 7780a8a09e
authorization: add ldap support
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-10 11:19:52 -04:00
Eric Callahan f52df8c7ed
ldap: initial implementation
Introduce an ldap component that can be used authenticate
Moonraker users over ldap connections.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-10 11:19:52 -04:00
Eric Callahan 5081321a32
Revert "authorization: add LDAP support"
This reverts commit a86cbc77f6.
2022-06-08 06:23:19 -04:00
Eric Callahan 250b93e89c
git_deploy: fix install script parsing
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-08 06:13:17 -04:00
Eric Callahan 3b76d81155
machine: add sonar and crowsnest to allowed services
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-06-07 06:51:40 -04:00
Luca Schöneberg a86cbc77f6
authorization: add LDAP support
Signed-off-by: Luca Schöneberg luca-schoeneberg@outlook.com
2022-06-07 06:46:08 -04:00
Eric Callahan 74d6e35166
Revert "job_queue: always initialize state to "ready""
This reverts commit d53cf27264.
2022-06-01 17:37:03 -04:00
Eric Callahan d53cf27264
job_queue: always initialize state to "ready"
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-05-22 06:02:46 -04:00
Eric Callahan f15ec23c3a
http_client: increase max body size
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-05-21 06:27:56 -04:00
Eric Callahan 0164bb239e
klippy_connection: fix bug during initialization
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-05-13 05:23:06 -04:00
Eric Callahan babfba1686
mqtt: allow unlimited connection attempts
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-05-12 19:37:33 -04:00
Eric Callahan 09ac00ce2e
klippy_connection: request endpoints before setting the state
All of Klipper's endpoints should be available before Moonraker
reports the "ready" state.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-05-12 19:22:56 -04:00
Pierre Bedell 3d9f5dc6d9 metadata: expanded IceSL's support
Signed-off-by: Pierre Bedell pierre.bedell@gmail.com
2022-05-09 12:22:20 -04:00
Richard Mitchell 56097a35ad
wled: Add extra control for wled effects
For the "Percent" preset the intensity controls the amount of the bar lit up 0-100
Work around issue when preset is re-enabled if sending intensity or speed while no preset is active

Removed control endpoint
Added missed toggle endpoint
Transition time to 0 for control changes

Signed-off-by:  Richard Mitchell <richardjm+moonraker@gmail.com>
2022-05-09 06:32:14 -04:00
Eric Callahan cd520ba917
http_client: immediately raise cancelled errors
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-23 14:55:49 -04:00
Eric Callahan 11beaa7076
metadata: read metadata after object processing
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-21 10:28:45 -04:00
Eric Callahan 6f2ce72b4c
metadata: add a UUID to extracted metadata
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-21 06:47:31 -04:00
Eric Callahan c1eda1ef3d
http_client: modify download progress reporting
Report progress for each percentage change.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-21 06:37:52 -04:00
Eric Callahan f8a38abc89
confighelper: Update the help url for moved options
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-20 07:13:26 -04:00
Eric Callahan 4be8e2e72f
database: fix decode exception handler
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-19 10:59:38 -04:00
Eric Callahan 65946ef857
job_queue: increase ready job delay
Delay for a full second before processing a job after
Klippy reports ready.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-19 06:23:02 -04:00
Eric Callahan bbd5d8a1a1
history: add logging
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-19 06:22:58 -04:00
Eric Callahan 430c2550c5
job_state: add logging
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-19 06:18:42 -04:00
Eric Callahan fe84226908
klippy_connection: log klippy version as received
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-19 06:18:32 -04:00
Eric Callahan d3003a1584
machine: return default values for find public interface
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-15 17:27:36 -04:00
Eric Callahan 4666458793
websockets: simplify JSON-RPC execution
To accommodate access to multiple protocols Moonraker will always
require that the "params" field contain a dictionary, so reject any
other type as invalid.  There is no need to expand keyword arguments,
simply pass the params dict to the callback.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-10 14:17:27 -04:00
Eric Callahan da864ab391
websockets: only allow connections to identify once
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-10 14:17:26 -04:00
Eric Callahan cbc02d625c
websockets: add agent registration
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-10 14:17:26 -04:00
Eric Callahan a79e0eeef2
moonraker: add extensions to core components
Bump the API patch version with the addition of the extension
APIs.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-10 14:17:26 -04:00
Eric Callahan 236a7a7736
extensions: initial implementation
Add basic support "agents", ie: unmanaged extensions.  Connected
agents are granted a limited ability to emit websocket notifications
and process rpc requests from Moonraker.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-10 14:17:25 -04:00
Eric Callahan 1133c296b1
websockets: implement notification masking
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-10 14:17:25 -04:00
Eric Callahan d5a55047ab
websockets: fix status codes
HTTP 404 and JSON-RPC -32601 are equivalent, so translate
where necessary.  Any other JRPC code received outside of the
HTTP error range should be assigned a 500.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-10 14:17:25 -04:00
Eric Callahan f6876c15e4
websockets: add ability to call ws client methods
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-10 14:17:24 -04:00
Eric Callahan 3a21e9d6f0
websockets: add default values for client data
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-10 14:17:24 -04:00
Eric Callahan 7631999c8f
klippy_connection: handle credential exceptions
Handle exceptions should the attempt to fetch peer
credentials on the unix socket fail.  This isn't a hard
requirement for connection and should not cause
the connection to abort.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-08 14:37:11 -04:00
Eric Callahan b21f909705
klippy_connection: get unix socket peer credentials
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-08 14:21:17 -04:00
Eric Callahan eb6aeddf78
update_manager: detect divergent remotes
If a repo's remote has diverged then a reset is necessary as the
attempt to pull will fail.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-07 08:25:26 -04:00
Eric Callahan 536871ad18
moonraker: bump API Version to 1.0.4
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-06 08:26:33 -04:00
Eric Callahan 77027d252e
moonraker: always log configuration exceptions
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-06 08:26:32 -04:00
Eric Callahan bf19bcecae
moonraker: report additional configuration info
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-06 08:26:32 -04:00
Eric Callahan fc6714b30d
confighelper: backup the entire configuraiton
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-06 08:26:32 -04:00
Eric Callahan ad00e08d11
confighelper: add support for include directives
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-06 08:26:31 -04:00
Eric Callahan 2e4814978f
app: shallow copy arguments before passing to a request
This prevents a scenario where a request handler mutates
the arguments of a WebRequest, which could result in
changing the default "request_arguments" in
"InternalTransport.call_method()".

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-05 15:48:36 -04:00
Eric Callahan fb2eacf702
confighelper: make parsed a required argument
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-05 15:48:36 -04:00
Eric Callahan ea25cce38f
confighelper: require core component sections
This is a reimplementation of commit d61540cad5,
however this attempt provides a fallback for legacy configurations
that still have configuration in the server section.

This will change how `/server/config` reports configuration.  Options
will always be reported in their respective component's field, even if
they are currently configured in the `[server]` section.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-05 15:48:34 -04:00
Eric Callahan f27daac4f4
confighelper: remove "orig section" tracking
This isn't necessary as we don't add new sections to the
original config object when parsing supplemental data.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 20:45:17 -04:00
Eric Callahan ac6cf0fac7
Revert "confighelper: match core components to their configuration"
This reverts commit d61540cad5.
2022-04-04 20:31:23 -04:00
Eric Callahan 7692197678
Revert "confighelper: remove "orig section" tracking"
This reverts commit 9c33eb225c.
2022-04-04 20:31:06 -04:00
Eric Callahan 366e68c8f4
klippy_connection: send an event when gcode commands are received
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 17:18:54 -04:00
Eric Callahan fe3b7456f6
klippy_apis: add pause, resume and cancel print method
These methods may be called internally, which invoke the associated
events.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 17:18:54 -04:00
Eric Callahan e05aeac884
proc_stats: report system memory usage
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 17:18:50 -04:00
Eric Callahan 071a430159
klippy_apis: send events on pause, resume, and cancel requests
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 17:18:04 -04:00
Eric Callahan 7c1d6a8f24
websockets: emit added, removed, and identified events
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 17:18:03 -04:00
Eric Callahan 18169f279e
file_manager: add get_directory method
This replaces the previous "get_sd_directory()" method, allowing
consumers to get any registered root path.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 17:18:03 -04:00
Eric Callahan 393cfa2a0e
machine: implement get_public_network method
This allows components to determine the current local
ip address that routes to the internet.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 17:18:02 -04:00
Eric Callahan 9c33eb225c
confighelper: remove "orig section" tracking
This isn't necessary as we don't add new sections to the
original config object when parsing supplemental data.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 15:26:16 -04:00
Eric Callahan d61540cad5
confighelper: match core components to their configuration
Most core components have default options that allow them to
load without a section specified in moonraker.conf.  This resulted
in those options showing up in the [server] section in the
"/server/config" response.  These changes will make sure that those
values show up in the correct section.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 15:16:25 -04:00
Eric Callahan 72a85e08d4
update_manager: refactor extension instantation
Don't allow extension errors to propagate, warn and continue
loading the module instead.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 11:46:24 -04:00
Eric Callahan 238b08ea1f
update_manager: bind Klipper beta updates to Moonraker
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 11:46:23 -04:00
Eric Callahan 6afc70a9f5
update_manager: add support for beta git updates
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 11:46:23 -04:00
Eric Callahan 03934d8d81
update_manager: deprecate web_beta type
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 11:46:23 -04:00
Eric Callahan 58ea3cfdc7
update_manager: deprecate zip beta type
Use the "channel" option to specify a beta.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 11:46:22 -04:00
Eric Callahan f965ce8fd8
git_deploy: refactor tag retrieval
Use git for-each-ref to retreive tags and their associated commit
hashes.  This allows us to limit the amount of tags to 10 and
simplifies the code as the returned objects are already dereferenced.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 11:46:22 -04:00
Eric Callahan e9e86c3042
update_manager: refactor AppDeloy class
Don't require the `app_params` argument, instead dynamically
generate the configuration from a dict.  This simiplifies AppDeploy
initialization as the internally generated configurations can be
read in the same way as those supplied in moonraker.conf.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 11:46:21 -04:00
Eric Callahan 54081612ca
confighelper: add a setoption method
This should only be used for internally generated configuration
that may change during runtime.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 11:46:21 -04:00
Eric Callahan 93b62236de
update_manager: reorder update instances
Instantiate the moonraker instance first, then Klipper.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 11:46:21 -04:00
Eric Callahan c8042a5700
update_manager: add support for extensions
While use of "unofficial" klippy extras an moonraker components
is not officially supported, there is no harm in facilitating
updates for these extensions in the update manager.  This adds
configuration which will restart either moonraker or klipper
after an extension is updated.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 11:46:20 -04:00
Eric Callahan 16737d086d
update_manager: add full update tracking
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 11:46:20 -04:00
Eric Callahan a4019bce8e
confighelper: add support for optional separators
If "None" is specified as a separator for getdict and the getlist
variants then strings will split along any whitespace character.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 11:46:20 -04:00
Eric Callahan 5643c0ffbe
assets: show announcements on welcome page
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-03 12:17:08 -04:00
Eric Callahan 13bb624bd7
app: include announcements in welcome page context
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-03 08:58:31 -04:00
Eric Callahan 156e9652e1
announcements: add internal access methods
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-03 08:37:42 -04:00
Eric Callahan 2edbba3b53
assets: improve welcome page style
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-03 08:37:42 -04:00
Eric Callahan 9b5b3cc506
proc_stats: report system uptime in API request
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-31 16:44:39 -04:00
Eric Callahan 1968beaa0d
app: add a welcome handler
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-30 19:59:27 -04:00
Eric Callahan d11357e5f2
authorization: add status methods
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-30 14:35:39 -04:00
Eric Callahan 8bb020edc6
moonraker: add method to retreive warnings
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-30 14:35:07 -04:00
Eric Callahan b85f3081ab
power: add retries to custom http requests
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-29 15:39:04 -04:00
Eric Callahan 8c7247acbb
announcements: add retries to http request
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-29 15:37:24 -04:00
Eric Callahan 242fabe7ad
announcements: don't capitalize the feed
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-25 15:48:15 -04:00
Eric Callahan d74d1e7612
moonraker: bump the API version
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-25 15:41:49 -04:00
Eric Callahan 829b3b5c98
announcements: refactor RssFeed class
Don't require a config object to instantiate and don't attempt
to wrap database namespace.  These changes allow instantation
after the server has started.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-25 15:08:54 -04:00
Eric Callahan 5757347994
http_client: use the simple client
While the curl based client is better in most respects, it requires
that libcurl be against with an asynchronous DNS resolver, such
as c-ares, in order to prevent blocking.  As of now it Debian does
not ship with a version of curl with ares enabled.  Fall back to the
simple client until this can be resolved.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-25 12:45:46 -04:00
Eric Callahan 81a482f83d
announcements: add support for temporary dismissals
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-25 12:45:46 -04:00
Eric Callahan 64b6029559
announcements: remove warnings on failure
Its possible for users to have an unstable internet connection.  Log
connection errors rather than warn.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-25 12:45:46 -04:00
Eric Callahan cd03b91f87
announcements: add support for dynamic feed registration
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-25 12:45:42 -04:00
Eric Callahan 88b0282900
announcements: dont cache feeds
The parsed feeds are stored in the DB, so there is no
need to cache the result when 304 is returned.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-24 19:15:13 -04:00
Eric Callahan 561f5f4230
http client: minor logging fix
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-24 18:21:48 -04:00
Eric Callahan 4b0685852e
announcements: remove stale code
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-24 17:40:15 -04:00
Eric Callahan 1bdedd009f
power: fix tasmota command encoding
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-24 14:46:46 -04:00
Eric Callahan 3b208c6889
moonraker: add announcements to core components
Bump Moonraker's the API version to 1.0.2 with the addition of new
endpoints.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-23 10:37:13 -04:00
Eric Callahan b1cc766576
announcements: initial implementation
This adds support for announcements retreived via RSS feed from
the "moonlight" GitHub repo.  Announcements may also be procedurally
generated internally.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-23 10:37:12 -04:00
Eric Callahan 4a6732f13a
confighelper: implement method to read a dictionary
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-23 10:37:12 -04:00
Eric Callahan 790d77756e
app: fix blocking I/O
Open and close static files to be read using the default
thread pool executor.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-23 10:37:11 -04:00
Eric Callahan 27466984df
update_manager: fix blocking I/O
When using tempfile.TemporaryDirectory it is possible that
exiting the context will block when attempting to delete
the temporary directory.  Don't use the context manager,
instead create and cleanup the temp dir using the default
threadpoolexecutor.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-23 10:37:11 -04:00
Eric Callahan faf956c65d
update_manager: use the http_client component
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-23 10:37:11 -04:00
Eric Callahan 5bf112bcbc
power: use the http_client component
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-23 10:37:10 -04:00
Eric Callahan 0abb831ea0
moonraker: remove references to Tornado's http client
Add the http client wrapper to core components.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-23 07:07:11 -04:00
Eric Callahan 43b19d8a83
http_client: shared client implementation
This abstracts the tornado http client from the rest of Moonraker,
allowing all components to access the client's most used functionality
without importing tornado modules.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-23 07:07:10 -04:00
Eric Callahan 052dd5e338
moonraker: bump API Version
Addition of a  the "server.connection.identify" API warrants a bump in th
micro version.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-04 19:42:27 -05:00
Eric Callahan 3667e0d41f
websockets: implement server.connection.identify method
Provide a remote method by which clients may identify their
name, version, and type.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>

fix

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-04 19:42:27 -05:00
Eric Callahan b86e86aff2
websockets: report hostname and connected time
By retreiving and storing the hostname in the websocket
header, it is possible to determine a fully qualified domain
used to reach the instance.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-04 14:20:06 -05:00
Eric Callahan 221df0937d
machine: fix typo in cpu description parser
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-02 19:25:53 -05:00
vertigo235 26d6ca009a notifier: Add paused and resumed events to notifier
So we can tell when our printers need our attention. 

Signed-off-by: Josh Jones (vertigo235) <jbjonesclt@gmail.com>
2022-03-02 16:48:06 -05:00
pataar 9d49659884 notifier: add support for 'attach' property
Signed-off-by: Pieter Willekens <me@pataar.nl>
2022-03-01 11:13:32 -05:00
Gregor Majcen 553f8862b5 notifier: typo at `job_state:completed`
Signed-off-by: Gregor Majcen <majcn.m@gmail.com>
2022-03-01 08:56:47 -05:00
Eric Callahan b6fc692500
dbus_manager: clarify warnings
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-28 06:57:38 -05:00
Eric Callahan c165c40146
power: improve device initialization
Refactor the PowerDevice initialize() method so that it acquires the
request lock. Always register the "klippy_started" event if the
"restart_klipper" option is set, and always check if Klipper is is
 the ready state before performing the restart.  Remove stale
 PowerDevice methods no longer used.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-27 07:47:12 -05:00
Eric Callahan 970c8a4181
power: move process_request to the device class
Perform the entire request within a lock to prevent rentry until
the request completes.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-26 20:10:27 -05:00
Eric Callahan 8f7f824a47
octoprint_compat: respect OctoPrint's case
Make sure that the "P" in Print is capitalized when referencing
OctoPrint.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-26 10:48:52 -05:00
Eric Callahan fd8bde7185
file_manager: implement access check method
This method can be used by other components to check if Moonraker has
access to a particular file or folder.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-26 10:48:51 -05:00
Eric Callahan a32bf4a47a
file_manager: allow server to start with invalid paths
Don't raise an exeption if the config or log paths are invalid,
add warnings instead.  This allows the user to see what is wrong
and resolve this issue.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-26 10:48:50 -05:00
Eric Callahan 3a384e62dd
file_manager: add registered directory validation
Make sure that paths registered with full access do not overlap one
another, nor that they overlap sensitive folders such as the database,
Moonraker's source, or Klipper's source.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-26 10:48:48 -05:00
Eric Callahan 79f867ba83
database: remove debug option
This option was intended for Moonraker developers to live test
changes to write protected namespaces.   This can be accomplished
locally with other methods, thus this option has been removed to
prevent users from compromising sections of the database.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-25 12:38:36 -05:00
pataar 71de8def8e notifier: create the new notifier module
This component will be a bridge between moonraker and https://github.com/caronc/apprise. This way users can easily add all kind of notification services to their printer.

Signed-off-by: Pieter Willekens <me@pataar.nl>
2022-02-23 17:05:55 -05:00
Eric Callahan 54f2ee61d0 machine: report the python version in system_info
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-23 12:01:50 -05:00
Eric Callahan 7679f8063f moonraker: remove the python version check
Moonraker depends on "future" annotations and uses fstrings, so
 versions of Python older than 3.7 will fail to load and never make
 it to the version check.

 Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-23 12:01:10 -05:00
Eric Callahan f83f476f81 moonraker: report the api version
Start tracking the Remote API version separately from the application
version.  This allows the API to stick to semantic versioning while
and track the application version separately.  This is necessary as
we prepare to release a beta.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-23 12:01:07 -05:00
Eric Callahan 7ab1dda772 power: change behavior of "on when queued"
Rename the "on_when_upload_queued" option to "on_when_job_queued",
deprecate the former.  This option now applies to any queued job while
the device is off.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 14:36:46 -05:00
Eric Callahan 2b1a3e5603 klippy_apis: fix blocking issue in start_print and do_restart
The "wait_connected" method would block indefinitely until a klippy
connection is established.  This isn't the behavior we want, we only
want to wait "if" a connection has been established until Klippy
reports that its startup sequence is complete.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 14:34:14 -05:00
Eric Callahan f7f487ac18 database: sort protected namespaces before storing them
This makes the order in which they are reported consistent,
as the namespaces are stored in a set.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan 888fb58c4f database: sync namespace bugfix
Use the transaction object to overwrite keys so that we don't
move the cursor.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan 5f96822c90 database: don't overwrite "get" server errors
Make sure the correct exception is raised when "get_item" fails.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan 2d28a3eeff database: fix typo in http exception
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan 96b00549cf database: validate that namespace exists in ns_contains
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan 0bd12c8dec database: don't allow sync against an empty dict
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan f3cd177a02 database: move_batch() fix
Raise an exception if the key lengths for the source and destination
keys do not match.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan 11e299558d database: fix insert_batch()
If a namespace does not exist insert batch must create a new one rather
than raise an exception.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan bb39a3c1b2 database: handle invalid reduce results
It is possible to reduce to a value that is not a dict in "insert_item()"
and "update_item()".  Raise a ServerError with a clear description of
what went wrong in these situations.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan 89e78b9a00 database: fix type reported in overwrite warning
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan c1104617b6 database: fix typo in sync implementation
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan 3c92f42d49 database: allow synchronous calls before the server starts
It is possible that Moonraker can be instantiated while the eventloop
is running during tests.  To avoid errors allow synchronous calls until
the server starts.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan 9ab6d0e83d update_manager: support database changes
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:34 -05:00
Eric Callahan c081fa49a1 history: update for database changes
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00
Eric Callahan 9e57db0611 file_manager: add method to retreive the metadata storage object
This allows other components to synchronously access and update
metadata if necessary.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00
Eric Callahan 0dd10ce116 file_manager: update for changes in the database
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00
Eric Callahan b43f4623fc authorization: update for changes in the database
Since the User DB is not going to be large cache the users
in local memory and sync with the DB when changes are
made to the local user store.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00
Eric Callahan 46f74329d3 database: reduce duplicate code
Add a _get_db() method that perform the check for existance.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00
Eric Callahan e2a62f80d4 database: introduce record based operations
Now that all transactions run in a thread it is possible for them to
interleave.  The record based operations allow for batch operations
within a single transaction.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00
Eric Callahan e029b6c582 database: refactor to remove duplicate code
Wrap command implementations in with a _run_command() method.  All
database commands now return a Future object.  If the command was
run before the eventloop starts its possible to immediately query
the Future's result.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00
Eric Callahan 65d1f23352 database: add a sync method
Similar to the update method, however sync will remove any
keys in the database not in the new value.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00
Eric Callahan 781e3e6250 database: combine namespace wrappers
Rather than creating two wrappers, use a single wrapper whose methods
always return a future or awaitable.  If the operation occurs during
the __init__() method of a component it will be syncrhonous, and the
result from the future can be immediately queried.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00
Eric Callahan 4d0a43cb25 database: refactor initial check for empty keys
Rather than reading out the entire database, attempt to pop off
empty keys in each database.  This should should speed up
init on platforms with slow disk I/O and prevents reading
large namespaces in memory.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00
Eric Callahan e754d123dd database: improve ns_contains method
It isn't necessary to read out the entire namespace, just attempt
to fetch the record and reduce the key list.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00
Eric Callahan 43c1b998b0 database: add methods to clear and update a namespace
Since transactions are now threaded we need updating
and clearing a namespace needs to be performed within
one transaction.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00
Eric Callahan e895b10ac3 database: run transactions in a thread after the eventloop starts
Database transactions can perform disk I/O tasks, which at times will
block the eventloop.  Run all transactions in threads to prevent this
from occuring.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00
Eric Callahan 1be639b99a eventloop: use the default executor for run_in_thread()
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00
Eric Callahan ac55b95c1d database: Add unsafe shutdowns to the log rollover
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00
Simon Germain 11f4ae75cc
octoprint_compat: add webcam settings
Signed-off-by: Simon Germain <sgermain06@gmail.com>
2022-02-17 10:46:05 -05:00
Eric Callahan c2861a1391 app: correct location header encoding
SIgned-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-15 14:39:33 -05:00
Eric Callahan e2d92b5575 confighelper: use read_file() rather than read()
The read() method will return an empty list if the file specified
does not exist or if the read failed in some fashion.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-15 11:42:50 -05:00
Eric Callahan 10703321b0 power: fetch the Smart Things token option as a template
This allows users to store their token in a "secrets" file

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-14 06:19:37 -05:00
Mitch Gallman d01b8a9763 power: add support for smartthings switch
power: add support for smartthings switch

Signed-off-by: Mitch Gallman <mitchell.gallman@gmail.com>
2022-02-14 06:12:52 -05:00
Eric Callahan ee11ed2a15 confighelper: fix the get_hash() method
Include the option's values in the hash.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-13 20:48:27 -05:00
Eric Callahan ecfad5cff1 update_manager: add support for application tags
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-13 10:50:28 -05:00
Pedro Lamas cb5ac86af7 metadata: add support for parsing layer count in Cura
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
2022-02-10 12:11:20 -05:00
Eric Callahan 94a2949c00 moonraker: report missing klippy requirements
Moonraker requires that some Klipper objects be configured
and loaded.  This check has always been performed and logged,
now track and report missing requirements.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2022-02-10 08:28:51 -05:00
Eric Callahan b4ddffd5d1 moonraker: refactor KlippyConnection
Move the KlippyConnection class into its own module.  Refactor
init to use loops rather than callbacks, this reduces complexity
of tracking and cancelling callback handles.

All Klippy state previously tracked by the Server is now in the
KlippyConnection.  This improves testing and makes the code
less ambiguous, ie: the `server.make_request()` method is not
as clear as `klippy.request()`.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-09 19:15:11 -05:00
Eric Callahan 737cf8a2cb mooraker: refactor main entry point
Move the version check to the top of the module.   An older version
of python is unlikely to make it beyond the initial import statements,
so print a message to stdout and stderr.

Move argument parsing out of the main method.  This makes it possible
to invoke main without parsing command line arguments, which is useful
for tests.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2022-02-09 07:35:01 -05:00
Eric Callahan 6efcffa028 moonraker: perform error checking when registering remote methods
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-09 06:48:23 -05:00
Eric Callahan a04e91c046 proc_stats: track the loop blocked count
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-05 20:24:00 -05:00
Eric Callahan 9e9f9ee0fd moonraker: add the SIGTERM handler in server_init()
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-05 06:56:29 -05:00
Eric Callahan 1072958534 authorization: start the prune timer in component_init()
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-05 06:56:29 -05:00
Eric Callahan a5eff12131 proc_stats: start timers in component init
Avoid adding  event loop callbacks in a component's "__init__()" method.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-05 06:56:29 -05:00
Eric Callahan 0f7af929f1 file_manager: suppress "root_update" notifications during init
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-05 06:56:29 -05:00
Eric Callahan 47f0437973 eventloop: add a reset method
Rather than instantiate a new version of the event loop wrapper
we can simply reset the internal event loop.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-04 18:14:46 -05:00