Add an additional checks to determine if a job needs to be cancelled when we receive a new "printing" state. A file name mismatch or a decrease in total_duration indicates a virtual sdcard reset.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Add GET and DELETE `/server/history/job` APIs and remvoe the `DELETE /server/history/delete` API. When returning a list of jobs, return it as an array rather than as a object. The `/server/history/list` API no longer accepts a job id.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This allows the repo init sequence to distinguish between a broken git repo and an invalid git repo.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
If a trusted IP address is passed as the origin then it is safe to assume that CORS access to this origin should be granted, but only if CORS is enabled by specifying at least one cors domain.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
A user may unintentionally allow access to dangerous domains if they place a wildcard in the top level domain portion of an entry. Raise a config error when this condition is detected.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Move git command functionality to its own class outside of the Updater class. This class is responsible for tracking repo state and executing commands on the repo. Fetch and Pull no longer use built in command timeouts, instead a callback is scheduled to see if the command returned progress. Only when no progress is returned will a fetch or pull be terminated after a timeout.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This class handles running shell commands and sending http API requests. Each updater class shares an instance of the command helper rather than the UpdateManager instance.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
In the "run()" method verbosity should still be allowed if log_stderr is True, even
if both callbacks are not set.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This allows plugins to interact with other plugins before they are closed. For example, a plugin may wish to save persistent state to the database before it is closed.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This handler provides consistent error reporting in the event that the client attempts to access an unknown endpoint. If the request is unauthorized, an 401 will be returned. Otherwise a 404 will be returned, however if CORS is available the CORS headers will be set.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Pass GIT_HTTP_LOW_SPEED_LIMIT and GIT_HTTP_LOW_SPEED_TIME environment variables to the "git fetch" and "git pull" commands. If the remote is unreachable this should force the command to timeout before Moonraker forcefully terminates it.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This brings consistency to the "run" methods. It also removes potential confusion between the previous "quiet" argument and the "verbose" argument in "run()".
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
A consumer of shell command can achieve "fire and forget" by scheduling the future returned by "run()" to execute on the event loop.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
It is now possible to redirect stderr to a callback for asynchronous message transfer. Also added is the env option, allowing custom environment variables to be passed to the subprocess.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Rather than use terminate to pre-emptively exit a shell command, attempt to exit with SIGINT, SIGTERM, and finally SIGKILL.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Moving log level init to the app module and have it explicitly set the level. This allows the logging level to be toggled with a server restart. Default debug logging to False.
When debug logging is disabled do not log HTTP requests.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Only report extruder and bed temperatures. Use dict "get()" methods to make sure that the fields are available.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This error is an indication that a JSON body was sent without the content type set to "application/json".
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
The prior implementations assumed that uploaded files would be buffered in memory.
This is no longer the case, so UFP extraction is more efficient when done straight to disk.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This PR is a minimal implementation of the Octoprint REST API that is required
for Cura to be able to establish a connection and send gcode/UFP files to
moonraker without errors.
Currently it only supports the "global apikey authentication" method.
Signed-off-by: Nickolas Grigoriadis <nagrigoriadis@gmail.com>