Commit Graph

1096 Commits

Author SHA1 Message Date
th33xitus 6c8e3690a7 chore: remove unused import
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
2022-01-05 06:32:09 -05:00
th33xitus 2c732b7afa metadata.py: add parsing of filament name
This commit will add parsing of optional filament name metadata for:
- PrusaSlicer and it's derivatives
- Simplify3D
- Cura
- IdeaMaker

For Cura and IdeaMaker it is necessary to add a custom start g-code comment.
Cura:
;Filament name = {material_name}
IdeaMaker:
;Filament name = {filament_name1}

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
2022-01-05 06:32:09 -05:00
th33xitus d145442d4b metadata.py: add parsing of filament type
This commit will add parsing of optional filament type metadata for:
- PrusaSlicer and it's derivatives
- Cura
- IdeaMaker

For Cura and IdeaMaker it is necessary to add a custom start g-code comment.
Cura:
;Filament type = {material_type}
IdeaMaker:
;Filament type = {filament_name_abbreviation1}

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
2022-01-05 06:32:09 -05:00
th33xitus 20d3c9961d metadata.py: add parsing of nozzle diameter
This commit will add parsing of optional nozzle diameter metadata for:
- PrusaSlicer and it's derivatives
- Simplify3D
- Cura
- IdeaMaker

For Cura and IdeaMaker it is necessary to add a custom start g-code comment.
Cura:
;Nozzle diameter = {machine_nozzle_size}
IdeaMaker:
;Nozzle diameter = {machine_nozzle_diameter1}

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
2022-01-05 06:32:09 -05:00
Pedro Lamas 9d7baa1eb6 utils: fixes minor typo
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
2021-12-28 14:13:27 -05:00
Pedro Lamas d997fd637a moonraker: fixes minor typo
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
2021-12-28 14:13:27 -05:00
Pedro Lamas 05af4babb9 mqtt: fixes minor typo
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
2021-12-28 14:13:27 -05:00
Pedro Lamas 7c5d840c1b zip_deploy: fixes minor typo
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
2021-12-28 14:13:27 -05:00
Eric Callahan 1e440741da mqtt: add support for "secret" credentials
Deprecate the "password_file" option in favor of "password".

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-24 14:23:05 -05:00
Eric Callahan c5fd863bb7 power: add support for secrets
The "user", "password", and "token" options are templates
that can resolve items stored in the secrets file.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-12-24 14:23:05 -05:00
Eric Callahan a269de5dc0 confighelper: add load_template method
This is an alternative to gettemplate that always returns a
template.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-24 14:23:05 -05:00
Eric Callahan a4f960d40c confighelper: implement deprecation
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-24 14:23:05 -05:00
Eric Callahan 9dadf50ac6 templates: add support for secrets
Add the secrets module as a Jinja2 Environment global.
All templates will be able to access secrets as if it were
a dictionary.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-24 12:41:28 -05:00
Eric Callahan d498eefd13 secrets: initial implmentation
Add support for an external "secrets" file that may contain
usernames, passwords, and tokens.  This file may be in
"ini" or "json" format.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-24 12:41:28 -05:00
Eric Callahan f4e3803647 metadata: refactor thumbnail parsing
Check for "Prusa" style embedded thumbnails by default for
all slicers.  This is becoming a standard, as it is now available
in Cura, Ideamaker, and Simplify3D via plugins.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-23 06:38:13 -05:00
Eric Callahan 92954245fa mqtt: implement a "publish_mqtt_topic" remote method
Allow Klipper to publish MQTT topics from gcode macros.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-12-22 19:31:00 -05:00
Eric Callahan cc1a55a871 metadata: always create a miniature thumbnail
Don't require that gcode files embed two thumbnails.  When
a single large thumbnail is parsed use pillow to create a
small one.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-22 07:29:16 -05:00
Eric Callahan 5766d16edc octoprint_compat: default printer profile fix
Cura's Octoprint plugin expects an "axes" field for each profile.
Report these values to match the default values used by the
plugin.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-22 05:41:00 -05:00
Eric Callahan ec43f5e9b6 octoprint_compat: make UFP uploads optional
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-22 05:41:00 -05:00
Eric Callahan e2fb1cc931 octoprint_compat: add support for "print on start"
Cura's Octoprint plugin does not set the 'start' flag on uploads
when UFP is enabled.  Instead it waits for the upload to
finish then issues Octoprint's "file command" request.  Add
limited support for this API, mimicing how uploads are normally
handled.

Singed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-22 05:41:00 -05:00
Eric Callahan e46b4994d4 app: add support for empty responses
If a dynamic request handler returns None with "wrap_result"
disabled, set the return status to 204.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-21 18:12:27 -05:00
Eric Callahan b369173f94 app: refactor upload handler registration
Move upload handler registration out of the file manager.
Register the primary hander in the app module, and the
Octoprint Comptaiblity handler in octoprint_compat.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-21 16:53:33 -05:00
Eric Callahan ac9eaa7681 app: set the status to 201 for uploads
Set the location header when the upload returns a valid result.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-21 15:32:28 -05:00
Eric Callahan 3e70e4b4ce machine: report additional release info
Report information contained within a linux distribution's
release file if it exists.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-20 16:58:21 -05:00
Eric Callahan 1333413db7 update_manager: fix pip location resolution
When creating a virtualenv, some operating systems provide
symbolic links back to /usr/bin/python3 rather than copy
the python exectuable over.  Previously Moonraker resolved
this symbolic link, resulting in a failure  to locate pip.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-20 12:30:26 -05:00
Eric Callahan 7d1cf435f7 authorization: report invalid "trusted_clients"
Add warnings that are reported to clients and logged if an
invalid trusted client is detected.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-20 08:37:54 -05:00
Eric Callahan d0b1621bd5 power: add mqtt device support
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-19 08:00:13 -05:00
Eric Callahan f57bddfe4a mqtt: send connect and disconnect events
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-14 17:51:12 -05:00
Eric Callahan 3ac8f8cd81 mqtt: add method to report instance name
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-14 17:51:12 -05:00
Eric Callahan e2b821e90c confighelper: add gettemplate method
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-14 17:51:12 -05:00
Eric Callahan 2142d344dd template: add support for Jinja2 template evaluation
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-14 17:51:12 -05:00
Eric Callahan 3f7cc53baa moonraker: don't allow a unix socket to open while closing
Hold the closed mutex in the "connect()" method.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-12 10:24:19 -05:00
Eric Callahan 31dd758d52 moonraker: unix socket fix
Handle connection errors in the read loop.  Set a maximum number
of consecutive errors encountered during a read before aborting.
Resolves #309.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-12-12 06:40:53 -05:00
Eric Callahan a4abec43d5 mqtt: fix non-threadsafe on_socket_open callback
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-11 14:31:10 -05:00
Eric Callahan c6cddf4b05 moonraker: logging improvements
Move logging setup to the Server class and enable asyncio debugging.
Sanitize debug logging for all "/access" endpoints so tokens and
passwords are not logged.

SIgned-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-11 14:16:15 -05:00
Eric Callahan c69ded21b0 job_state: initialize in "klippy_started" event
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-11 08:44:55 -05:00
Eric Callahan 08111415be update_manager: auto-refresh fix
Only refresh a provider when the update interval has expired.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-10 11:37:51 -05:00
Eric Callahan 56a98aa8ed update_manager: replace PeriodicCallback
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-10 11:37:51 -05:00
Eric Callahan 511c91829a power: use native asyncio socket streams
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-10 11:37:51 -05:00
Eric Callahan ae4c4ad678 moonraker: use native asyncio unix streams
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-10 11:37:51 -05:00
Eric Callahan df674ae476 proc_stats: replace PeriodicCallback
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-12-10 11:37:51 -05:00
Eric Callahan 5dadc2067d data_store: replace PeriodicCallback
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-10 11:32:52 -05:00
Eric Callahan 4e625aef37 authorization: replace PeriodicCallback
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-10 11:32:52 -05:00
Eric Callahan 69a06dd12a eventloop: add a timer class
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-09 14:38:32 -05:00
Eric Callahan 54abd27486 paneldue: multi-extruder fixes
Sort heater response so that the bed is displayed first, followed
by extruders in ascending order.  Set inactive extruders to
"standby" if they are on rather than "active".

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-08 19:31:41 -05:00
Eric Callahan f5f87bf08c file_manager: metadata move fix
If the destination exits in the metadata database it is necessary
to either overwrite it with the source metadata or delete it
so that the new metadata can be rescanned.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-08 15:26:45 -05:00
Eric Callahan 18b84b8d9f file_manager: don't request metadata from non-gcode files
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-08 15:26:45 -05:00
Eric Callahan ec29787edd file_manager: inotify timing fix
Flush pending delete events when move and create events are detected.  This resolves timing issues with rapidfire create/delete events.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-08 15:26:45 -05:00
Eric Callahan 1ad83cec97 mqtt: fix connect/reconnect issues
Handle all potential exceptions.  Run the connect/disconnect
in another thread, as its possible for some calls to block
the event loop.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-06 08:38:27 -05:00
Eric Callahan ac73036857 machine: fix issues with network interface parsing
Don't parse non "ether" types.  Don't add interfaces that don't
have mac addresses and at least one IP address.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 17:12:21 -05:00
Eric Callahan c0c34ea045 file_manager: fix object processing option name
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 14:08:41 -05:00
Eric Callahan 6a90bfa480 update_manager: prevent apt from fetching updates on startup
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 09:14:49 -05:00
Eric Callahan b1c9a96040 metadata: add support for parsing layer count
Currently this is only supported in SuperSlicer.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 06:45:06 -05:00
Eric Callahan cfa5f4a432 file_manager: don't emit events when a node is processing metadata
When a folder is copied processing can take several minutes, depending on the size and number of gcode files in the
path.  Suppress all file events on a node until processing
is complete.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 06:45:06 -05:00
Eric Callahan 9dd0797f49 file_manager: ignore duplicate "create_file" notifications for gcode files
The the cancel object post processor results in an additional
"create_file" notification when the old file is replaced.
Track previous "create_file" notifications for valid gcode
files so the dups can be suppressed.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 06:45:06 -05:00
Eric Callahan b7c64443db file_manager: refactor metadata processing
When destructively iterating over pending metdata requests
don't pop the pending item until metadata processing is
complete.  If a call to `parse_metadata()` has a request
pending, return the asyncio Event associated with that
request.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 06:45:06 -05:00
Eric Callahan 88137d5898 file_manager: add option to enable object postprocessing
Signed-off-by:  Eric Callahan <arksine.code@gmail.com
2021-12-05 06:45:06 -05:00
Eric Callahan 6bd46a4433 metadata: add support for object postprocessing
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 06:45:06 -05:00
Eric Callahan 13bc4c5b9b update_manager: handle system package init
Force refresh requests after server initializaton.  Update
package state after installation.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 06:26:34 -05:00
Eric Callahan e8c1798a13 update_manager: Prune stale data in the database
SIgned-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 06:26:34 -05:00
Eric Callahan 3203950ca9 update_manager: prevent refresh requests from spamming
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 06:26:34 -05:00
Eric Callahan 4c68086798 zip_deploy: add support for persistent state
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 06:26:34 -05:00
Eric Callahan bb87917c97 git_deploy: add support for persistent state
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 06:26:34 -05:00
Eric Callahan 74a03fca59 app_deploy: add support for persistent state
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 06:26:34 -05:00
Eric Callahan eb8f1e2526 update_manager: add support for persistent state
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 06:26:31 -05:00
Eric Callahan 3a547fb530 base_deploy: add support for persistent state
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 06:25:24 -05:00
Eric Callahan d23f72d232 database: increase max namespaces to 100
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 06:25:24 -05:00
Eric Callahan c4fa76f217 update_manager: remove refresh time tracking
This is preparation for moving refresh time tracking to the deployment
provider class.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-05 06:25:20 -05:00
Eric Callahan d8a31fc249 update_manager: remove init success check
Now that the update manager doesn't rely on the rate
limit it should always initialize successfully.  An individual
updater may still fail to initialize, however this does
not prevent the update manager from loading.

Singed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-28 11:15:23 -05:00
Eric Callahan 7f0712183d update_manager: remove GitHub rate limit initialization
The rate limit fields can be extracted from the response
to an API request, even if that request fails with 403.  This speeds up update manager initialization and reduces
failures if github is unreachable.

SIgned-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-28 11:15:23 -05:00
Eric Callahan f7bdfb4d6b confighelper: add get_hash method
This returns the checksum of a config section and can be used to check
if the section has changed.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-28 11:15:23 -05:00
Eric Callahan eda5623b2e database: fix invalid key handling
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-11-28 11:10:42 -05:00
Eric Callahan 3df0f3ffe4 job_queue: add websocket notification
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-27 10:23:04 -05:00
Eric Callahan 269897bef7 job_queue: rename "resume" api to "start"
Given the changes to the job queue, "start" is a more
appropriate API call than "resume".

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-27 06:04:47 -05:00
Eric Callahan 4837ea56cb job_queue: register remote method to control the queue
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-26 20:35:10 -05:00
Eric Callahan 28e88b1363 job_queue: dont attempt to start a print when empty
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-11-26 19:53:57 -05:00
Eric Callahan 784b8b9b18 file_manager: attempt to start gcode uploads prior to queueing
Only attempt to queue the upload if the job failed to start.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-26 19:46:59 -05:00
Eric Callahan f09c313c5b job_queue: fix resume request
Make sure that the queue is set to ready after resuming,
even if the next job is unable to be loaded.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-26 18:11:11 -05:00
Eric Callahan d25c3c1d49 job_queue: queue state fix
When not in automatic mode make sure the queue
state is paused after adding a job to the queue.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-26 17:19:44 -05:00
Eric Callahan e8cdd8a928 job_queue: add "automatic_transition" option
When set to true, the queue will automatically transition
to the next job in the queue upon completion of the
current job.  When false the queue will pause between
jobs, requiring that the user manually resume.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-26 17:00:42 -05:00
Eric Callahan 0b9fa7d87e zeroconf: more refactoring
Resolve issues with ipv6 addresses.  Only register the
net_state_changed event handler if Moonraker is bound
to all interfaces.  Build a new instance of ServiceInfo
for each update rather than attempt to modify the
existing object.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-26 15:51:49 -05:00
Eric Callahan c89a9152b5 moonraker: log exceptions when a component_init fails
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-26 14:39:01 -05:00
Eric Callahan b70254feed zeroconf: minor formatting fix
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-26 14:30:47 -05:00
Clifford Roche 513a122290 zeroconf: Don't close on update
Signed-off-by: Clifford Roche <clifford.roche@gmail.com>
2021-11-26 14:28:06 -05:00
Clifford Roche 6258082d70 zeroconf: Implement new approach for ip detection
Signed-off-by: Clifford Roche <clifford.roche@gmail.com>
2021-11-26 14:28:06 -05:00
Eric Callahan 76e431330c machine: service unit detection fix
Add `--plain` and `--no-legend` to the command to list service units.
This fixes a bug where  a service could be prefixed with a unique
character, resulting undetected services.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-26 09:02:05 -05:00
Eric Callahan 685bd72274 app: add request debug logging
This mimics the logging available over JSON-RPC requests.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-26 06:11:13 -05:00
Eric Callahan f0831cbe3c moonraker: prevent duplicate failed components
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-25 17:16:09 -05:00
Eric Callahan 2a0be55a8d power: remove has_gpio check
This prevents loading the gpio module unless a gpio
device is configured.  Resolves #283.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-25 17:16:09 -05:00
Eric Callahan ccb86ea039 proc_stats: check for network updates every 10 seconds
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-25 08:18:24 -05:00
Eric Callahan b33183f60f machine: add support for parsing network info
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-25 07:58:25 -05:00
Eric Callahan 7a99f83396 server: refactor get_host_info method
Return a dict with the host name, server address, server port, and ssl port.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-25 05:43:49 -05:00
Eric Callahan 50fd8c9cc4 confighelper: track default values
This restores the behavior before commit 5b4de64.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-11-23 13:55:24 -05:00
Eric Callahan 0a1367744f confighelper: fix json parsing error for gpios
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-11-23 08:21:56 -05:00
Clifford Roche 4e8e4f7d14 zeroconf: add module for zeroconf discovery
Signed-off-by: Clifford Roche <clifford.roche@gmail.com>
2021-11-22 15:03:33 -05:00
Clifford Roche 44abc64533 machine: add serial number attribute for cpu
Adds the property "serial_number" to the process info structure.

Signed-off-by:  Clifford Roche <clifford.roche@gmail.com>
2021-11-22 14:00:34 -05:00
Eric Callahan 97e27661d7 gpio: remove get_gpio_out_from_config method
The confighelper object now can setup  gpios directly.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-21 06:26:09 -05:00
Eric Callahan 0e4e3383e3 update_manager: node update fix
Use "getboolean" rather than "get" to fetch this option.

SIgned-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-20 11:40:57 -05:00
Eric Callahan fd6d318f0a power: use extended confighelper methods
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-20 11:40:57 -05:00
Eric Callahan 69e2fb810f update_mananger: use extended confighelper methods
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-20 11:40:57 -05:00
Eric Callahan 4572bd955e paneldue: use extended confighelper methods
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-20 11:40:57 -05:00
Eric Callahan 9ebae5fd5a mqtt: use extended confighelper methods
SIgned-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-20 11:40:57 -05:00
Eric Callahan 22807ee393 authorization: use extended confighelper methods
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-11-20 11:40:57 -05:00
Eric Callahan 845689fde1 confighelper: add getgpioout method
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-20 11:40:55 -05:00
Eric Callahan 0b25350ebc confighelper: add support for getlist and getdict
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-20 11:40:07 -05:00
Eric Callahan c0ae10bef6 confighelper: add has_option method
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-20 11:38:37 -05:00
Eric Callahan 5b4de64709 confighelper: add support for conditionals
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-20 11:38:34 -05:00
Pedro Lamas d51d65ef30 mqtt: retry connection if failed to resolve hostname
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
2021-11-18 06:00:51 -05:00
Eric Callahan 1caaebe03f power: implement workaround for Homeassistant devices
Some devices on the Home Assistant server do not update their internal state immediately after a request returns.  Introduce a configurable delay to work around this issue.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-15 10:59:46 -05:00
Eric Callahan c3400bd237 power: add timer support to the RFDevice
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-15 08:11:08 -05:00
Eric Callahan 18c6ff5a99 power: refactor gpio device to use gpio component
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-15 08:11:08 -05:00
Eric Callahan 83901b1896 gpio: helper component for managing system gpios
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-11-15 08:10:29 -05:00
Eric Callahan dfa11f0f3e utils: add method to load system level modules
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-11-15 06:41:38 -05:00
Eric Callahan adb88fd8cf authorization: validate user data on startup
This provides corrective action in the event that an
invalid user entry makes its way into the database.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-15 06:00:59 -05:00
Richard Mitchell 389e9c7e62
wled: support for remote neopixel control
Signed-off-by:  Richard Mitchell <richardjm+moonraker@gmail.com>
2021-11-14 07:16:20 -05:00
Pedro Lamas bed239c90a mqtt: implements last will and testament
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
2021-11-13 11:00:26 -05:00
Eric Callahan ca27c2cf10 power: change gpiod line request based on version
For gpiod versions 1.3 or greater use the "default_val" keyword argument to set the default, otherwise use
"default_vals".

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan 6d458125a1 power: fix scheduled firmware restarts
Determine if a firmware restart should be postponed by checking Klippy's state.  This should correctly schedule the restart regardless of whether or not the device is bound to Klipper.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan 7f11214609 power: abort a scheduled firmware restart if klipper reports ready
This handles a specific scenario where a power device is bound to the Klipper service and is configured to perform a firmware restart after power on.  In this case, we can detect if the firmware restart is required and abort it if necessary.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan 739af51904 power: add "on_when_upload_queued" option
When this option is set to "True", the device will power on after the file manager queues an upload for printing.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan 484c4aea59 eventloop: fix FlexCallback annotation
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan ac23f00d1f update_manager: remove initialized lock
Now that init occurs before the server starts there is no need to block requests until post initialization.

Signed-off-buy:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan 2d5914b358 moonraker: attempt to resolve "event loop closed" errors on restart
Occasionally a server restart will fail as the new loop instantiates as closed.  This seems to be an issue with asyncio, attempt to work around by retyring to create a new loop.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan c718e9d1c3 moonraker: don't use a set to load initial components
Previously a set was used to remove duplicate components, however this is unnecessary as the `load_component` method immediately returns dups.  Using a list should preserve the load order based on the configuration, making it more predictable.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan 76731b673b moonraker: refactor klipper initialization
The `send_event()` method now returns a future that can be awaited until all callbacks are complete.  All events emitted during Klipper init are now awaited, and a Lock is used to prevent re-entry.  This resolves potential timing issues with commands sent during the init sequence.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan c2bf9bf551 event_loop: add create_future method
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan 9854fd36cf power: use component_init for post initialization
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan e6bedd1ffe paneldue: use component_init for post initialization
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan 799e763050 mqtt: use component_init for post initalization
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan fd59ace4f8 machine: use component_init for post initialization
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan 15d99be9f0 update_manager: use component_init method for post initialzation
Clean up retry functionality to use for loops rather than while loops.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan cbdbe83bbd moonraker: refactor component initialization
Components may call a "component_init" method for initialization that requires async calls.  This allows moonraker to track init progress and guarantee init order.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan 7a8aeae673 file_manager: use the job queue to start gcode uploads
If a print cannot be started then it will be queued.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan b135f48867 moonraker: add job queue to core components
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan 0f1aea8df8 moonraker: refactor component loading
Remove the "load_component_multi" method as it is not
necessary.  Components are responsible for loading
"child" sections as required.  Core components can
now have their own config section.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan ec12a187fc job_queue: initial implementation
Add support for holding multiple printer jobs in a queue.
When a job successfully completes Moonraker will load
the next job in the queue.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan 358fe9733f history: implement reset totals endpoint
This allows clients to request that job totals are reset to 0.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan 21ee446509 history: use the job_state module to manage job events
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan d0c104aceb job_state: initial implementation
This module adds a helper to track Klippy's "print_stats" module.  It
stores the current stats and emits events for changes in job state.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-12 10:11:39 -05:00
Eric Callahan 53291f6887 power: use the default_vals keyword to init gpios
The "default_val" keyword argument is not available in libgpiod version 1.2.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-11 19:35:34 -05:00
Pedro Lamas a3ba4b4169 power: improves GPIO initial_state handling
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
2021-11-11 19:09:06 -05:00
Eric Callahan 61fab42281 moonraker: log unix socket permission errors
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-04 11:03:53 -04:00
Eric Callahan 105858b0c7 machine: fix perfomance regression
The `update_service_status()` method could result in the creation of multiple subprocesses for each update, resulting in a performance hit as subprocesses are inherently expensive.

Fetch the state for all detected services in a single subprocess.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-03 09:10:12 -04:00
Eric Callahan 6a39bbd0c3 mqtt: don't publish status updates when disconnected
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-03 08:49:40 -04:00
FrY Sennberg eec60a760b
git_deploy: report git repository name
Signed-off-by: Christoph Frei <fryakatkop@gmail.com>
2021-11-01 19:10:35 -04:00
Eric Callahan 86ac019572 moonraker: report software version in server.info
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-01 11:24:31 -04:00
Eric Callahan 4f43cf3a9f shell_command: handle ProcessLookupError when cancelling
This suggests that the process has previously exited.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-01 08:25:28 -04:00
Eric Callahan e71e723f89 confighelper: attempt to clarify unparsed config warnings
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-31 19:17:25 -04:00
Eric Callahan 8e33698e23 power: improve logging when the gpiod module fails to load
Log all import errors other than ModuleNotFound errors.  Add a server warning if a gpio type is configured and the gpiod module is not loaded.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-31 19:12:20 -04:00
Eric Callahan 2addf845d3 machine: add PNY to the list of known SD manufacturers
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-31 19:12:00 -04:00
Eric Callahan b55b21921a file_manager: report additional info in response to get_directory
Include the root's name and its permissions.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-30 16:49:41 -04:00
Eric Callahan e9b06472c1 file_manager: minor refactoring in _list_directory method
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-30 16:46:40 -04:00
Eric Callahan aa608b4c29 metadata: support extracting thumbnails from footer
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-30 11:01:27 -04:00
Eric Callahan 4e262dfa14 file_manager: remove redundant code in delete_file method
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-30 07:34:40 -04:00
Eric Callahan 538c68fc8b file_manager: normalize path requests
This resolves an issue where a path is containter two slashes as a separator reports as outside of the root.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-30 07:28:55 -04:00
Eric Callahan 28c8bf61da machine: add a more robust container check
Most containers do not have access to systemd, so using
systemd-detect-virt will fail.  We can check the cgroup
and sched files of the first process to reliably determine
if Moonraker is running within a container.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-28 19:38:15 -04:00
Eric Callahan f35bceb309 machine: detect virtualized envronment
It isn't valid to run some commands from within containers.  Use systmd-detect-virt to detect a virtualized environment and report the type and id via the system_info endpoint.

If Moonraker is running from within a container do not allow access to the reboot and shutdown endpoints.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-28 11:45:13 -04:00
Eric Callahan de8c0fc871 file_manager: fix inotify symlink handling
When a symbolic link is created there is no completion event, so immediately fire the notification.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-27 11:24:57 -04:00
Eric Callahan e33962fdd4 file_manager: check write permissions for uploads
If the specified path is a symbolic link do not proceed with the upload, raise an exception.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-27 08:55:44 -04:00
Eric Callahan 734f295822 file_manager: allow registration of full access directories
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-27 08:55:44 -04:00
Eric Callahan 4c42b8d072 file_manager: report file and directory permissions
Signed-off-by: Eric Callahan <arksine.code@gmail.com>

fix
2021-10-27 08:55:19 -04:00
Eric Callahan 47999e24c4 power: add support for bound services
A bound service is stopped when a device powers off and started when a device is powered on.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-24 12:39:52 -04:00
Eric Callahan 12e035b6eb machine: list all active units
This resolves an issue where an allowed service is not
tagged as available if it is not loaded when moonraker
starts.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-10-24 08:45:28 -04:00
Eric Callahan 9d7dac3425 moonraker: rework Klippy init sequence
Stop polling Klippy after it it has exited the "startup" state.
When this has been detected, emit a "klippy_startup"
event.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-24 08:45:28 -04:00
Eric Callahan a0b5275cc9 machine: add method to wait for service init
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-10-23 10:20:07 -04:00
Eric Callahan 97522947ec proc_stats: update service state in the proc_stat timer
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-23 10:20:07 -04:00
Eric Callahan 8126a73663 machine: report active status of available services
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-23 10:20:07 -04:00
th33xitus 6a6422c16e metadata: add IdeaMaker thumbnail parsing
This commit allows Moonraker to parse thumbnails from g-code files generated by IdeaMaker.

Signed-off-by:  Dominik Willner <th33xitus@gmail.com>
2021-10-14 14:23:00 -04:00
Eric Callahan 838b25d288 power: implement timer functionality for gpio devices
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-14 08:03:13 -04:00
crashmaxx 2836600857
power: add timer option to tplink-smartplug devices
Signed-off-by: Andrew Stowell crashmaxx@gmail.com
2021-10-12 06:35:32 -04:00
Eric Callahan 25f9800f77 moonraker: don't send status updates for empty objects
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-10 17:58:43 -04:00
Eric Callahan 0ed367d734 mqtt: support specifying fields in "status_objects" option
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-10 12:21:27 -04:00
Eric Callahan 070e03d741 file_manager: Don't filter inotify events on the gcodes root
Broadcast events for all files and let clients determine
what should be shown.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-10 11:33:33 -04:00
Eric Callahan 7f1c327f02 file_manager: hidden folder bugfix
Since inotify supports hidden folders we shouldn't skip them when scanning for nodes.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-10 11:04:59 -04:00
Eric Callahan 0c311aeef4 mqtt: add support for publishing klipper status updates
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-10-08 14:17:13 -04:00
danijoo c3f1b290f8 power: add RF transmitter support
Signed-off: Daniel Bauer <github@dbauer.me>
2021-10-03 09:05:12 -04:00
Eric Callahan 86764657cf machine: add moonraker-telegram-bot to list of allowed services
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-09-29 18:08:08 -04:00
Eric Callahan fdfab66951 metadata: add PrusaSlicer aliases
The varous forks of PrusaSlicer are processed identically
outside of their identifier, so there is no need to
implement new classes for each fork.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-09-28 06:14:24 -04:00
Eric Callahan 9c09ca2ed5 update_manager: add support for moved git repos
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-09-24 12:22:45 -04:00
Eric Callahan d6fafef902 proc_stats: report websocket connection count
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-09-21 14:19:01 -04:00
Eric Callahan b1d739e032 moonraker: report websocket connection via /server/info
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-09-21 11:30:25 -04:00
Eric Callahan e76e83d8c1 moonraker: configure the tornado http client to use the curl backend
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-09-21 08:32:24 -04:00
Eric Callahan e92da4c82c power: add gpiod support for Arch Linux
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-09-15 18:09:20 -04:00
Eric Callahan 776e0d6c90 file_manager: strip leading slashes supplied in the upload path argument
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-09-14 14:43:00 -04:00
Stefan Dej 81176a6d31 confighelper: update 'Invalid config option' warning for better understanding
Signed-off-by: Stefan Dej <meteyou@gmail.com>
2021-08-29 14:15:12 -04:00
Eric Callahan 245053434f authorization: specifically identify basic auth
Raise an exception when a request with Basic Auth is received, however do not log the username/password.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-08-28 08:54:40 -04:00
Eric Callahan dfb8da6e3e authorization: improve error message for invalid auth headers
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-08-27 06:11:55 -04:00
Eric Callahan b040640813 update_manager: broadcast update_refreshed notification in the status refresh handler
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-08-26 15:44:26 -04:00
Eric Callahan 8a7b348899 update_manager: fix apt-get issue with changed release info
Add --allow-releaseinfo-change to the call to apt-get.  This resolves an issue where the repos are chaning their "Suite" value from stable to oldstable with the release of Debian Bullseye.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-08-24 06:39:54 -04:00
Eric Callahan 5204fe3e08 metadata: fix est time parsing for Simplify3D
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-08-07 11:45:44 -04:00
Eric Callahan 86e0ef0d5e git_deploy: use "git pull --rebase" when repo debug is enabled
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-27 05:52:56 -04:00
Eric Callahan 42f61ceafa power: attempt to retry failed device init for 120 seconds
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-18 14:26:10 -04:00
Eric Callahan c684b063b2 proc_stats: report network stats for all interfaces
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-18 08:49:38 -04:00
Eric Callahan 8f8d780c72 proc_stats: fix stat logging when the event loop is blocked
Convert the deque to a list before slicing.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-15 11:03:07 -04:00
Eric Callahan 91f264bdaf update_manager: fix unbound variable error
Signed-off-by:  Eric Callahan <arksine.code
2021-07-15 08:14:18 -04:00
Eric Callahan 1fdfb5299e moonraker: create a new asyncio event loop on restart
This should guarantee that no dangliing callbacks are leftover on a soft restart.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-15 06:57:54 -04:00
Eric Callahan 0d1431395e update_manager: fix potential race condition with auto_refresh
Wait until update manager init is complete before attempting starting the auto refresh periodic callback.  This prevents an auto refresh from blocking init if Moonraker is started during the auto refresh window.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-07-15 06:52:04 -04:00
Eric Callahan 7f740ccb5a authorization: add warning if a domian in "cors_domains" contains a trailing slash
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-12 15:47:38 -04:00
Eric Callahan cb8d5ecb35 app_deploy: add "is_system_service" configuration option
This allows users to add update manager "clients" that don't have systemd services registered.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-12 07:47:43 -04:00
Eric Callahan 87444f5bcb zip_deploy: allow updates to stable releases when on the "beta" channel
Users on the "beta" channel should be updated to the latest release, including stable releases.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-12 07:47:43 -04:00
Eric Callahan 2ceafb0ff5 git_deploy: replace references to ioloop with eventloop
Wrap some additional system calls that could potentially block in "run_in_thread".

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-07-12 06:34:15 -04:00
Eric Callahan 912840bbcd zip_deploy: replace references to ioloop with eventloop
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-12 06:16:18 -04:00
Eric Callahan d52554231a app_deploy: replace reference to ioloop with eventloop
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-12 06:16:18 -04:00
Eric Callahan c4796ee321 update_manager: replace references to ioloop with eventloop
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-12 06:16:18 -04:00
Eric Callahan 13a85fe9e0 file_manager: replace references to ioloop with eventloop
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-12 06:16:18 -04:00
Eric Callahan e4ecc1febe authorization: replace references to ioloop with eventloop
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-12 06:16:18 -04:00
Eric Callahan 646e97ad55 machine: replace reference to ioloop with eventloop
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-12 06:16:18 -04:00
Eric Callahan 05e2389dc1 mqtt: replace references to ioloop with eventloop
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-12 06:16:18 -04:00
Eric Callahan 8382b90682 paneldue: replace reference to ioloop with eventloop
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-12 06:16:18 -04:00
Eric Callahan c61cfa325f power: replace references of ioloop with EventLoop
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-12 06:16:18 -04:00
Eric Callahan 78e10cf7f8 proc_stats: Use the EventLoop to run blocking calls in in a background thread
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-12 06:16:18 -04:00
Eric Callahan 85d12da18d shell_command: replace tornado lock with asyncio lock
Also use asyncio's sleep method in place of tornado's wrapper around it.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-07-12 06:16:18 -04:00
Eric Callahan 4430d564fe websockets: replace references to ioloop with event loop
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-12 06:16:18 -04:00
Eric Callahan 8a3ff7a54a app: replace refrences to ioloop with eventloop
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-07-12 06:16:18 -04:00
Eric Callahan d224536552 moonraker: replace calls to ioloop with eventloop wrapper
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-12 06:16:18 -04:00
Eric Callahan 07cb64a191 eventloop: initial implementation
This adds a thin wrapper around asyncio's eventloop.  Generally it is similar to Tornado's IOLoop, however without the need to support all awaitables.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-12 06:16:18 -04:00
Eric Callahan fddc67db93 update_manager: add support for web betas
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-09 18:06:07 -04:00
Eric Callahan df43aca222 proc_stats: fix erroneous timer handle assignment
The delayed callback to "log_last_stats()" in the Watchdog shold not have its return value assigned to the watchdog handle.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-09 08:01:27 -04:00
Eric Callahan fb9206aa8f proc_stats: read system files in another thread
This should prevent the event loop from getting blocked by a system call.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-09 05:53:11 -04:00
Eric Callahan e20c12619b git_deploy: compare upstream url to lowercase url during validation
SIgned-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-08 12:09:17 -04:00
Eric Callahan 211c7e70e1 app_deploy: fix typo preventing repo clients from loading
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-08 11:58:11 -04:00
Eric Callahan dacd9f7565 update_manager: report detected_type and configured_type for applications
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-08 09:02:08 -04:00
Eric Callahan d76abe019f update_manager: return True when on update success
All calls to update now return a boolean value.  When performing a full upate this return value is used to
check if Moonraker should wait for Klippy to reconnect.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-08 07:55:50 -04:00
Eric Callahan b6cd19d6ef update_manager: make application package updates generic
This ignores an attempt to update packages if system updates are disabled and opens the possibility for supporting updates for other linux distributions.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-07 18:27:12 -04:00
Eric Callahan 74630f933a update_manager: use asyncio locks
Transion away from Tornado's wrappers, as their implementation of
"wait()" can be confusing.  Some of tornado's methods require that
you specify a delay in seconds, others requrire that you specify a
timeout relative to the Unix epoch.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-07 18:27:07 -04:00
Eric Callahan 9133b59dbf update_manager: add "full" update endpoint
This endpoint will perform a full system update.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-07 18:26:30 -04:00
Eric Callahan 10da7b714f update_manager: add support for zip deployment
This adds support for updating packaged applications from GitHub.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Eric Callahan 908501cbc8 update_manager: remove unnecessary Is_refreshing check
The underlying deployment implementations use locks to prevent concurrent attempts at refeshing state, thus the "is_refreshing" check is redundant.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Eric Callahan 5d35cc0d10 update_manager: Implement async streaming downloads
This allows Moonraker to report download progress.  This also resolves potential issues with I/O blocking the event loop.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Eric Callahan f2b48d0f1a update_manager: refactor github API requests
Save a request cache in the CommandHelper that stores the etag and value for each URL requested.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Eric Callahan 88ee83c7d8 update_manager: use pathlib to represent file system paths
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Eric Callahan d3ec2dbae2 update_manager: refactor application deployment
This is the first step toward creating mutliple methods for deployment.  This patch creates a base class for all deployment objects and a base class for application deployment.  The git functionality has moved to its own module.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Eric Callahan 78edcab86e confighelper: don't add supplemental configs to the original
Create a new ConfigParser that reads the supplemental and return a new ConfigWrapper.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Eric Callahan 627db24c63 update_manager: make system updates optional
Remove the "distro" config option as it is not necessary.  If there is a need to identify the linux distribution that can now be done through the distro dependency.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Eric Callahan 7c56a8fa74 utils: add method to validate packaged applications
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Eric Callahan 0527904c48 moonraker: remove references to "system_args"
Rather than add these arguments to the config, use a method to access them from the server object.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Eric Callahan 39a532cf87 utils: move git version parsing into its own method
This creates a generic utility for retreiving the git version.  Moonraker will now attempt to parse basic version info from a ".version" file if git describe fails.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Eric Callahan ebaac290e7 utils: add a method to calculate the hash of a directory
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Arksine 2ab63d75fc moonraker: fix imports for type checking
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Arksine 1c248d1de8 moonraker: remove check for component existence in "load_component()"
The importlib module will raise an exception if the component does not exist, so the check is redundant.  This allow allows packages to be loaded.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Arksine 261fbbc867 file_manager: move modules to its own package
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Arksine 346015e528 update_manager: move the "rebuild env" functionality
Initially rebuilding the venv was required to change env options to include dist packages.  This is no longer necessary so we can remove detection for it.  Building a venv could still be necessary, so move this functionality to its own method.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Arksine 8b8d538a9c update_manager: remove dist package options
These options are no longer necessary, as we now apply the dist path before the import in modules that require dist packages.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Arksine 5b260a5ba6 update_manager: correct relative paths
Update the paths to Moonraker and the supplemental configuration file.

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

Update update_manager.py
2021-07-06 19:25:10 -04:00
Arksine 03892a517e update_manger: move module into its own package
This includes its specific configuration file.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Arksine 30155c4a8c power: add special handling for gpiod import
Rather than symlink the gpiod dependency in a virtualenv, temporarily add the dist-package to sys.path then import gpiod.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Arksine bfef2eb98e file_manager: update location of metadata script
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Arksine 7ccb455174 metadata: move extract_metadata.py to components
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:25:10 -04:00
Eric Callahan 80df137437 websockets: fix call to wait() in WebsocketHandler.close()
The wait timeout must be relative to the current time.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:24:52 -04:00
Eric Callahan a605cd3048 file_manager: NotifySyncLock bugfix
The time() method must be called on the current IOLoop.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 19:22:46 -04:00
Eric Callahan c6fee3c1f4 moonraker: send status eventtime as a second parameter to "notify_status_update"
This resolves a potential issue where clients could anticipate that all items in the status parameter are objects.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 14:56:18 -04:00
Eric Callahan 81854d1daf moonraker: report Klipper event time with status subscriptions
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-07-06 14:35:09 -04:00
Eric Callahan 4836f52a5d shell_command: ignore utf8 decode errors
Also catch a potential KeyError when removing running commands.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-07-06 07:26:09 -04:00
Eric Callahan ecc0fbdae9 mqtt: return a boolean in the wait_connection method
Rather than require consumers handle the TimeoutError, handle it directly and return the connection state.

SIgned-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-28 12:45:50 -04:00
Eric Callahan 00f4bd594f app: prevent static file reads from blocking the event loop
Perform reads in a thread so File I/O does not block.

This patch also disables ETags for static files.  Tornado's default behavior of caching file hashes will not work as many of Moonraker's can be updated.  The previous workaround to this was to recalculate the checksum if the modified date changed.  This is inefficient  as its behavior is not much different than using "If-Modified-Since".

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-28 07:31:40 -04:00
Eric Callahan 3529acfeec proc_stats: report a blocked event loop
Use the PeriodicCallback in proc_stats to check if the event loop was blocked for a More than 5 seconds.  If this is detected, log
Moonraker's CPU usage over that time.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-27 17:10:49 -04:00
Eric Callahan 1510f66121 app: Process file uploads in a thread pool executor
This should prevent large file uploads from blocking the asyncio event loop for a long period of time.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-27 12:33:52 -04:00
Eric Callahan b6f9769488 websockets: refactor message handling
Implement a write buffer so that all calls to "write_message" are awaited.  This allows for more graceful shutdown if the websocket is closed.

When Moonraker shuts down, attempt to wait for all websockets to close before exiting.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-26 15:33:35 -04:00
Eric Callahan 0126aa794f mqtt: initial support for mqtt connections
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-26 08:10:32 -04:00
Eric Callahan 2bc7efd20e octoprint_compat: only register endpoints with the http transport
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-25 17:46:43 -04:00
Eric Callahan 566df69ca5 moonraker: expose additional app methods
Add references to the application's "get_websocket_manager" and "register_api_transport" methods.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-25 17:46:43 -04:00
Eric Callahan 40f21b10cd app: allow transport registration
This allows eligible components to register themselves as API transports.  By default the WebsocketManager is registered.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-25 17:46:43 -04:00
Eric Callahan a7801db6e7 websockets: Make the JsonRPC class more generic
Allow JsonRPC to be used with transports other than the websocket.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-25 17:46:43 -04:00
Eric Callahan 06bbca7ae3 moonraker: add method to set a component as failed
Some components require post-load initialization after the IOLoop has started.  Provide a method for these components to register a failure with the server.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-22 19:38:09 -04:00
Kamil Trzcinski 20673b9edd pause_resume: Make Moonraker to use `pause_resume/*` API
This switches Moonraker from calling `CANCEL_PRINT` and alikes
to rather use `pause_resume/` API that underneath calls
the relevant G-Codes.

This done, this way, allows Klipper to be able to interrupt
blocking operations gracefully.

Signed-off-by: Kamil Trzcinski <ayufan@ayufan.eu>
2021-06-15 12:22:43 -04:00
Rafael Schridi 3b4bfba85e Add variable domain support for Home Assistant
Defaults to the hard-coded "switch" domain used before

Signed-off-by:  Rafael Schridi <r.schridi@gmail.com>
2021-06-13 18:17:08 -04:00
Eric Callahan 42bdb42573 database: read out all namespaces on init
If a namespace contains an invalid key reading out the namespace should correct the issue.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-13 11:04:44 -04:00
Eric Callahan c9a958f861 database: track unsafe shutdowns
Keep track of the number of unsafe shutdowns a machine experiences.  This data is useful in diagnosing potential file system issues and issues with the datbase itself.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-13 09:15:09 -04:00
Eric Callahan 9a316fe84a database: check for invalid keys
It is invalid for a namespace to contain a top level key represented as an empty bytestring.  If this is detected, log the result and drop the invalid key.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-13 08:18:12 -04:00
Eric Callahan 92423911a9 file_manager: upload request fix
Make sure that inotify watches are added for new directories created via the upload endpoint.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-12 17:22:01 -04:00
Kamil Trzcinski 6770a965a6 history: add support for cancelled state
Signed-off-by: Kamil Trzcinski <ayufan@ayufan.eu>
2021-06-12 11:35:35 -04:00
Eric Callahan 9ea91f4f5d machine: report total memory from /proc/meminfo
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-10 19:58:11 -04:00
Eric Callahan 0b885ec5ec file_manager: scan metadata for renamed gcode files
Some slicers create a temporary file during export, then rename the file with gcode extension after completion.  If file metadata does not exist during an attempt to move metadata, scan the file.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-08 16:55:04 -04:00
Eric Callahan b16110bcd0 mooraker: refactor stop_server()
Shutdown the websocket and http server before doing final component cleanup.  This prevents clients from making a request after components have been closed.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-07 11:17:52 -04:00
Eric Callahan 936d766cae authorization: correctly handle the transition from a deprecated signature algorithm
SIgned-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-04 14:48:21 -04:00
Eric Callahan 39343f984a authorization: switch to EdDSA signatures
This removes the cryptography dependency in favor of libsodium.  Also removed is python-jose, as we must generate our own JWTs for use with EdDSA.

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

use libnacl instead of pynacl
2021-06-03 05:45:56 -04:00
Eric Callahan 628c0193f3 machine: extend allowed services
Allow all services that start with a match.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-06-02 17:46:34 -04:00
Eric Callahan def6b365fa machine: fix service case sensitivity bug
Systemd units are case sensitive, do not convert the "name" argument for service requests to lower case.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-31 07:34:16 -04:00
Eric Callahan 1b3efb1a78 machine: add support for controlling MoonCord and KlipperScreen services
Provide a list of available services in the `/machine/system_info` endpoint.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-30 14:21:07 -04:00
Alan Harper d6156dee68 power: Fix Home Assistant exception
Home Assistant returns an empty response when switching a switch
on or off. Will now requery the switch status and return it's result

Signed-off-by:  Alan Harper <alan@aussiegeek.net>
2021-05-29 14:12:20 -04:00
Alan Harper 541f5e54dc power: Add https support for Home Assistant
Signed-off-by:  Alan Harper <alan@aussiegeek.net>
2021-05-29 14:12:20 -04:00
Eric Callahan 793ab6b24b app: add a redirect endpoint
Clients can use this in situations where a browser may
prompt the user to take action prior to sending the
request.  After the user accepts, Moonraker will redirect the user to the url provided in the request.

SIgned-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-28 21:03:03 -04:00
Eric Callahan 082134b9a0 authorization: raise a 401 error in the event that a JWT failes decoding
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-28 18:26:32 -04:00
Arksine 2db727e40f file_manager: handle situations where file transfer is corrupt
The addition of inotify can introduce scenarios where file transfers complete abruptly, resulting in a corrupt/incomplete file.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-26 06:41:59 -04:00
Arksine fc5420db27 file_manager: filter out websocket notifcations in the gcodes root
Only push notifications for files with valid gcode extensions.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-26 06:32:31 -04:00
Arksine aeb24dabdb file_manager: add watches for hidden directories
The logic used to sync requests to modify contents in hidden directories is no longer necessary, thus removed.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-26 06:32:31 -04:00
Arksine 3d0d1e1dcb file_manager: disallow requests for paths outside of a root
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-26 06:31:47 -04:00
Arksine 5f7cff9af8 authorization: attempt to resolve cryptography import issues
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-24 07:25:31 -04:00
Arksine d7c367f095 update_manager: update pip before installing new python deps
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-24 06:38:10 -04:00
Arksine aa9641024a authorization: restrict CORS headers on non-options requests
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-23 20:36:26 -04:00
Arksine 60d6c748ef moonraker: rename deprecated "logging.warn"
Python uses "logging.warning" to log warning level methods.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-23 14:46:46 -04:00
Arksine dc4da6087f authorization: rename the oneshot request handler
Naming the method "_handle_oneshot_request" is less ambiguous than "_handle_token_request".

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-23 14:46:46 -04:00
Arksine 8a3b885eca authorization: use ES256 algorithm for JWT signatures
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-23 14:46:46 -04:00
Arksine ce7f659a32 authorization: use python_jose dependency for jwt management
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-23 09:09:53 -04:00
Arksine a18987aa59 app: raise an exception if configured ssl cert or key files do not exist
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-22 08:22:46 -04:00
Arksine dcf1cdf526 moonraker: add support for serving https with self signed certs
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-21 12:45:45 -04:00
Arksine 68b9a073af update_manager: compare file hashes rather than modified times
The metadata won't always depict an actual change to the content of a file.  Compare a hash of the file content rather than retrieve modified times to determine if it is necessary to install dependencies.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-21 08:58:40 -04:00
Arksine f1ba8e3d9b shell_command: Use a lock to prevent re-entrant calls
Re-entrant calls to "run" and "run_with_response" would poison the process state resulting in unexpected behavior.  Use a lock to prevent this.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-21 08:54:48 -04:00
Arksine e7193dbb5f shell_command: track running commands and cancel them prior to moonraker exit
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-21 08:54:48 -04:00
Arksine e15ef345bc shell_command: run_with_response fixes
Reset the command tracking data before each retry.  If the command is cancelled by the user immediately break.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-21 08:54:48 -04:00
Arksine 564e33bc18 update_manager: enhance attempt to recover from loose object errors
Attempt to recover from "loose object" error in git status and git fetch commands.   It is no longer necessary to run git fsck on every refresh attempt, only run it after a recovery attempt.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-21 08:54:48 -04:00
Arksine daa7b5edd4 update_manager: allow the remote method to run a generic command
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-21 08:54:48 -04:00
Arksine a012c4b772 update_manager: remove unused rsync methods
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-21 08:54:48 -04:00
Arksine 58f7aa0a57 update_manager: Implement clone method for GitRepo class
Replace the existing rsync "hard" recovery method with a call to git clone.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-21 08:54:48 -04:00
Arksine 81f2393b46 update_manager: Don't set the std_err_callback for async git commands
When no callback is set for stderr, the outputfrom stderr is piped to stdout.  This makes setting the callback redundant.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-21 08:54:48 -04:00
Arksine 5d783a743a app: re-enable authorization checks on static files
Image files (.png) are still granted unauthorized access, however all other files require that the request be authorized.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-20 17:07:48 -04:00
Arksine c335b62d26 file_manager: fix sync issues with hidden directories
While inotify watches are not applied to hidden directories it is still valid to use Moonraker's endpoints to perform operations on them.  When performing an operation on an item within a hidden directory, or on a hidden directory itself,  do not sync the request with inotify.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-20 08:35:26 -04:00
Arksine ceae5bb88b moonraker: report a 'warnings' field in "/server/info"
This allows clients to display a list of warnings that Moonraker detects.   Previously this info was only logged.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-19 20:37:36 -04:00
Arksine b8cf0d7fd2 authorization: check the query string for jwts
Clients may pass a json web token via the query string's "access_token" argument to authorize requests that do not allow modified headers.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-19 19:18:23 -04:00
Arksine dca7bd51cd authorization: add 'force_logins' option
When "force_logins" is enabled a user login is required if at least one user is registered, overriding the "trusted_clients" configuration.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-19 19:05:48 -04:00
Vladimir Poleh 6b9a3c656d app: Fixed download for the files with non-ASCII characters in name.
Replace non-ASCII characters with "?" and add escaped unicode version of the file name to the "Content-Disposition" header to fix problems with thumbnails and downloading for the gcode file with non-ASCII characters in filename.

Signed-off-by: Uladzimir Palekh <visor.rti@gmail.com>
2021-05-19 17:43:49 -04:00
Arksine f5ccddb52b file_manager: add support for an optional "logs" root
This root may be used to store log files for Klipper, Moonraker, and other applications as necessary.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-19 08:23:24 -04:00
Arksine dbe28751df file_manager: add annotations
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-19 06:59:38 -04:00
Arksine d392a895d9 update_manager: add annotations
USER CHANGE:  The deprecated "client_repo" and "client_path" options have been removed in this commit.  Use [update_manger client client_name] to configure clients.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-19 06:59:38 -04:00
Arksine 1026d59cad paneldue: add annotations
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-19 06:59:38 -04:00
Arksine 1ada457364 power: add annotiations
This includes a refactoring of the PowerDevice base class so that it defines some abstract methods that its children must implement.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-19 06:54:57 -04:00
Arksine 12246029ef proc_stats: add annotations
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:16:49 -04:00
Arksine c977948c2c octoprint_compat: add annotations
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:16:49 -04:00
Arksine 9994e1eb84 machine: Add annotations
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:16:49 -04:00
Arksine 1755d0f970 history: add annotations
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:16:49 -04:00
Arksine f5010e960b data_store: add annotations
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:16:49 -04:00
Arksine 9bf4ade35b klippy_apis: Add annotiations
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:16:49 -04:00
Arksine ce7495ecce shell_command: add annotations
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:16:49 -04:00
Arksine 41ddbb16a8 authorization: add annotations
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:16:49 -04:00
Arksine 410db750c6 database: add annotations
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:16:49 -04:00
Arksine b91df6642d app: add annotations
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:16:49 -04:00
Arksine 420ba065da confighelper: add annotations
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:16:48 -04:00
Arksine ca69a10838 moonraker: add annotations
Annotate function definitions, class attributes, and local variables as necessary for type hinting.  This is useful for IDEs with linters that support type hints and also can be used by GitHub Actions to detect erroneous code.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:16:48 -04:00
Arksine 9c76dbef7a websockets: add annotations
Implement a "Subscribable" base class for objects that can maintain a status subscription.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:16:48 -04:00
Arksine 96e69240ca utils: add annotations
Add a SentinelClass singleton.  This can be used to generate Sentinels by
modules that need to use the Sentinel pattern for default values.  This
allows for more robust type checking, as the Sentinel type should not be
included as a return value.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:16:48 -04:00
Arksine 6c27885702 file_manager: send "root_update" notification for all registered directories
This includes non mutable directories such as "config_examples" and "docs".

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine 316c6b5fa1 file_manager: rename "filename" field to "path" in "/server/files/list" request
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine 17a436bc27 file_manager: validate file extension before attempting to parse metadata
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine 93a29e0e34 file_manager: return more descriptive responses for op requests
File manager operations now return values similar to that of file change notifications.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine d46f04de0b file_manager: delete file trees in another thread
On slower platforms it is possible for this to take time and block the event loop.   Run shutil.rmtree in another thread to prevent this from occuring.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine 55941b106b file_manager: only run the operation check for files in the "gcodes" root
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine ebaf355878 file_manager: synchronize inotify events with api requests
If an inotify event is generated as the result of an API request, the notifications are synchronized so that they occur after the request returns.  Use a mutex to prevent multiple "write" requests processing concurrently.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine 21d290beb7 file_manager: implement metadata "move" functionality
If a file is moved from one location to another in the "gcodes" root it isn't necessary to rescan the file metadata as the underlying file information does not change.   Add the ability to change the metadata's key and move associated thumbnails when a file is moved.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine a9f1a98fa2 file_manager: remove metadata_update notifications
Since filelist_changed notifications are now delayed until after metadata is processed there is no need to send an additional metadata notification.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine 5fe9f1a217 file_manager: don't send filelist notifications until metadata is processed
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine 9da74f7bc6 file_manager: implement inotify using a bidirectional tree
Rather than tracking watch paths directly, wrap each watch in a node.  This makes makes it a bit easier to handle move and delete changes, as we don't have to manage several different dicts to store the information we need.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine e4d61de406 file_manager: bundle directory creation events
When a directory is created, attempt to suppress notifications generated as its children are created.
Wait until all items are copied before notifying clients and scanning metadata.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine 93fcd1ae86 file_manager: process copy requests in another thread
The copy methods are blocking and will block the asyncio event loop.  Run them in a  ThreadPoolExecutor to keep the event loop free.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine 9c31a360ee file_manager: remove child watches when a directory is stale
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine bb00825cd2 file_manager: bundle inotify delete events
When a directory is deleted this attempts to suppress delete events for all children.  Clients only need to be notified of the parent node, as its deletion implies all children have been deleted.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine c40c202220 file_manager: allow extract_metadata to unzip ufp files
This guarantees that .ufps will not be unzipped in parallel and offloads a potential blocking operation to another process.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine ecbf663b18 file_manager: make the thumbs directory hidden
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine 23dd001a9b file_manager: don't add inotify watches for hidden directories
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine 48607f8ab3 file_manager: allow inotify to exclusively handle gcode metadata and ufp files
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00
Arksine c2871d94ed file_manager: remove gcode metadata prune callback
Inotify keeps metadata in sync with the file system.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-05-18 19:12:54 -04:00