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>
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>
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>
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>
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>
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>
The result should be a dictionary of dictionaries rather than a
dictionary of SectionProxy objects.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
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>
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>
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>
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>
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>
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>
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>
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>
When the "none" provider is set service action APIs will be disabled
and return an error when called. Service state tracking is also
disabled.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
All requests to update, refresh, recover, or reinstall must acquire
the command lock. Given that the individual Deployment implementations
are not (and should not be) called from outside of a request the locks they
use to prevent unwanted re-entry are redundant, confusing, and could
potential result in a deadlock if used improperly.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This is added to distrubute the changes made to "enum-converter.py"
taken from the original PackageKit repo.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This allows for the inclusion of 3rd party Python Source
within the Moonraker package. Initially this includes
a python source file containing PackageKit enumerations.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>