Step-by-Step Configuration of Development Environment

1. Setting Up the Configuration Files

To configure your Anthias instance, begin by creating the necessary configuration files. The main configuration file is screenly.conf, located in the user’s home directory under a specific configuration directory. The class responsible for handling settings is AnthiasSettings, as defined in settings.py.

Example of initializing AnthiasSettings:

settings = AnthiasSettings()

The configuration directory and file paths are handled as follows:

def get_configdir(self):
    return path.join(self.home, CONFIG_DIR)

def get_configfile(self):
    return path.join(self.home, CONFIG_DIR, CONFIG_FILE)

Ensure that the configuration directory exists. If it does not, create it:

if not os.path.exists(CONFIG_DIR):
    os.mkdir(CONFIG_DIR)

2. Configuring Auth Backends

You can choose different authentication backends for your instance. The current implementation includes NoAuth() and BasicAuth(self):

self.auth_backends_list = [NoAuth(), BasicAuth(self)]

Each backend can be loaded with specific configurations. Handle the authentication backend selection within AnthiasSettings:

backend_name = self['auth_backend']
if backend_name in self.auth_backends:
    return self.auth_backends[self['auth_backend']]

3. Loading Configuration Files

Load the configuration using the load() method. This method parses screenly.conf:

def load(self):
    logging.debug('Reading config-file...')
    config = configparser.ConfigParser()
    config.read(self.conf_file)

    for section, defaults in list(DEFAULTS.items()):
        for field, default in list(defaults.items()):
            self._get(config, section, field, default)

4. Default Configuration and Saving Changes

If screenly.conf is missing, the system will use default settings. To save configurations, the save() method must be called after any modifications:

def save(self):
    config = configparser.ConfigParser()
    for section, defaults in list(DEFAULTS.items()):
        config.add_section(section)
        for field, default in list(defaults.items()):
            self._set(config, section, field, default)
    with open(self.conf_file, "w") as f:
        config.write(f)

5. Docker Configuration Options

If running within a Docker environment, configuration files or volume mounts can be defined in the docker-compose.yml. The following represents a snippet where assets and static files are included:

volumes:
  - /home/${USER}/.screenly:/data/.screenly:ro
  - /home/${USER}/screenly_assets:/data/screenly_assets:ro
  - /home/${USER}/screenly/staticfiles:/data/screenly/staticfiles:ro

6. WebSocket and Database Components

Understand the role of components such as anthias-websocket for handling network requests and redis for database caching. Ensure they are included in your Docker setup:

services:
  redis:
    image: screenly/anthias-redis:${DOCKER_TAG}-${DEVICE_TYPE}
    ports:
      - 127.0.0.1:6379:6379

7. Environment Variables and Paths

Utilize environment variables within the development environment for consistency:

export HOME="/path/to/user/home"

This affects how the AnthiasSettings class retrieves paths for configuration files.

8. Poetic Installation

Poetry is used for dependency management. Make sure Poetry is installed to manage packages effectively. Use the provided script:

./bin/install_poetry.sh

Follow this with the necessary adjustments in your shell configuration for adding Poetry to your path:

export PATH="$HOME/.local/bin:$PATH"

Finally, install the required dependencies:

poetry install --only=docker-image-builder

Summary

By following these configuration steps, expert developers can customize their Anthias installation effectively, ensuring a suitable setup for development and testing environments.

Source: docs/developer-documentation.md, settings.py, docker-compose.yml, docs/installation-options.md.