ahriman.application.handlers package
Submodules
ahriman.application.handlers.add module
- class Add
Bases:
Handleradd packages handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.backup module
- class Backup
Bases:
Handlerbackup packages handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
- static get_paths(configuration: Configuration) set[Path]
extract paths to back up
- Parameters:
configuration (Configuration) – configuration instance
- Returns:
map of the filesystem paths
- Return type:
set[Path]
ahriman.application.handlers.change module
- class Change
Bases:
Handlerpackage changes handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.clean module
- class Clean
Bases:
Handlerclean caches handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.copy module
- class Copy
Bases:
Handlercopy packages handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
- static copy_package(package: Package, application: Application, source_application: Application) None
copy package
packagefrom source repository to target repository- Parameters:
package (Package) – package to copy
application (Application) – application instance of the target repository
source_application (Application) – application instance of the source repository
ahriman.application.handlers.daemon module
- class Daemon
Bases:
Handlerdaemon packages handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.dump module
- class Dump
Bases:
Handlerdump configuration handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.handler module
- class Handler
Bases:
objectbase handler class for command callbacks
- ALLOW_MULTI_ARCHITECTURE_RUN
(class attribute) allow running with multiple architectures
- Type:
bool
- arguments
(class attribute) argument parser methods, which will be called to create command line parsers
- Type:
list[Callable[[SubParserAction], argparse.ArgumentParser]]
Examples
Wrapper for all command line actions, though each derived class implements
run()method, it usually must not be called directly. The recommended way is to callexecute()class method, e.g.:>>> from ahriman.application.handlers.add import Add >>> >>> Add.execute(args)
- classmethod call(args: Namespace, repository_id: RepositoryId) bool
additional function to wrap all calls for multiprocessing library
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
- Returns:
Trueon success,Falseotherwise- Return type:
bool
- classmethod execute(args: Namespace) int
execute function for all aru
- Parameters:
args (argparse.Namespace) – command line args
- Returns:
0 on success, 1 otherwise
- Return type:
int
- Raises:
MultipleArchitecturesError – if more than one architecture supplied and no multi architecture supported
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
- Raises:
NotImplementedError – not implemented method
- static check_status(enabled: bool, status: HasBool | HasLength | int | Callable[[], HasBool | HasLength | int]) None
check condition and flag and raise ExitCode exception in case if it is enabled and condition match
- Parameters:
enabled (bool) – if
Falseno check will be performedstatus (ExplicitBool | Callable[[], ExplicitBool]) – return status or function to check.
Truemeans success and vice versa
- Raises:
ExitCode – if result is empty and check is enabled
- static repositories_extract(args: Namespace) list[RepositoryId]
get known architectures
- Parameters:
args (argparse.Namespace) – command line args
- Returns:
list of repository names and architectures for which tree is created
- Return type:
list[RepositoryId]
- Raises:
MissingArchitectureError – if no architecture set and automatic detection is not allowed or failed
ahriman.application.handlers.help module
- class Help
Bases:
Handlerhelp handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.key_import module
- class KeyImport
Bases:
Handlerkey import packages handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.patch module
- class Patch
Bases:
Handlerpatch control handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
- static patch_create_from_diff(sources_dir: Path, architecture: str, track: list[str]) tuple[str, PkgbuildPatch]
create PKGBUILD plain diff patches from sources directory
- Parameters:
sources_dir (Path) – path to directory with the package sources
architecture (str) – repository architecture
track (list[str]) – track files which match the glob before creating the patch
- Returns:
package base and created PKGBUILD patch based on the diff from master HEAD to current files
- Return type:
tuple[str, PkgbuildPatch]
- static patch_create_from_function(variable: str, patch_path: Path | None) PkgbuildPatch
create single-function patch set for the package base
- Parameters:
variable (str) – function or variable name inside PKGBUILD
patch_path (Path | None) – optional path to patch content. If not set, it will be read from stdin
- Returns:
created patch for the PKGBUILD function
- Return type:
- static patch_set_create(application: Application, package_base: str, patch: PkgbuildPatch) None
create patch set for the package base
- Parameters:
application (Application) – application instance
package_base (str) – package base
patch (PkgbuildPatch) – patch descriptor
- static patch_set_list(application: Application, package_base: str, variables: list[str] | None, exit_code: bool) None
list patches available for the package base
- Parameters:
application (Application) – application instance
package_base (str) – package base
variables (list[str] | None) – extract patches only for specified PKGBUILD variables
exit_code (bool) – exit with error on empty search result
- static patch_set_remove(application: Application, package_base: str, variables: list[str] | None) None
remove patch set for the package base
- Parameters:
application (Application) – application instance
package_base (str) – package base
variables (list[str] | None) – remove patches only for specified PKGBUILD variables
ahriman.application.handlers.rebuild module
- class Rebuild
Bases:
Handlermake world handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
- static extract_packages(application: Application, status: BuildStatusEnum | None, *, from_database: bool) list[Package]
extract packages from database file
- Parameters:
application (Application) – application instance
status (BuildStatusEnum | None) – optional filter by package status
from_database (bool) – extract packages from database instead of repository filesystem
- Returns:
list of packages which were stored in database
- Return type:
list[Package]
ahriman.application.handlers.reload module
- class Reload
Bases:
Handlerweb server reload handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.remove module
- class Remove
Bases:
Handlerremove packages handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.remove_unknown module
- class RemoveUnknown
Bases:
Handlerremove unknown packages handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.repositories module
- class Repositories
Bases:
Handlerrepositories listing handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.restore module
- class Restore
Bases:
Handlerrestore packages handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.run module
- class Run
Bases:
Handlermulticommand handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
- static run_command(command: list[str], parser: ArgumentParser) bool
run command specified by the argument
- Parameters:
command (list[str]) – command to run
parser (argparse.ArgumentParser) – generated argument parser
- Returns:
status of the command
- Return type:
bool
ahriman.application.handlers.search module
- class Search
Bases:
Handlerpackages search handler
- SORT_FIELDS
(class attribute) allowed fields to sort the package list
- Type:
set[str]
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
- static sort(packages: Iterable[AURPackage], sort_by: str) list[AURPackage]
sort package list by specified field
- Parameters:
packages (Iterable[AURPackage]) – packages list to sort
sort_by (str) – AUR package field name to sort by
- Returns:
sorted list for packages
- Return type:
list[AURPackage]
- Raises:
OptionError – if search fields is not in list of allowed ones
ahriman.application.handlers.service_updates module
- class ServiceUpdates
Bases:
Handlerservice updates handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.setup module
- class Setup
Bases:
Handlersetup handler
- ARCHBUILD_COMMAND_PATH
(class attribute) default devtools command
- Type:
Path
- MIRRORLIST_PATH
(class attribute) path to pacman default mirrorlist (used by multilib repository)
- Type:
Path
- SUDOERS_DIR_PATH
(class attribute) path to sudoers.d includes directory
- Type:
Path
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
- static build_command(root: Path, repository_id: RepositoryId) Path
generate build command name
- Parameters:
root (Path) – root directory for the build command (must be root of the repository)
repository_id (RepositoryId) – repository unique identifier
- Returns:
valid devtools command name
- Return type:
Path
- static configuration_create_ahriman(args: Namespace, repository_id: RepositoryId, root: Configuration) None
create service specific configuration
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
root (Configuration) – root configuration instance
- static configuration_create_devtools(repository_id: RepositoryId, source: Path, mirror: str | None, multilib: bool, repository_server: str) None
create configuration for devtools based on
sourceconfigurationNotes
devtools does not allow to specify the pacman configuration, thus we still have to use configuration in /usr
- Parameters:
repository_id (RepositoryId) – repository unique identifier
source (Path) – path to source configuration file
mirror (str | None) – link to package server mirror
multilib (bool) – add or do not multilib repository to the configuration
repository_server (str) – url of the repository
- static configuration_create_makepkg(packager: str, makeflags_jobs: bool, paths: RepositoryPaths) None
create configuration for makepkg
- Parameters:
packager (str) – packager identifier (e.g. name, email)
makeflags_jobs (bool) – set MAKEFLAGS variable to number of cores
paths (RepositoryPaths) – repository paths instance
- static configuration_create_sudo(paths: RepositoryPaths, repository_id: RepositoryId) None
create configuration to run build command with sudo without password
- Parameters:
paths (RepositoryPaths) – repository paths instance
repository_id (RepositoryId) – repository unique identifier
- static executable_create(paths: RepositoryPaths, repository_id: RepositoryId) None
create executable for the service
- Parameters:
paths (RepositoryPaths) – repository paths instance
repository_id (RepositoryId) – repository unique identifier
ahriman.application.handlers.shell module
- class Shell
Bases:
Handlerpython shell handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.sign module
- class Sign
Bases:
Handler(re-)sign handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.statistics module
- class Statistics
Bases:
Handlerrepository statistics handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
- static event_stats(event_type: str, events: list[Event]) None
calculate event stats
- Parameters:
event_type (str) – event type
events (list[Event]) – list of events
- static plot_packages(event_type: str, events: dict[str, int], path: Path) None
plot packages frequency
- Parameters:
event_type (str) – event type
events (dict[str, int]) – list of events
path (Path) – path to save plot
- static plot_times(event_type: str, events: list[Event], path: Path) None
plot events timeline
- Parameters:
event_type (str) – event type
events (list[Event]) – list of events
path (Path) – path to save plot
ahriman.application.handlers.status module
- class Status
Bases:
Handlerpackage status handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.status_update module
- class StatusUpdate
Bases:
Handlerstatus update handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.structure module
- class Structure
Bases:
Handlerdump repository structure handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.tree_migrate module
- class TreeMigrate
Bases:
Handlertree migration handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
- static symlinks_fix(paths: RepositoryPaths) None
fix package archive symlinks
- Parameters:
paths (RepositoryPaths) – new repository paths
- static tree_move(from_tree: RepositoryPaths, to_tree: RepositoryPaths) None
move files between trees. Trees must be created in advance
- Parameters:
from_tree (RepositoryPaths) – old repository tree
to_tree (RepositoryPaths) – new repository tree
ahriman.application.handlers.triggers module
- class Triggers
Bases:
Handlertriggers handlers
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
ahriman.application.handlers.triggers_support module
ahriman.application.handlers.unsafe_commands module
- class UnsafeCommands
Bases:
Handlerunsafe command help parser
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
- static check_unsafe(command: list[str], unsafe_commands: list[str], parser: ArgumentParser) None
check if command is unsafe
- Parameters:
command (str) – command to check
unsafe_commands (list[str]) – list of unsafe commands
parser (argparse.ArgumentParser) – generated argument parser
- static get_unsafe_commands(parser: ArgumentParser) list[str]
extract unsafe commands from argument parser
- Parameters:
parser (argparse.ArgumentParser) – generated argument parser
- Returns:
list of commands with default unsafe flag
- Return type:
list[str]
ahriman.application.handlers.update module
- class Update
Bases:
Handlerpackage update handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
- static log_fn(application: Application, dry_run: bool) Callable[[str], None]
package updates log function
- Parameters:
application (Application) – application instance
dry_run (bool) – do not perform update itself
- Returns:
in case if dry_run is set it will return print, logger otherwise
- Return type:
Callable[[str], None]
ahriman.application.handlers.users module
- class Users
Bases:
Handleruser management handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
- static user_create(args: Namespace) User
create user descriptor from arguments
- Parameters:
args (argparse.Namespace) – command line args
- Returns:
built user descriptor
- Return type:
- Raises:
PasswordError – password input is invalid
ahriman.application.handlers.validate module
- class Validate
Bases:
Handlerconfiguration validator handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
- static schema(configuration: Configuration) dict[str, dict[str, Any]]
get schema with triggers
- Parameters:
configuration (Configuration) – configuration instance
- Returns:
configuration validation schema
- Return type:
- static schema_erase_required(schema: dict[str, dict[str, Any]]) dict[str, dict[str, Any]]
recursively remove required field from supplied cerberus schema
- Parameters:
schema (ConfigurationSchema) – source schema from which required field must be removed
- Returns:
schema without required fields. Note, that source schema will be modified in-place
- Return type:
- static schema_merge(source: dict[str, Any], schema: dict[str, Any]) dict[str, Any]
- merge child schema into source. In case if source already contains values, new keys will be added
(possibly with overrides - in case if such key already set also)
- Parameters:
source (dict[str, Any]) – source (current) schema into which will be merged
schema (dict[str, Any]) – new schema to be merged
- Returns:
schema with added elements from source schema if they were set before and not presented in the new one. Note, that schema will be modified in-place
- Return type:
dict[str, Any]
ahriman.application.handlers.versions module
- class Versions
Bases:
Handlerversion handler
- PEP423_PACKAGE_NAME
(class attribute) special regex for valid PEP423 package name
- Type:
re.Pattern[str]
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
- static package_dependencies(root: str) Iterator[tuple[str, str]]
extract list of ahriman package dependencies installed into system with their versions
- Parameters:
root (str) – root package name
- Yields:
tuple[str, str] – map of installed dependency to its version
ahriman.application.handlers.web module
- class Web
Bases:
Handlerweb server handler
- classmethod run(args: Namespace, repository_id: RepositoryId, configuration: Configuration, *, report: bool) None
callback for command line
- Parameters:
args (argparse.Namespace) – command line args
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
- static extract_arguments(args: Namespace, configuration: Configuration) Iterator[str]
extract list of arguments used for current command, except for command specific ones
- Parameters:
args (argparse.Namespace) – command line args
configuration (Configuration) – configuration instance
- Yields:
str – command line arguments which were used for this specific command