72 Commits

Author SHA1 Message Date
Eric Callahan
0a8590643f
server: refactor startup
Use asyncio.run() to launch the server application as recommended
by the Python docs.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-08-08 16:29:01 -04:00
Eric Callahan
863d0c1e4b confighelper: don't resolve backup path
If the configuration file is a symbolic link we want the backup
generated in the config folder.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-08-08 15:02:13 -04:00
Eric Callahan
9beecbda92 confighelper: add getchoice method
This getter provides a pattern for configuring an item that
within a range of choices.

Signed-off-by:  Eric Callahan <arksine@gmail.com>
2024-07-24 07:37:08 -04:00
Eric Callahan
c5bf6e77a7
confighelper: type checking fix
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-05-14 20:08:40 -04:00
Eric Callahan
9c6048a759
confighelper: store deep copies of parsed options
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-05-14 18:05:19 -04:00
Eric Callahan
60f4a82873
confighelper: avoid direct import of JinjaTemplate
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-15 06:03:35 -05:00
Eric Callahan
dbbb07c68e
confighelper: clean up warnings
Don't generate additional "unparsed option" warnings when
a component fails to load.  When an error is encountered,
include the original error message in the subsequent
ConfigError.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-23 15:22:23 -05:00
Eric Callahan
ad1666bb2c
confighelper: add getgpioevent method
Use the ConfigHelper as an intermediary to register GPIO event
pins.  This allows for parsing exceptions to be captured and
properly re-raised as Config Errors.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-23 11:42:32 -05:00
Eric Callahan
327441fd6b
confighelper: fix linter errors
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-10-07 10:29:24 -04:00
Eric Callahan
4329241949
confighelper: fix inline comment parsing
Require that inline comments be separated from configuration
data by whitespace.  Unescape comment specifiers that follow
the correct escape sequence.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-10-06 12:25:26 -04:00
Eric Callahan
ad66831324
confighelper: getlists bugfix
If a valid "count" argument is received do not overwrite it
with "None" values.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-24 07:08:42 -05:00
Eric Callahan
2cda75ff2c
utils: simplify sentinel object
Use an enum to represent the sentinel rather than a singleton object.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-22 18:08:50 -05:00
Eric Callahan
e32fd688e4
moonraker: correct stale annotations
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-22 18:08:50 -05:00
Eric Callahan
b9a17e07e9
moonraker: convert code to a package
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-22 12:16:26 -05:00
Eric Callahan
a5d63db9a6
server: rename moonraker.py to server.py
Signed-off-by:  Eric Callahan <arksiine.code@gmail.com>
2023-02-21 18:05:01 -05:00
Eric Callahan
484950cb40
confighelper: implement getpath
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-11-06 10:51:30 -05:00
Eric Callahan
e8999363ed
confighelper: raise duplicate exceptions
Moonraker requires that the configuration be parsed in 'strict' mode,
ie: duplicate sections are not allowed within the same file and duplicate
options are not allowed within the same section.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-28 11:16:51 -04:00
Eric Callahan
0dd8eee034
confighelper: add method to write the config to any folder
Signed-off-by:  Eric Callahan <arksine.cod@gmail.com>
2022-08-21 05:19:27 -04:00
Eric Callahan
a4f9fbe298
confighelper: support config modification
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-08-21 05:19:12 -04:00
Eric Callahan
e264fa82b2
confighelper: don't overwrite option tracking
Its possible for any component to request a configuration
option from another component.  Don't overwrite the
inital value stored.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-07-26 19:34:40 -04:00
Eric Callahan
a178a6cd01
confighelper: improve file parsing
Process included files in the order they are added.  This changes how
duplicate sections throughout included files are merged, options in
the last section to be parsed will take precedent.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-07-26 19:34:39 -04:00
Eric Callahan
f8a38abc89
confighelper: Update the help url for moved options
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-20 07:13:26 -04:00
Eric Callahan
bf19bcecae
moonraker: report additional configuration info
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-06 08:26:32 -04:00
Eric Callahan
fc6714b30d
confighelper: backup the entire configuraiton
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-06 08:26:32 -04:00
Eric Callahan
ad00e08d11
confighelper: add support for include directives
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-06 08:26:31 -04:00
Eric Callahan
fb2eacf702
confighelper: make parsed a required argument
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-05 15:48:36 -04:00
Eric Callahan
ea25cce38f
confighelper: require core component sections
This is a reimplementation of commit d61540cad53c0ef1d018d5a9c73dff4ecbb2e8b8,
however this attempt provides a fallback for legacy configurations
that still have configuration in the server section.

This will change how `/server/config` reports configuration.  Options
will always be reported in their respective component's field, even if
they are currently configured in the `[server]` section.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-05 15:48:34 -04:00
Eric Callahan
f27daac4f4
confighelper: remove "orig section" tracking
This isn't necessary as we don't add new sections to the
original config object when parsing supplemental data.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 20:45:17 -04:00
Eric Callahan
ac6cf0fac7
Revert "confighelper: match core components to their configuration"
This reverts commit d61540cad53c0ef1d018d5a9c73dff4ecbb2e8b8.
2022-04-04 20:31:23 -04:00
Eric Callahan
7692197678
Revert "confighelper: remove "orig section" tracking"
This reverts commit 9c33eb225c14d69c89633a5933cd10fc3c5d6c07.
2022-04-04 20:31:06 -04:00
Eric Callahan
9c33eb225c
confighelper: remove "orig section" tracking
This isn't necessary as we don't add new sections to the
original config object when parsing supplemental data.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 15:26:16 -04:00
Eric Callahan
d61540cad5
confighelper: match core components to their configuration
Most core components have default options that allow them to
load without a section specified in moonraker.conf.  This resulted
in those options showing up in the [server] section in the
"/server/config" response.  These changes will make sure that those
values show up in the correct section.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 15:16:25 -04:00
Eric Callahan
54081612ca
confighelper: add a setoption method
This should only be used for internally generated configuration
that may change during runtime.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 11:46:21 -04:00
Eric Callahan
a4019bce8e
confighelper: add support for optional separators
If "None" is specified as a separator for getdict and the getlist
variants then strings will split along any whitespace character.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-04-04 11:46:20 -04:00
Eric Callahan
4a6732f13a
confighelper: implement method to read a dictionary
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-03-23 10:37:12 -04: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
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
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
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
3bd5f7edbd template: add support for async rendering
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-01-12 08:05:17 -05:00
Eric Callahan
a269de5dc0 confighelper: add load_template method
This is an alternative to gettemplate that always returns a
template.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-24 14:23:05 -05:00
Eric Callahan
a4f960d40c confighelper: implement deprecation
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-24 14:23:05 -05:00
Eric Callahan
e2b821e90c confighelper: add gettemplate method
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-12-14 17:51:12 -05:00
Eric Callahan
f7bdfb4d6b confighelper: add get_hash method
This returns the checksum of a config section and can be used to check
if the section has changed.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-28 11:15:23 -05:00
Eric Callahan
50fd8c9cc4 confighelper: track default values
This restores the behavior before commit 5b4de64.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-11-23 13:55:24 -05:00
Eric Callahan
0a1367744f confighelper: fix json parsing error for gpios
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2021-11-23 08:21:56 -05:00
Eric Callahan
845689fde1 confighelper: add getgpioout method
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-20 11:40:55 -05:00
Eric Callahan
0b25350ebc confighelper: add support for getlist and getdict
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-20 11:40:07 -05:00
Eric Callahan
c0ae10bef6 confighelper: add has_option method
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2021-11-20 11:38:37 -05:00