Process
This document describes how the Anthias codebase is built and packaged for different platforms.
Balena Build Images
The build-balena-disk-image.yaml
workflow defines the steps for creating disk images for different Balena boards. This is achieved using the Balena CLI to build images.
- Workflow Trigger: The workflow is triggered manually using
workflow_dispatch
with the following input parameters:tag
: The release tag to be used. This is a required field and should be a string.commit
: The commit or branch name. This is optional and defaults tomaster
.
- Build Matrix: The
strategy.matrix
configuration allows for building images for different Balena boards:pi1
,pi2
,pi3
,pi4
- Build Environment: The workflow runs on Ubuntu 20.04 and requires the following permissions:
contents: write
: To checkout the code repositoryid-token: write
: To authenticate with Balena Cloudattestations: write
: To sign the built images
- Build Steps:
- Checkout: Check out the code repository using
actions/checkout@v4
. - Build Images: The workflow uses the Balena CLI to build images for each board defined in the
strategy.matrix
.
- Checkout: Check out the code repository using
Anthias App Migrations
The anthias_app/migrations
directory contains migrations for the Anthias database. These migrations are used to manage changes to the database schema over time.
- Migration 0001_initial: This migration creates the initial database schema, including the
Asset
model. - Migration 0002_auto_20241015_1524: This migration changes the field types for several fields in the
Asset
model to better represent the data:duration
: Changes fromTextField
toBigIntegerField
is_enabled
,is_processing
,nocache
,skip_asset_check
: Changes fromIntegerField
toBooleanField
Scheduler
The Scheduler
class, located in viewer.py
, is responsible for managing the playback of assets. It handles the following tasks:
- Initializing: The constructor initializes various properties, including the
assets
list,counter
,current_asset_id
,deadline
,extra_asset
,index
, andreverse
. It also callsupdate_playlist()
. - Getting the Next Asset: The
get_next_asset()
method retrieves the next asset to be played. It prioritizes processing any pendingextra_asset
before proceeding to the main playlist. - Refreshing the Playlist: The
refresh_playlist()
method checks for changes in the playlist and updates it accordingly. It considers:- Database modifications
- Shuffle playlist setting
- Asset deadlines
- Updating the Playlist: The
update_playlist()
method fetches the updated asset list and deadline fromgenerate_asset_list()
. It compares the updated assets and deadlines with the current ones and only updates the playlist if any changes are detected. It also resets thecounter
and adjusts theindex
to maintain the current position in the playlist. - Getting Database Last Modification Time: The
get_db_mtime()
method retrieves the last modification time of the database file.
Other Notable Code Snippets
get_next_asset()
Function: This function, located inviewer.py
, retrieves the next asset to be played based on the current playlist and settings.update_playlist()
Function: This function, located inviewer.py
, updates the playlist based on changes to the database or settings.wait.py
: This file contains code for waiting for a condition to be met.celery_tasks.py
: This file contains code for celery tasks.utils.py
: This file contains various utility functions, including aYoutubeDownloadThread
class that handles downloading YouTube videos.
Template Files
The templates/index.html
file defines the web interface for the Anthias player.
Anthias App Views
The anthias_app/views.py
file contains code for handling web requests. The system_info()
function provides information about the system, including:
- System Load: CPU load average
- Disk Space: Free disk space
- Memory Usage: Total, used, free, shared, buffered, and available memory
- Uptime: System uptime in days and hours
- Device Model: Device model based on CPU information
- Anthias Version: Anthias version and commit information
- MAC Address: The MAC address of the device
- Balena Flag: Indicates if the application is running on Balena
Project Structure
├── authias_app
│ ├── migrations
│ │ ├── 0001_initial.py
│ │ └── 0002_auto_20241015_1524.py
│ ├── models.py
│ ├── admin.py
│ ├── urls.py
│ ├── forms.py
│ ├── views.py
│ └── tests.py
├── media
│ └── static
│ └── anthias_app
│ └── css
│ └── styles.css
├── bin
│ ├── wait.py
│ └── build-balena-disk-image.py
└── lib
└── utils.py
Links
Top-Level Directory Explanations
.github/ - This directory contains GitHub-specific configuration files and workflows for the project.
.github/workflows/ - This directory contains YAML files defining continuous integration and deployment workflows for GitHub Actions.
ansible/ - Ansible is an open-source configuration management and automation tool. This directory contains Ansible playbooks and roles for managing and configuring the project.
ansible/roles/ - This directory contains Ansible roles, which are reusable collections of tasks and configurations for managing specific aspects of a system.
ansible/roles/network/ - This role manages network configurations.
ansible/roles/screenly/ - This role is specific to the Screenly project and likely contains configurations and tasks related to it.
ansible/roles/splashscreen/ - This role manages the configuration of a splash screen.
ansible/roles/system/ - This role manages system-level configurations.
anthias_app/ - This directory contains the main application codebase for the project, likely written in Django.
anthias_app/migrations/ - This directory contains database migration files for the Django application.
api/ - This directory contains the API codebase for the project.
api/serializers/ - This directory contains Django REST Framework serializers for converting data between Python objects and JSON.
api/views/ - This directory contains Django views for handling HTTP requests and rendering responses.
bin/ - This directory contains executable scripts for the project.
lib/ - This directory contains reusable Python modules and libraries for the project.
static/ - This directory contains static files, such as images, CSS, and JavaScript, that are served directly to the user by the web server.
static/spec/ - This directory contains test files for the static files.
static/spec/jasmine/ - This directory contains Jasmine test files.
templates/ - This directory contains HTML templates used to render dynamic content.
tests/ - This directory contains test files for the project.
tools/ - This directory contains tools and scripts used to develop and maintain the project.
tools/image_builder/ - This tool likely builds and optimizes images for the project.
website/ - This directory contains the website codebase.
website/bin/ - This directory contains website executable scripts.