trading_agent.extensions.app_catalog
¶
The web apps that installed packages bring, and whether each is up.
An app is up when its page answers, which is checked by asking its health address with a short timeout; any answer below 500 counts, because an app that asks for a login still answers. Its unit's state comes from systemd.
Typical usage example:
catalog = AppCatalog(packages, SystemdUserUnits()) for app in catalog.apps(): status = await catalog.status(app)
InstalledApp
dataclass
¶
One package's app.
Attributes:
| Name | Type | Description |
|---|---|---|
package |
str
|
The package's name, which also names the app in addresses. |
folder |
Path
|
The installed package's folder. |
manifest |
AppManifest | None
|
The app's settings, or None when app.toml cannot be read. |
error |
str
|
Why app.toml cannot be read, or an empty string. |
AppStatus
dataclass
¶
Whether one app is up.
Attributes:
| Name | Type | Description |
|---|---|---|
healthy |
bool
|
Whether its page answered. |
health_detail |
str
|
The answer's status code, or why there was none. |
unit_state |
UnitState | None
|
Its unit's state, or None when it has no unit or systemd could not be asked. |
unit_error |
str
|
Why systemd could not be asked, or an empty string. |
AppCatalog
¶
Finds the apps of installed packages and checks them.
Creates the catalog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
packages
|
InstalledPackages
|
The installed packages. |
required |
units
|
SystemdUserUnits
|
Talks to systemd. |
required |
Source code in src/trading_agent/extensions/app_catalog.py
apps
¶
Every installed package that has an app.toml, read afresh.
Returns:
| Type | Description |
|---|---|
list[InstalledApp]
|
The apps, in package-name order. |
Source code in src/trading_agent/extensions/app_catalog.py
find
¶
Finds one package's app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package
|
str
|
The package's name. |
required |
Returns:
| Type | Description |
|---|---|
InstalledApp | None
|
The app, or None when that package has none. |
Source code in src/trading_agent/extensions/app_catalog.py
status
async
¶
Checks whether an app's page answers and asks systemd about its unit, both at once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app
|
InstalledApp
|
The app. |
required |
Returns:
| Type | Description |
|---|---|
AppStatus
|
The app's state. |