Commit Graph

1267 Commits

Author SHA1 Message Date
Eric Callahan ac55b95c1d database: Add unsafe shutdowns to the log rollover
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:57 -05:00
Eric Callahan 5f9706f6be test: initial testing framework
This adds the framework for unit testing Moonraker via pytest.
Initally only moonraker.py, klippy_connection.py, and confighelper.py
have acceptable coverage.  Coverage for other modules will be added on
an incremental basis, when most of Moonraker's source is covered tests
will be conducted via GitHub actions.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-17 11:19:41 -05:00
Lars Pöpperl 34f607c061
docs: add alternative sample file for home assistant
Signed-off-by: Lars Pöpperl  <lars.poepperl@gmail.com>
2022-02-17 11:03:30 -05:00
Simon Germain 11f4ae75cc
octoprint_compat: add webcam settings
Signed-off-by: Simon Germain <sgermain06@gmail.com>
2022-02-17 10:46:05 -05:00
Eric Callahan f79439aedd
funding: add a ko-fi button
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-16 05:44:10 -05:00
Eric Callahan c2861a1391 app: correct location header encoding
SIgned-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-15 14:39:33 -05:00
Eric Callahan e2d92b5575 confighelper: use read_file() rather than read()
The read() method will return an empty list if the file specified
does not exist or if the read failed in some fashion.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-15 11:42:50 -05:00
Eric Callahan 0e27a949af docs: update power documentation for "smartthings" devices
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-14 06:26:34 -05:00
Eric Callahan 10703321b0 power: fetch the Smart Things token option as a template
This allows users to store their token in a "secrets" file

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-14 06:19:37 -05:00
Mitch Gallman 0dc05eac76 docs: add smartthings power documentation
docs: add smartthings power documentation

Signed-off-by: Mitch Gallman <mitchell.gallman@gmail.com>
2022-02-14 06:12:52 -05:00
Mitch Gallman d01b8a9763 power: add support for smartthings switch
power: add support for smartthings switch

Signed-off-by: Mitch Gallman <mitchell.gallman@gmail.com>
2022-02-14 06:12:52 -05:00
Eric Callahan b60153c919 workflows: disable blank issues
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2022-02-13 20:50:22 -05:00
Eric Callahan ee11ed2a15 confighelper: fix the get_hash() method
Include the option's values in the hash.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-13 20:48:27 -05:00
Eric Callahan 9be93ff445 docs: add "info_tags" to update manager status
This also fixes some stale documentation.

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

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

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

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

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

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

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

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-04 18:14:46 -05:00
Eric Callahan a5c49e8742 moonraker: refactor init sequence
Don't load components and start the server from within the
__init__() method.  Break those out and call them in __main__().
This makes unit testing individual components possible.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-04 11:54:39 -05:00
Eric Callahan 35d8d88855 confighelper: remove direct component imports
Dont directly import components for instance checks.  Instead
check to see if the type is serializable, if not store the string
representation.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-04 11:20:31 -05:00
Eric Callahan f6d8de2cee utils: move config backup methods to confighelper
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-04 10:58:00 -05:00
pznamenskii 6749d3836e
docs: add Home Assistant camera example
Signed-off-by: Pavel Znamenskiy <[pznamenskii@gmail.com](mailto:pznamenskii@gmail.com)>
2022-02-03 19:17:11 -05:00
Eric Callahan 509759ba0d secrets: fix ConfigParser to Dict conversion
The result should be a dictionary of dictionaries rather than a
dictionary of SectionProxy objects.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-03 17:57:50 -05:00
Eric Callahan 5a966836b5 moonraker: backup the most recent working config
Attempt to take a backup of the configuration file if Moonraker
loads successfully and has not seen a config change.

If Moonraker fails to load due to a config error, attempt to fallback
to the backup configuration.  If that fails, exit the server.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-03 17:19:17 -05:00
Eric Callahan 4ec781d66b confighelper: minor cleanup in get_configuration
Its safer to let the attempt to read fail before additional error
checking.  Also there is no need to remove DEFAULT from
config.sections(), as it can't be there per the Python docs.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-03 12:19:29 -05:00
Eric Callahan ae8cab356b moonraker: gracefully handle invalid log paths
Don't exit the server if the log path is invalid.  Instead start
logging to stdout and add a warning for the user to
resolve.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-03 11:21:34 -05:00
Eric Callahan 305e002f8c docs: update docs for "klipper_device" power types
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-03 08:38:44 -05:00
Eric Callahan 0b13e2da44 power: add support for gcode_macro Klipper devices
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-02-03 08:14:48 -05:00
Matthew Humphrey aca7cb78b9 module: power
Add separate output_id configuration attribute for TPLink Smartplug device.

Signed-off-by:  Matthew Humphrey <mhumphrey@gmail.com>
2022-02-02 17:35:18 -05:00
Eric Callahan 10ac044485 scripts: add a --root argument to set-policykit-rules.sh
If a user specifies this then root is allowed to run the script.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-01-30 15:20:49 -05:00
Eric Callahan f616c83ebc docs: clarify PackageKit documentation
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-01-30 14:12:03 -05:00
Eric Callahan 5ec98cf0ba scripts: workaround pip 22.0 issues
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-01-30 14:08:13 -05:00
Eric Callahan de796a9ec7 app_deploy: don't update pip
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-01-30 12:14:09 -05:00
Eric Callahan 13591d0a5b scripts: do not allow set-policykit-rules.sh to run as root
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-01-29 14:07:15 -05:00
Eric Callahan b4ad6692e3 update_manager: fix klipper path regression
Commit 7401192 introduced a regression where the saved klipper
paths were not loaded into the Update object.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-01-29 11:03:08 -05:00
Pedro Lamas 287982acdd
power: initial support for Klipper Devices
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
2022-01-29 07:53:30 -05:00
Eric Callahan 7c8c0e715f scripts: update set-policykit-rules.sh
Check for the moonraker-admin Supplementary group
in the moonraker service file and add it if necessary.

For PolKit versions > 0.106 make sure that the process
is launched with the moonraker-admin group before
granting any polkit permissions.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-01-28 18:00:21 -05:00
Eric Callahan 468ea36bba scripts: update install-moonraker.sh
Add the "moonraker-admin" supplementary group to the service unit
file.  Check if polkit rules are available after installation, if not
advise the user that they may wish to run set-polkit-rules.sh.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-01-28 18:00:21 -05:00
Eric Callahan d396dbd2cb utils: add support for versioning shallow clones
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-01-28 18:00:21 -05:00
Eric Callahan 471885c3a2 git_deploy: add support for shallow clone tags
Shallow clones don't report the tag in git describe, so use
git rev-list to extract the tag and prepend it to the version
string.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-01-28 18:00:21 -05:00
Eric Callahan 7401192478 update_manager: store klipper paths in the database
If Klipper or its python executable is located at a custom path
this allows moonraker to instantiate its update on startup
rather than wait for Klipper to connect.  This also resolves an
issue where Klipper's update state is always refreshed on startup
when its located in a non-default path.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-01-28 18:00:21 -05:00