🤖 I have created a release *beep* *boop* --- ## [4.0.0](https://github.com/libretime/libretime/compare/3.2.0...4.0.0) (2024-01-07) ### ⚠ BREAKING CHANGES * The media file serving is now handled by Nginx instead of the API service. The `storage.path` field is now used in the Nginx configuration, so make sure to update the Nginx configuration file if you change it. * **installer:** The default listen port for the installer is now `8080`. We recommend that you put a reverse proxy in front of LibreTime. * **installer:** The `--update-nginx` flag was removed from the installer. The nginx configuration deployed by the installer will now always be overwritten. Make sure to move your customizations to a reverse proxy configuration. * The default system output (`stream.outputs.system[].kind`) changed from `alsa` to `pulseaudio`. Make sure to update your configuration file if you rely on the default system output. * The `general.secret_key` configuration field is now required. Make sure to update your configuration file and add a secret key. ### Features * default system output is now `pulseaudio` ([#2842](https://github.com/libretime/libretime/issues/2842)) ([ |
||
---|---|---|
.. | ||
libretime_shared | ||
tests | ||
Makefile | ||
README.md | ||
packages.ini | ||
pyproject.toml | ||
requirements.txt | ||
setup.py |
README.md
Shared
The libretime_shared
package contains reusable functions and classes for the LibreTime project.
Usage
This library assumes that:
- You will use
Click
to build a CLI for your app. - You will use
Pydantic
to validate objects in your app.
Configuration
First define a schema for your configuration in order to validate it. A schema is a class that inherit from pydantic.BaseModel
. Some existing schemas can be reused such as libretime_shared.config.RabbitMQ
or libretime_shared.config.Database
.
Load your configuration using a subclass of libretime_shared.config.BaseConfig
.
from pydantic import BaseModel
from libretime_shared.config import RabbitMQConfig, BaseConfig
class AnalyzerConfig(BaseModel):
bpm_enabled: bool = False
bpm_track_max_length: int
class Config(BaseConfig):
rabbitmq: RabbitMQConfig
analyzer: AnalyzerConfig
config = Config("/etc/libretime/config.yml")
Don't instantiate a sub model if it has a required field, otherwise the
Config
class import will raise aValidationError
.
CLI
Decorate your CLI commands with the shared decorators to add extra flags.
import click
from libretime_shared.cli import cli_logging_options, cli_config_options
from .app import App
@click.group()
def cli():
pass
@cli.command()
@cli_config_options()
@cli_logging_options()
def run(**kwargs):
app = App(**kwargs)
return app.run()