Config

class blueweather.config.Config(directory: str)

Bases: blueweather.config.objects.Config

load()

Load the config file

save()

Save the config file

serialize() → dict

Serialize the settings into a dictionary

Returns:settings
deserialize(data: dict)

Deserialize the settings from a dictionary

Parameters:data – settings

Schemas

The Schemas for the settings file.

This module contains all schemas for exporting and importing setings to the config.yml file.

class blueweather.config.schemas.ApiKey(*, only: Union[Sequence[str], Set[str], None] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict[KT, VT]] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)

Bases: marshmallow.schema.Schema

The APi Key Schema

class blueweather.config.schemas.SidebarItem(*, only: Union[Sequence[str], Set[str], None] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict[KT, VT]] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)

Bases: marshmallow.schema.Schema

The Sidebar Schema

category = None

The category for the Sidebar Item

value = None

The value for the Sidebar Item

class blueweather.config.schemas.Web(*, only: Union[Sequence[str], Set[str], None] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict[KT, VT]] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)

Bases: marshmallow.schema.Schema

The Web Schema

debug = None

Whether the server starts in debug mode

time_zone = None

The time zone of the server

allowed_hosts = None

The allowed hosts that the server will listen on.

database = None

The server database: custom_fields.Database

secret_key = None

The server’s secret key

sidebar = None

The sidebar settings: custom_fields.NamedList SidebarItem

frontend = None

The server’s frontend app

api_keys = None

The api keys that allow access to the api without needing to be logged in

class blueweather.config.schemas.System(*, only: Union[Sequence[str], Set[str], None] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict[KT, VT]] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)

Bases: marshmallow.schema.Schema

The System Schema

commands = None

A list of system commands

class blueweather.config.schemas.Plugins(*, only: Union[Sequence[str], Set[str], None] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict[KT, VT]] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)

Bases: marshmallow.schema.Schema

The Plugin Schema

weather_driver = None

The weather driver extension

enabled = None

A list of enabled plugins

class blueweather.config.schemas.Apps(*, only: Union[Sequence[str], Set[str], None] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict[KT, VT]] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)

Bases: marshmallow.schema.Schema

The Apps Schema

settings = None

A dictionary of plugin settings

class blueweather.config.schemas.Config(*, only: Union[Sequence[str], Set[str], None] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict[KT, VT]] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)

Bases: marshmallow.schema.Schema

The base Config Schema

web = None

Web

system = None

System

plugins = None

Plugins

apps = None

Apps

version = None

The version of settings

migrate(data: dict, **kwargs) → dict

Migrate the Config from previous versions

Custom Fields

class blueweather.config.custom_fields.ClassedList(cls, cls_or_instance, **kwargs)

Bases: marshmallow.fields.List

A List Field that deserializes to a custom List Object

class blueweather.config.custom_fields.APIKey(*, default: Any = <marshmallow.missing>, missing: Any = <marshmallow.missing>, data_key: Optional[str] = None, attribute: Optional[str] = None, validate: Union[Callable[[Any], Any], Iterable[Callable[[Any], Any]], None] = None, required: bool = False, allow_none: Optional[bool] = None, load_only: bool = False, dump_only: bool = False, error_messages: Optional[Dict[str, str]] = None, **metadata)

Bases: marshmallow.fields.String

A Uuid formatted string

class blueweather.config.custom_fields.ClassString(default_module=None, *args, **kwargs)

Bases: marshmallow.fields.String

Class String Name which can be prepended with a default module

class blueweather.config.custom_fields.NamedList(cls_or_instance, key_attr='name', value_attr='value', **kwargs)

Bases: marshmallow.fields.List

A data object that is serialized as a dictionary, and deserialized as a list of named objects

The output of the serialized data will look something like this

[
    {"key": {
        "val_key": "value",
        "other_data": "data"
    }}
    {"key": "value_only"},
    "key_only"
]

This isn’t very pretty, but looks very good in yaml

list:
- key:
    val_key: value
    other_data: data
- key: value_only
- key_only
class blueweather.config.custom_fields.Database(**kwargs)

Bases: marshmallow.fields.Dict

Database Setting field that deserializes to objects.Database

API

ReST API for accessing the settings

Config api prefix: /api/config/

api.interfaces()

Get the settings interface

Method:any
api.get_settings(label: str)

Get the current settings

Method:any
Name:get
Parameters:label (str) – plugin label
api.set_settings(label: str, settings: dict)

Set the Settings

Method:

POST

Name:

set

Parameters:
  • label (str) – plugin label
  • settings (dict) – settings
api.load()

Load the settings from disk

Method:any
api.apply()

Apply the settings to disk

Method:any