ahriman.models package
Submodules
ahriman.models.action module
- class Action(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
StrEnum
base action enumeration
ahriman.models.aur_package module
- class AURPackage(*, id: int, name: str, package_base_id: int, package_base: str, version: str, num_votes: int, popularity: float, first_submitted: ~datetime.datetime, last_modified: ~datetime.datetime, url_path: str, description: str = '', url: str | None = None, out_of_date: ~datetime.datetime | None = None, maintainer: str | None = None, submitter: str | None = None, repository: str = 'aur', depends: list[str] = <factory>, make_depends: list[str] = <factory>, opt_depends: list[str] = <factory>, check_depends: list[str] = <factory>, conflicts: list[str] = <factory>, provides: list[str] = <factory>, license: list[str] = <factory>, keywords: list[str] = <factory>)
Bases:
object
AUR package descriptor
- id
package ID
- Type:
int
- name
package name
- Type:
str
- package_base_id
package base ID
- Type:
int
- version
package base version
- Type:
str
- description
package base description
- Type:
str
- url
package upstream URL
- Type:
str | None
- num_votes
number of votes for the package
- Type:
int
- popularity
package popularity
- Type:
float
- out_of_date
package out of date timestamp if any
- Type:
datetime.datetime | None
- maintainer
package maintainer
- Type:
str | None
- submitter
package first submitter
- Type:
str | None
- first_submitted
timestamp of the first package submission
- Type:
datetime.datetime
- last_modified
timestamp of the last package submission
- Type:
datetime.datetime
- url_path
AUR package path
- Type:
str
- repository
repository name of the package
- Type:
str
- depends
list of package dependencies
- Type:
list[str]
- make_depends
list of package make dependencies
- Type:
l[str]
- opt_depends
list of package optional dependencies
- Type:
list[str]
- check_depends
list of package test dependencies
- Type:
list[str]
- conflicts
conflicts list for the package
- Type:
list[str]
- provides
list of packages which this package provides
- Type:
list[str]
- license
list of package licenses
- Type:
list[str]
- keywords
list of package keywords
- Type:
list[str]
Examples
Mainly this class must be used from class methods instead of default
__init__()
:>>> package = AURPackage.from_json(metadata) # load package from json dump >>> # ...or alternatively... >>> package = AURPackage.from_repo(metadata) # load package from official repository RPC >>> # properties of the class are built based on ones from AUR RPC, thus additional method is required >>> >>> from ahriman.core.alpm.pacman import Pacman >>> from ahriman.core.configuration import Configuration >>> from ahriman.models.repository_id import RepositoryId >>> >>> configuration = Configuration() >>> pacman = Pacman(RepositoryId("x86_64", "aur-clone"), configuration) >>> metadata = pacman.package_get("pacman") >>> package = AURPackage.from_pacman(next(metadata)) # load package from pyalpm wrapper
- static convert(descriptor: dict[str, Any]) dict[str, Any]
covert AUR RPC key names to package keys
- Parameters:
descriptor (dict[str, Any]) – RPC package descriptor
- Returns:
package descriptor with names converted to snake case
- Return type:
dict[str, Any]
- classmethod from_json(dump: dict[str, Any]) Self
construct package descriptor from RPC properties
- Parameters:
dump (dict[str, Any]) – json dump body
- Returns:
AUR package descriptor
- Return type:
Self
- classmethod from_pacman(package: pyalpm.Package) Self
construct package descriptor from official repository wrapper
- Parameters:
package (Package) – pyalpm package descriptor
- Returns:
AUR package descriptor
- Return type:
Self
- classmethod from_repo(dump: dict[str, Any]) Self
construct package descriptor from official repository RPC properties
- Parameters:
dump (dict[str, Any]) – json dump body
- Returns:
AUR package descriptor
- Return type:
Self
ahriman.models.auth_settings module
- class AuthSettings(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
StrEnum
web authorization type
- Disabled
(class attribute) authorization is disabled
- Type:
- Configuration
(class attribute) configuration based authorization
- Type:
- OAuth
(class attribute) OAuth based provider
- Type:
- static from_option(value: str) AuthSettings
construct value from configuration
- Parameters:
value (str) – configuration value
- Returns:
parsed value
- Return type:
- property is_enabled: bool
get enabled flag
- Returns:
False in case if authorization is disabled and True otherwise
- Return type:
bool
ahriman.models.build_status module
- class BuildStatus(status: ~ahriman.models.build_status.BuildStatusEnum = BuildStatusEnum.Unknown, timestamp: int = <factory>)
Bases:
object
build status holder
- status
build status
- Type:
- timestamp
build status update time
- Type:
int
- classmethod from_json(dump: dict[str, Any]) Self
construct status properties from json dump
- Parameters:
dump (dict[str, Any]) – json dump body
- Returns:
status properties
- Return type:
Self
- pretty_print() str
generate pretty string representation
- Returns:
print-friendly string
- Return type:
str
- view() dict[str, Any]
generate json status view
- Returns:
json-friendly dictionary
- Return type:
dict[str, Any]
- class BuildStatusEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
StrEnum
build status enumeration
- Unknown
(class attribute) build status is unknown
- Type:
- Pending
(class attribute) package is out-of-dated and will be built soon
- Type:
- Building
(class attribute) package is building right now
- Type:
- Failed
(class attribute) package build failed
- Type:
- Success
(class attribute) package has been built without errors
- Type:
ahriman.models.changes module
- class Changes(last_commit_sha: str | None = None, changes: str | None = None)
Bases:
object
package source files changes holder
- last_commit_sha
last commit hash
- Type:
str | None
- changes
package change since the last commit if available
- Type:
str | None
- classmethod from_json(dump: dict[str, Any]) Self
construct changes from the json dump
- Parameters:
dump (dict[str, Any]) – json dump body
- Returns:
changes object
- Return type:
Self
- view() dict[str, Any]
generate json change view
- Returns:
json-friendly dictionary
- Return type:
dict[str, Any]
- property is_empty: bool
validate that changes are not empty
- Returns:
True
in case if changes are not set andFalse
otherwise- Return type:
bool
ahriman.models.context_key module
ahriman.models.counters module
- class Counters(*, total: int, unknown: int = 0, pending: int = 0, building: int = 0, failed: int = 0, success: int = 0)
Bases:
object
package counters
- total
total packages count
- Type:
int
- unknown
packages in unknown status count
- Type:
int
- pending
packages in pending status count
- Type:
int
- building
packages in building status count
- Type:
int
- failed
packages in failed status count
- Type:
int
- success
packages in success status count
- Type:
int
- classmethod from_json(dump: dict[str, Any]) Self
construct counters from json dump
- Parameters:
dump (dict[str, Any]) – json dump body
- Returns:
status counters
- Return type:
Self
- classmethod from_packages(packages: list[tuple[Package, BuildStatus]]) Self
construct counters from packages statuses
- Parameters:
packages (list[tuple[Package, BuildStatus]]) – list of package and their status as per watcher property
- Returns:
status counters
- Return type:
Self
ahriman.models.internal_status module
- class InternalStatus(*, status: BuildStatus, architecture: str | None = None, packages: Counters = Counters(total=0, unknown=0, pending=0, building=0, failed=0, success=0), repository: str | None = None, version: str | None = None)
Bases:
object
internal server status
- status
service status
- Type:
- architecture
repository architecture
- Type:
str | None
- repository
repository name
- Type:
str | None
- version
service version
- Type:
str | None
- classmethod from_json(dump: dict[str, Any]) Self
construct internal status from json dump
- Parameters:
dump (dict[str, Any]) – json dump body
- Returns:
internal status
- Return type:
Self
- view() dict[str, Any]
generate json status view
- Returns:
json-friendly dictionary
- Return type:
dict[str, Any]
ahriman.models.log_handler module
- class LogHandler(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
StrEnum
log handler as described by default configuration
- Console
(class attribute) write logs to console
- Type:
- Syslog
(class attribute) write logs to syslog device /dev/null
- Type:
- Journald
(class attribute) write logs to journald directly
- Type:
ahriman.models.log_record_id module
ahriman.models.migration module
- class Migration(*, index: int, name: str, steps: list[str], migrate_data: Callable[[Connection, Configuration], None])
Bases:
object
migration implementation
- index
migration position
- Type:
int
- name
migration name
- Type:
str
- steps
migration steps
- Type:
list[str]
- migrate_data
data migration callback
- Type:
Callable[[Connection, Configuration], None]
ahriman.models.migration_result module
- class MigrationResult(*, old_version: int, new_version: int)
Bases:
object
migration result implementation model
- old_version
old schema version before migrations
- Type:
int
- new_version
new schema version after migrations
- Type:
int
- validate() None
perform version validation
- Raises:
MigrationError – if old version is newer than new one or negative
- property is_outdated: bool
check migration and check if there are pending migrations
- Returns:
True in case if it requires migrations and False otherwise
- Return type:
bool
ahriman.models.package module
- class Package(*, base: str, version: str, remote: RemoteSource, packages: dict[str, PackageDescription], packager: str | None = None)
Bases:
LazyLogging
package properties representation
- base
package base name
- Type:
str
- packager
package packager if available
- Type:
str | None
- packages
map of package names to their properties. Filled only on load from archive
- Type:
dict[str, PackageDescription
- remote
package remote source if applicable
- Type:
- version
package full version
- Type:
str
Examples
Different usages of this class may generate different (incomplete) data, e.g. if instantiating class from json:
>>> package = Package.from_json(dump)
it will contain every data available in the json body. Otherwise, if generate package from local archive:
>>> package = Package.from_archive(local_path, pacman)
it will probably miss file descriptions (in case if there are multiple packages which belong to the base).
The specific class load method must be defined based on the source provided. The following methods (mostly) must be used:
from_archive()
,from_aur()
,from_build()
,from_official()
for sourcesahriman.models.package_source.PackageSource.Archive
,ahriman.models.package_source.PackageSource.AUR
,ahriman.models.package_source.PackageSource.Local
andahriman.models.package_source.PackageSource.Repository
repsectively:>>> ahriman_package = Package.from_aur("ahriman") >>> pacman_package = Package.from_official("pacman", pacman)
- actual_version(paths: RepositoryPaths) str
additional method to handle VCS package versions
- Parameters:
paths (RepositoryPaths) – repository paths instance
- Returns:
package version if package is not VCS and current version according to VCS otherwise
- Return type:
str
- Raises:
PackageInfoError – if there are parsing errors
- classmethod from_archive(path: Path, pacman: Pacman) Self
construct package properties from package archive
- Parameters:
path (Path) – path to package archive
pacman (Pacman) – alpm wrapper instance
- Returns:
package properties
- Return type:
Self
- classmethod from_aur(name: str, packager: str | None = None) Self
construct package properties from AUR page
- Parameters:
name (str) – package name (either base or normal name)
packager (str | None, optional) – packager to be used for this build (Default value = None)
- Returns:
package properties
- Return type:
Self
- classmethod from_build(path: Path, architecture: str, packager: str | None = None) Self
construct package properties from sources directory
- Parameters:
path (Path) – path to package sources directory
architecture (str) – load package for specific architecture
packager (str | None, optional) – packager to be used for this build (Default value = None)
- Returns:
package properties
- Return type:
Self
- Raises:
PackageInfoError – if there are parsing errors
- classmethod from_json(dump: dict[str, Any]) Self
construct package properties from json dump
- Parameters:
dump (dict[str, Any]) – json dump body
- Returns:
package properties
- Return type:
Self
- classmethod from_official(name: str, pacman: Pacman, packager: str | None = None, *, use_syncdb: bool = True) Self
construct package properties from official repository page
- Parameters:
name (str) – package name (either base or normal name)
pacman (Pacman) – alpm wrapper instance
packager (str | None, optional) – packager to be used for this build (Default value = None)
use_syncdb (bool, optional) – use pacman databases instead of official repositories RPC (Default value = True)
- Returns:
package properties
- Return type:
Self
- full_depends(pacman: Pacman, packages: Iterable[Package]) list[str]
generate full dependencies list including transitive dependencies
- is_newer_than(timestamp: float | int) bool
check if package was built after the specified timestamp
- Parameters:
timestamp (float | int) – timestamp to check build date against
- Returns:
True in case if package was built after the specified date and False otherwise. In case if build date is not set by any of packages, it returns False
- Return type:
bool
- is_outdated(remote: Package, paths: RepositoryPaths, *, vcs_allowed_age: float | int = 0, calculate_version: bool = True) bool
check if package is out-of-dated
- Parameters:
remote (Package) – package properties from remote source
paths (RepositoryPaths) – repository paths instance. Required for VCS packages cache
vcs_allowed_age (float | int, optional) – max age of the built packages before they will be forced to calculate actual version (Default value = 0)
calculate_version (bool, optional) – expand version to actual value (by calculating git versions) (Default value = True)
- Returns:
True if the package is out-of-dated and False otherwise
- Return type:
bool
- static local_files(path: Path) Generator[Path, None, None]
extract list of local files
- Parameters:
path (Path) – path to package sources directory
- Yields:
Path –
- list of paths of files which belong to the package and distributed together with this tarball.
All paths are relative to the
path
- Raises:
PackageInfoError – if there are parsing errors
- next_pkgrel(local_version: str) str | None
generate next pkgrel variable. The package release will be incremented if
local_version
is more or equal to theversion
; in this case the function will return new pkgrel value, otherwiseNone
will be returned- Parameters:
local_version (str) – locally stored package version
- Returns:
- new generated package release version if any. In case if the release contains dot (e.g. 1.2),
the minor part will be incremented by 1. If the release does not contain major.minor notation, the minor version equals to 1 will be appended
- Return type:
str | None
- pretty_print() str
generate pretty string representation
- Returns:
print-friendly string
- Return type:
str
- static supported_architectures(path: Path) set[str]
load supported architectures from package sources
- Parameters:
path (Path) – path to package sources directory
- Returns:
list of package supported architectures
- Return type:
set[str]
- Raises:
PackageInfoError – if there are parsing errors
- view() dict[str, Any]
generate json package view
- Returns:
json-friendly dictionary
- Return type:
dict[str, Any]
- property depends: list[str]
get package base dependencies
- Returns:
sum of dependencies per each package
- Return type:
list[str]
- property depends_build: set[str]
get full list of external dependencies which has to be installed for build process
- Returns:
full dependencies list used by devtools
- Return type:
set[str]
- property depends_check: list[str]
get package test dependencies
- Returns:
sum of test dependencies per each package
- Return type:
list[str]
- property depends_make: list[str]
get package make dependencies
- Returns:
sum of make dependencies per each package
- Return type:
list[str]
- property depends_opt: list[str]
get package optional dependencies
- Returns:
sum of optional dependencies per each package
- Return type:
list[str]
- property groups: list[str]
get package base groups
- Returns:
sum of groups per each package
- Return type:
list[str]
- property is_single_package: bool
is it possible to transform package base to single package or not
- Returns:
true in case if this base has only one package with the same name
- Return type:
bool
- property is_vcs: bool
get VCS flag based on the package base
- Returns:
True in case if package base looks like VCS package and False otherwise
- Return type:
bool
- property licenses: list[str]
get package base licenses
- Returns:
sum of licenses per each package
- Return type:
list[str]
- property packages_full: list[str]
get full packages list including provides
- Returns:
full list of packages which this base contains
- Return type:
list[str]
ahriman.models.package_description module
- class PackageDescription(*, architecture: str | None = None, archive_size: int | None = None, build_date: int | None = None, depends: list[str] = <factory>, make_depends: list[str] = <factory>, opt_depends: list[str] = <factory>, check_depends: list[str] = <factory>, description: str | None = None, filename: str | None = None, groups: list[str] = <factory>, installed_size: int | None = None, licenses: list[str] = <factory>, provides: list[str] = <factory>, url: str | None = None)
Bases:
object
package specific properties
- architecture
package architecture
- Type:
str | None
- archive_size
package archive size
- Type:
int | None
- build_date
package build date
- Type:
int | None
- check_depends
package dependencies list used for check functions
- Type:
list[str]
- depends
package dependencies list
- Type:
list[str]
- opt_depends
optional package dependencies list
- Type:
list[str]
- make_depends
package dependencies list used for building
- Type:
list[str]
- description
package description
- Type:
str | None
- filename
package archive name
- Type:
str | None
- groups
package groups
- Type:
list[str]
- installed_size
package installed size
- Type:
int | None
- licenses
package licenses list
- Type:
list[str]
- provides
list of provided packages
- Type:
list[str]
- url
package url
- Type:
str | None
Examples
Unlike the
ahriman.models.package.Package
class, this implementation only holds properties. The recommended way to deal with it is to read data based on the source type - either json orpyalpm.Package
instance:>>> description = PackageDescription.from_json(dump) >>> >>> from pathlib import Path >>> from ahriman.core.alpm.pacman import Pacman >>> from ahriman.core.configuration import Configuration >>> from ahriman.models.repository_id import RepositoryId >>> >>> configuration = Configuration() >>> pacman = Pacman(RepositoryId("x86_64", "aur-clone"), configuration) >>> pyalpm_description = next(package for package in pacman.package_get("pacman")) >>> description = PackageDescription.from_package( >>> pyalpm_description, Path("/var/cache/pacman/pkg/pacman-6.0.1-4-x86_64.pkg.tar.zst"))
- classmethod from_aur(package: AURPackage) Self
construct properties from AUR package model
- Parameters:
package (AURPackage) – AUR package model
- Returns:
package properties based on source AUR package
- Return type:
Self
- classmethod from_json(dump: dict[str, Any]) Self
construct package properties from json dump
- Parameters:
dump (dict[str, Any]) – json dump body
- Returns:
package properties
- Return type:
Self
- classmethod from_package(package: pyalpm.Package, path: Path) Self
construct class from alpm package class
- Parameters:
package (Package) – alpm generated object
path (Path) – path to package archive
- Returns:
package properties based on tarball
- Return type:
Self
- view() dict[str, Any]
generate json package view
- Returns:
json-friendly dictionary
- Return type:
dict[str, Any]
- property filepath: Path | None
wrapper for filename, convert it to Path object
- Returns:
path object for current filename
- Return type:
Path | None
ahriman.models.package_source module
- class PackageSource(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
StrEnum
package source for addition enumeration
- Auto
(class attribute) automatically determine type of the source
- Type:
- Archive
(class attribute) source is a package archive
- Type:
- AUR
(class attribute) source is an AUR package for which it should search
- Type:
- Directory
(class attribute) source is a directory which contains packages
- Type:
- Local
(class attribute) source is locally stored PKGBUILD
- Type:
- Remote
(class attribute) source is remote (http, ftp etc…) link
- Type:
- Repository
(class attribute) source is official repository
- Type:
Examples
In case if source is unknown the
resolve()
and the source descriptor is available method must be used:>>> real_source = PackageSource.Auto.resolve("ahriman", configuration.repository_paths)
the code above will ensure that the presudo-source
Auto
will not be processed later.- resolve(source: str, paths: RepositoryPaths) PackageSource
resolve auto into the correct type
- Parameters:
source (str) – source of the package
paths (RepositoryPaths) – repository paths instance
- Returns:
non-auto type of the package source
- Return type:
ahriman.models.packagers module
- class Packagers(default: str | None = None, overrides: dict[str, str | None] = <factory>)
Bases:
object
holder for packagers overrides
- default
default packager username if any to be used if no override for the specified base was found
- Type:
str | None
- overrides
dict[str, str | None]: packager username override for specific package base
- Type:
dict[str, str | None]
- for_base(package_base: str) str | None
extract username for the specified package base
- Parameters:
package_base (str) – package base to lookup
- Returns:
package base override if set and default packager username otherwise
- Return type:
str | None
ahriman.models.pacman_synchronization module
- class PacmanSynchronization(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
IntEnum
pacman database synchronization flag
- Disabled
(class attribute) do not synchronize local database
- Type:
- Enabled
(class attribute) synchronize local database (same as pacman -Sy)
- Type:
- Force
(class attribute) force synchronize local database (same as pacman -Syy)
- Type:
ahriman.models.pkgbuild_patch module
- class PkgbuildPatch(key: str | None, value: str | list[str])
Bases:
object
wrapper for patching PKBGUILDs
- key
name of the property in PKGBUILD, e.g. version, url etc. If not set, patch will be considered as full PKGBUILD diffs
- Type:
str | None
- value
value of the stored PKGBUILD property. It must be either string or list of string values
- Type:
str | list[str]
- classmethod from_env(variable: str) Self
construct patch from environment variable. Functions are not supported
- Parameters:
variable (str) – variable in bash form, i.e. KEY=VALUE
- Returns:
package properties
- Return type:
Self
- quote()
Return a shell-escaped version of the string s.
- serialize() str
serialize key-value pair into PKGBUILD string. List values will be put inside parentheses. All string values (including the ones inside list values) will be put inside quotes, no shell variables expanding supported at the moment
- Returns:
serialized key-value pair, print-friendly
- Return type:
str
- view() dict[str, Any]
generate json patch view
- Returns:
json-friendly dictionary
- Return type:
dict[str, Any]
- write(pkgbuild_path: Path) None
write serialized value into PKGBUILD by specified path
- Parameters:
pkgbuild_path (Path) – path to PKGBUILD file
- property is_function: bool
parse key and define whether it function or not
- Returns:
True in case if key ends with parentheses and False otherwise
- Return type:
bool
- property is_plain_diff: bool
check if patch is full diff one or just single-variable patch
- Returns:
True in case key set and False otherwise
- Return type:
bool
ahriman.models.process_status module
ahriman.models.property module
- class Property(name: str, value: Any, indent: int = 1, *, is_required: bool = False)
Bases:
object
holder of object properties descriptor
- name
name of the property
- Type:
str
- value
property value
- Type:
Any
- is_required
if set to True then this property is required
- Type:
bool
- indent
property indentation level
- Type:
int
ahriman.models.remote_source module
- class RemoteSource(*, source: PackageSource, git_url: str | None = None, web_url: str | None = None, path: str | None = None, branch: str | None = None)
Bases:
object
remote package source properties
- branch
branch of the git repository
- Type:
str | None
- git_url
url of the git repository
- Type:
str | None
- path
path to directory with PKGBUILD inside the git repository
- Type:
str | None
- source
package source pointer used by some parsers
- Type:
- web_url
url of the package in the web interface
- Type:
str | None
- classmethod from_json(dump: dict[str, Any]) Self
construct remote source from the json dump (or database row)
- Parameters:
dump (dict[str, Any]) – json dump body
- Returns:
remote source
- Return type:
Self
- git_source() tuple[str, str]
get git source if available
- Returns:
git url and branch
- Return type:
tuple[str, str]
- Raises:
InitializeError – in case if git url and/or branch are not set
- view() dict[str, Any]
generate json package remote view
- Returns:
json-friendly dictionary
- Return type:
dict[str, Any]
- property is_remote: bool
check if source is remote
- Returns:
True in case if package is well-known remote source (e.g. AUR) and False otherwise
- Return type:
bool
- property pkgbuild_dir: Path | None
get path to directory with package sources (PKGBUILD etc.)
- Returns:
path to directory with package sources based on settings if available
- Return type:
Path | None
ahriman.models.report_settings module
- class ReportSettings(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
StrEnum
report targets enumeration
- Disabled
(class attribute) option which generates no report for testing purpose
- Type:
- HTML
(class attribute) html report generation
- Type:
- Email
(class attribute) email report generation
- Type:
- Console
(class attribute) print result to console
- Type:
- Telegram
(class attribute) markdown report to telegram channel
- Type:
- RemoteCall
(class attribute) remote ahriman server call
- Type:
- static from_option(value: str) ReportSettings
construct value from configuration
- Parameters:
value (str) – configuration value
- Returns:
parsed value
- Return type:
ahriman.models.repository_id module
- class RepositoryId(architecture: str, name: str)
Bases:
object
unique identifier of the repository
- architecture
repository architecture
- Type:
str
- name
repository name
- Type:
str
- query() list[tuple[str, str]]
generate query parameters
- Returns:
json view as query parameters
- Return type:
list[tuple[str, str]]
- view() dict[str, Any]
generate json package view
- Returns:
json-friendly dictionary
- Return type:
dict[str, Any]
- property id: str
get repository id to be used for databases
- Returns:
unique id for this repository
- Return type:
str
- property is_empty: bool
check if all data is supplied for the loading
- Returns:
True in case if architecture or name are not set and False otherwise
- Return type:
bool
ahriman.models.repository_paths module
- class RepositoryPaths(root: Path, repository_id: RepositoryId, *, _force_current_tree: bool = False)
Bases:
LazyLogging
repository paths holder. For the most operations with paths you want to use this object
- repository_id
repository unique identifier
- Type:
- root
repository root (i.e. ahriman home)
- Type:
Path
Examples
This class can be used in order to access the repository tree structure:
>>> paths = RepositoryPaths(Path("/var/lib/ahriman"), RepositoryId("x86_64", "aur-clone"))
Additional methods can be used in order to ensure that tree is created:
>>> paths.tree_create()
Access to directories inside can be done by either using properties or specifying the package base:
>>> cache_dir = paths.cache >>> ahriman_cache_dir = paths.cache_for("ahriman")
- cache_for(package_base: str) Path
get path to cached PKGBUILD and package sources for the package base
- Parameters:
package_base (str) – package base name
- Returns:
full path to directory for specified package base cache
- Return type:
Path
- chown(path: Path) None
set owner of path recursively (from root) to root owner
- Parameters:
path (Path) – path to be chown
- Raises:
PathError – if path does not belong to root
- classmethod known_architectures(root: Path, name: str = '') set[str]
get known architecture names
- Parameters:
root (Path) – repository root
name (str, optional) – repository name (Default value = “”)
- Returns:
list of repository architectures for which there is created tree
- Return type:
set[str]
- classmethod known_repositories(root: Path) set[str]
get known repository names
- Parameters:
root (Path) – repository root
- Returns:
list of repository names for which there is created tree. Returns empty set in case if repository is loaded in legacy mode
- Return type:
set[str]
- static owner(path: Path) tuple[int, int]
retrieve owner information by path
- Parameters:
path (Path) – path for which extract ids
- Returns:
owner user and group ids of the directory
- Return type:
tuple[int, int]
- tree_clear(package_base: str) None
clear package specific files
- Parameters:
package_base (str) – package base name
- tree_create() None
create ahriman working tree
- property cache: Path
get directory for packages cache (mainly used for VCS packages)
- Returns:
full path to cache directory
- Return type:
Path
- property chroot: Path
get directory for devtools chroot
- Returns:
full patch to devtools chroot directory
- Return type:
Path
- property packages: Path
get directory for built packages
- Returns:
full path to built packages directory
- Return type:
Path
- property pacman: Path
get directory for pacman local package cache
- Returns:
full path to pacman local database cache
- Return type:
Path
- property repository: Path
get repository directory
- Returns:
full path to the repository directory
- Return type:
Path
- property root_owner: tuple[int, int]
get UID and GID of the root directory
- Returns:
owner user and group of the root directory
- Return type:
tuple[int, int]
ahriman.models.result module
- class Result(*, added: Iterable[Package] | None = None, updated: Iterable[Package] | None = None, removed: Iterable[Package] | None = None, failed: Iterable[Package] | None = None)
Bases:
object
build result class holder
- STATUS_PRIORITIES
(class attribute) list of statues according to their priorities
- Type:
list[str]
default constructor
- Parameters:
added (Iterable[Package] | None, optional) – initial list of successfully added packages (Default value = None)
updated (Iterable[Package] | None, optional) – initial list of successfully updated packages (Default value = None)
removed (Iterable[Package] | None, optional) – initial list of successfully removed packages (Default value = None)
failed (Iterable[Package] | None, optional) – initial list of failed packages (Default value = None)
- add_added(package: Package) None
add new package to new packages list
- Parameters:
package (Package) – package removed
- add_failed(package: Package) None
add new package to failed built
- Parameters:
package (Package) – package with errors during build
- add_removed(package: Package) None
add new package to removed list
- Parameters:
package (Package) – package removed
- add_updated(package: Package) None
add new package to success built
- Parameters:
package (Package) – package built
- merge(other: Result) Self
merge other result into this one. This method assumes that other has fresh info about status and override it
- Parameters:
other (Result) – instance of the newest result
- Returns:
updated instance
- Return type:
Self
- refine() Self
merge packages between different results (e.g. remove failed from added, etc.) removing duplicates
- Returns:
updated instance
- Return type:
Self
- property failed: list[Package]
get list of failed packages
- Returns:
list of packages which were failed
- Return type:
list[Package]
- property is_empty: bool
get if build result is empty or not
- Returns:
True in case if success list is empty and False otherwise
- Return type:
bool
ahriman.models.sign_settings module
- class SignSettings(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
StrEnum
sign targets enumeration
- Disabled
(class attribute) option which generates no report for testing purpose
- Type:
- Packages
(class attribute) sign each package
- Type:
- Repository
(class attribute) sign repository database file
- Type:
- static from_option(value: str) SignSettings
construct value from configuration
- Parameters:
value (str) – configuration value
- Returns:
parsed value
- Return type:
ahriman.models.smtp_ssl_settings module
- class SmtpSSLSettings(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
StrEnum
SMTP SSL mode enumeration
- Disabled
(class attribute) no SSL enabled
- Type:
- SSL
(class attribute) use SMTP_SSL instead of normal SMTP client
- Type:
- STARTTLS
(class attribute) use STARTTLS in normal SMTP client
- Type:
- static from_option(value: str) SmtpSSLSettings
construct value from configuration
- Parameters:
value (str) – configuration value
- Returns:
parsed value
- Return type:
ahriman.models.upload_settings module
- class UploadSettings(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
StrEnum
remote synchronization targets enumeration
- Disabled
(class attribute) no sync will be performed, required for testing purpose
- Type:
- Rsync
(class attribute) sync via rsync
- Type:
- S3
(class attribute) sync to Amazon S3
- Type:
- GitHub
(class attribute) sync to GitHub releases page
- Type:
- RemoteService
(class attribute) sync to another ahriman instance
- Type:
- static from_option(value: str) UploadSettings
construct value from configuration
- Parameters:
value (str) – configuration value
- Returns:
parsed value
- Return type:
ahriman.models.user module
- class User(*, username: str, password: str, access: UserAccess, packager_id: str | None = None, key: str | None = None)
Bases:
object
authorized web user model
- username
username
- Type:
str
- password
hashed user password with salt
- Type:
str
- access
user role
- Type:
- packager_id
packager id to be used. If not set, the default service packager will be used
- Type:
str | None
- key
personal packager key if any. If user id is empty, it is interpreted as default key
- Type:
str | None
Examples
Simply create user from database data and perform required validation:
>>> password = User.generate_password(24) >>> user = User(username="ahriman", password=password, access=UserAccess.Full)
Since the password supplied may be plain text, the
hash_password()
method can be used to hash the password:>>> user = user.hash_password("salt")
Having the user instance and password, it can be validated:
>>> if user.check_credentials(password, "salt"): >>> print("password is valid") >>> else: >>> print("password is invalid")
…and finally access can be verified:
>>> if user.verify_access(UserAccess.Read): >>> print(f"user {user.username} has read access")
- check_credentials(password: str, salt: str) bool
validate user password
- Parameters:
password (str) – entered password
salt (str) – salt for hashed password
- Returns:
True in case if password matches, False otherwise
- Return type:
bool
- static generate_password(length: int) str
generate password with specified length
- Parameters:
length (int) – password length
- Returns:
random string which contains letters and numbers
- Return type:
str
- hash_password(salt: str) Self
generate hashed password from plain text
- Parameters:
salt (str) – salt for hashed password
- Returns:
user with hashed password to store in configuration
- Return type:
Self
- verify_access(required: UserAccess) bool
validate if user has access to requested resource
- Parameters:
required (UserAccess) – required access level
- Returns:
True in case if user is allowed to do this request and False otherwise
- Return type:
bool
ahriman.models.user_access module
- class UserAccess(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
StrEnum
web user access enumeration
- Unauthorized
(class attribute) user can access specific resources which are marked as available without authorization (e.g. login, logout, static)
- Type:
- Read
(class attribute) user can read the page
- Type:
- Reporter
(class attribute) user can read everything and is able to perform some modifications
- Type:
- Full
(class attribute) user has full access
- Type:
- permits(other: UserAccess) bool
compare enumeration between each other and check if current permission allows the
other
- Parameters:
other (UserAccess) – other permission to compare
- Returns:
True in case if current permission allows the operation and False otherwise
- Return type:
bool
ahriman.models.waiter module
- class Waiter(wait_timeout: int, *, start_time: float = <factory>, interval: int = 10)
Bases:
object
simple waiter implementation
- interval
interval in seconds between checks
- Type:
int
- start_time
monotonic time of the waiter start. More likely must not be assigned explicitly
- Type:
float
- wait_timeout
timeout in seconds to wait for. Negative value will result in immediate exit. Zero value
- Type:
int
means infinite timeout
- is_timed_out() bool
check if timer is out
- Returns:
True in case current monotonic time is more than
start_time
andwait_timeout
doesn’t equal to 0- Return type:
bool
- wait(in_progress: ~collections.abc.Callable[[~Params], bool], *args: ~typing.~Params, **kwargs: ~typing.~Params) float
wait until requirements are not met
- Parameters:
in_progress (Callable[Params, bool]) – function to check if timer should wait for another cycle
*args (Params.args) – positional arguments for check call
**kwargs (Params.kwargs) – keyword arguments for check call
- Returns:
consumed time in seconds
- Return type:
float
ahriman.models.worker module
- class Worker(address: str, *, identifier: str = '')
Bases:
object
worker descriptor
- address
worker address to be reachable outside
- Type:
str
- identifier
worker unique identifier. If none set it will be automatically generated from the address
- Type:
str
- view() dict[str, Any]
generate json patch view
- Returns:
json-friendly dictionary
- Return type:
dict[str, Any]