Previously this check was only on done when a directory was requested by the API. Moving this check to _list_directory ()updates metadata for internal calls as well.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
The slower system package update will now only executed by the auto-refresh routine. Moonraker will check for updates roughly every 2 hours, however system packages updates will only occur between 1am and 4am local time.
If a print is in progress any attempt to refresh or update will be aborted.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This should reduce the load on low perfomance devices. This also makes it possible to queue update requests.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Calls to "refresh" should not be allowed to occur while a client a current refresh is in progress. Updates will wait for a pending refresh to complete before beginning the update procedure.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
It is possible for the log files to be registered after a rollover, which can result in the file not existing. Force the log endpoints to register, bypassing the existance check.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Instead make sure that the supplied path is not the system root and check that moonraker has the appropriate privileges to access the directory.
Also track visited directories when retreiving a full file list to prevent infinite recursion.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This provides the update manager flexibility, such as the ability to define disto specific dependencies. This also fixes an issue where two updates are necessary to install additional dependencies.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This allows the config object to read additional config files as requred. Also implement a "get_options" method that can be used to retrive a dictionary of all options in the current section.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
After a repo has been updated fetching the remote is not needed, as it was just done in the prior update step.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Track rate limit attributes and reject requests when the user IP has reached their limit. Use conditional API requests to reduce the number of requests that count against the limit.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
It shouldn't be necessary to use gen.with_timeout during the fetch with tornado 6.1. Also fix some potential issues with unbound timeouts variables.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
The remote version info can be retrieved by simply doing a git fetch, then running "git rev-parse" and "git describe" on the desired remote branch.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Allow developers to update a detached git repo. Note that this option should not be used on production machines.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Clear partial output and cancelled attributes prior to each call of run(). This allows a command to be cleanly run again after a failure.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This allows Moonraker to update its paths to Klippy immediately upon a successful response from the info endpoint.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This will make klippy.log available in the event that Klippy has not successfully connected, assuming the log is available at the default location.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This allows for the installation of python "dist-packages" without enabling "system-site-packages" in the virtualenv. As of the moment moonraker only requires the gpiod dist package.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This may be useful for system packaging options that do not wish to put configuration in the home directory.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Before the service is restarted, check the local version. This should make sure that the local repo state is reported correctly after an update, regardless of the timing of a status request.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
It is possible that a status request can occur while an updater is checking intial state. Use an event to wait on initializing before returning the status request.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This resolves an issue where an unhandled exception is rasied when a websocket attempts to write to a closed websocket.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This implements two queues, one for commands that execute locally and a second
for gcode commands that execute on the Klippy host. While it is valid for a local
command to execute concurrently with a remote command, commands of the same type
(local or remote) should execute sequentially.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Update paneldue.py
Report that the PanelDue is "idle" until it is first initialized. This allows for the Macros to be set upon first connection
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Add a "get_return_code" method that allows users to fetch the return code after the shell command has executed.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This implementation adds a delay that allows for pip to function correclty after the venv is built.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
The current method for rebuilding the virtualenv fails. A potential workaround is to do the rebuild and subsequent update with a script. For now, disable the rebuild.
Signed-off-by: Eric Callahan <arskine.code@gmail.com>
This manager can perform updates on moonraker and klipper, assuming that the source is located in a valid git repo, the origin points to the official repo, and the currently selected branch is "master".
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This makes it possible for clients to hard restart an service in the event it becomes unresponsive.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This method collects the entire response and returns it with the call. Suitable for commands that produce little output.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This allows moonraker plugins to look up the stored info without needing to make an addition "info" request to Klippy.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Do not allow on, off, or status requests without arguments. Pass device objects to "power_device()" rather than device names.
Signed-off-by: Eric Callahan <arkine.code@gmail.com>
Devices are now configured using "prefix" sections. The pin configuration now more closely mimics that of Klipper's configuration so as to reduce confusion.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Only load the plugin for each prefix section once. Plugins themselves will be responsible for parsing the configuration from each prefix section.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Tornado clears the headers when an error is detected, "set_default_headers" must be overrridden so that errors are properly returned.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Rather than allow all origins as was the default with "enable_cors", users may not specify the domains allowed. If "*" is specified, all domains are allowed.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
GIven that subscriptions are reset, connected clients no longer maintained and they cannot check "webhooks.state" to see if Klippy is ready. This notifcation may be used to in its place.
SIgned-off-by: Eric Callahan <arksine.code@gmail.com>
Clients may provide arguments either in the query string or body. Reserved arguments "token" and "connection_id" are excluded from the result.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Some requests, such "printer/objects/subscribe", require a websocket
for asynchronous updates. Clients may now specify a "connection_id"
in the form data that identifies an associated websocket.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
There is no need to pass the auth, server, or websocket manager objects to request handlers. They can be retreived directly from the application reference.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This allows clients to "unsubscribe"by sending an empty dict. Each client will receive updates only for subscribed objects.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This class encapsulates all request data received from a client. This simplifies callbacks and makes it easier to add additional parameters to a client request.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This allows regsitered methods to be coroutines. Execution is done on the event loop to prevent a coroutine from blocking the incoming command queue.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This is a better description of the item parsed from _convert_path() is a path relative to the "root" directory.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Previously different parts of the file manager referred to name identifying a "root directory" as either base or root. This could lead to confusion, so all references are now "root".
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Since we need to walk through a file list each time one is requested there is no gain from storing lists locally.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Storage is now updated by individual calls to "parse_metadata()" instead of passing a full list. This will allow the manager to
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
If extended==True is passed to GET directory then the result for each gcode file will include associate metadata, if present.
SIgned-off-by: Eric Callahan <arksine.code@gmail.com>
Credit to GitHub user cdkeito for creating a template from which this implementation was inspired.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This method provides basic server information, such as loaded plugins and the state of the UDS connection to Klippy.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Now that the file_manager directly handles DELETE file requests, it is not necessary have the HTTP file handler perform any checks. Thus it is no longer required to pass a "can_delete" parameter.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This method is now the primary means of deleting files, as it includes checks to make sure that the delete is allowed.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Websocket APIs are now generated using traditional namespaces, for example "printer.gcode.script" rather than "post_printer_gcode_script". Local endpoints that register multiple requests methods will have the method prefixed (ie:. "server.files.get_directory", "server.files.post_directory", "server.files.delete_directory")
Signed-off-by: Eric Callahan
If the metadata script encoutners an error it will return an empty dict for the "metadata" item. Do not update the metadata storage or send a notification if the dict is empty.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Attempt to reconnect every 250ms when disconnected. Once connected, attempt to initialize every 250ms.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Move logic for managine metadata to its own class. Allow 3 retries if extraction fails, and send a printer event if metadata is updated due to an added file.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Logging to a file has the potential to block a the main thread, a QueueLogger resolves this by forwarding logging request to a secondary thread.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This optimized version should initialize faster as it doesn't rely on an additional Periodic Callback when Klippy is detected as ready.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Like gcode_apis, the klippy_apis module registers Web API aliases for particular gcodes. In addition, this module presents an interface where moonraker can call Klippy APIs directly.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This allows users to specify a "confirmed_macros" that wil pop up a message box requiring confirmation before proceeding. Useful for restart and firmware_restart to prevent accidental execution.
Also do not raise an exception when Klippy disconnects after a restart or firmware_restart.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
The make_request() method is now awaitable and returns the result directly vs the previous behavior of returning a request that was awaited.
There is no longer a need to check the result to see if it is an error, exceptions are raised if an error is detected.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
It is expected that the Klippy will disconnect when a restart request is sent. Handle those exceptions so they return an acknowledgement.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
There "check_available" endpoint no longer exists in Klippy, so use "objects/list" instead. If Klippy is not properly configured Moonraker will log the result.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This reduces the amount of code needed to handle the connection and adds more robust error handling. This also prepares moonraker for the eventual transition of Klippy hosting the server socket.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Rather than receive its configuration from Klippy, moonraker will receive its configuration from a config file. By default this file is located at ~/moonraker.conf.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>