Commit Graph

1225 Commits

Author SHA1 Message Date
Eric Callahan 0d93cf2c39
docs: respect OctoPrint's case
Make sure that all references capitalize the "P" in OctoPrint.

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

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-26 10:48:52 -05:00
Eric Callahan 65e76aeec8
docs: document remote methods registered by machine
The "reboot_machine" and "shutdown_machine" remote methods may
be called from a Klipper gcode macro to accomplish their respective
tasks.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-26 10:48:52 -05:00
Eric Callahan ab09364a98
docs: provide additional context for the secrets module
Advise users to use unique credentials, and warn them that unattended
clients can be configured to steal credentials.

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

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

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

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

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

Signed-off-by: Pieter Willekens <me@pataar.nl>
2022-02-23 17:05:55 -05:00
Eric Callahan 501af62018 docs: update /server/info and /machine/system_info docs
These endpoints now return additional values.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-23 12:25:52 -05:00
Eric Callahan 1fbfb90500 tests: update test_server for changes to moonraker
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-23 12:01:50 -05:00
Eric Callahan 54f2ee61d0 machine: report the python version in system_info
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-23 12:01:50 -05:00
Eric Callahan 7679f8063f moonraker: remove the python version check
Moonraker depends on "future" annotations and uses fstrings, so
 versions of Python older than 3.7 will fail to load and never make
 it to the version check.

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

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-23 12:01:07 -05:00
th33xitus 8b8cb66481 readme: fix link for MainsailOS
readme: replace `Meteyou` with `Mainsail-Crew`

docs: replace `meteyou` with `mainsail-crew` in web_api.md

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
2022-02-23 10:24:39 -05:00
Eric Callahan 8ff54e2372 docs: update documenation for "power on queued" changes
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-23 09:13:54 -05:00
Eric Callahan 7ab1dda772 power: change behavior of "on when queued"
Rename the "on_when_upload_queued" option to "on_when_job_queued",
deprecate the former.  This option now applies to any queued job while
the device is off.

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

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 14:34:14 -05:00
Eric Callahan 86469903f3 tests: add database tests
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan 3edb4b1bad tests: add support for loading a database
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan f2f1d413d4 scripts: introduce dbtool
This tool may be used to backup and restore Moonraker's lmdb
database without depending on the "lmdb-utils" package.  The
backup is done to a plain text file in cdb format, so a backup
may be restored on any platform.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan 55baad1ad0 tests: rework path_args and klippy fixtures
Initialize the temporary directory in a "session_args" fixture that is session
scoped.  Move the Klippy process to a session scope, restarting the process
only when necessary.  This combination speeds up tests as it reduces disk
I/O and the overhead of starting the Klippy process for each test.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan 81f2418d78 tests: fix error in websocket_client fixture
A jsonrpc request is a notification when no ID is present.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan 348d45e87c tests: increase the timeout to 60 seconds
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan e6b4e54bea tests: fix the server pending tasks tests
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan 6946f67dbf tests: increase the klippy process timeout to 2.5 seconds
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan f7f487ac18 database: sort protected namespaces before storing them
This makes the order in which they are reported consistent,
as the namespaces are stored in a set.

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

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan 2b7a5ff035 tests: assign the WebsocketError to an static variable
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-22 07:47:38 -05:00
Eric Callahan d630b79e8b tests: http client fixes
Correctly encode the query string.  Use the query string for DELETE
requests in addition to GET requests.

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

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

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

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

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

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

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

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

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

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00