ahriman.core.report package

Submodules

ahriman.core.report.console module

class Console(repository_id: RepositoryId, configuration: Configuration, section: str)

Bases: Report

html report generator

use_utf

print utf8 symbols instead of ASCII

Type:

bool

default constructor

Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • section (str) – settings section name

generate(packages: list[Package], result: Result) None

generate report for the specified packages

Parameters:
  • packages (list[Package]) – list of packages to generate report

  • result (Result) – build result

ahriman.core.report.email module

class Email(repository_id: RepositoryId, configuration: Configuration, section: str)

Bases: Report, JinjaTemplate

email report generator

host

SMTP host to connect

Type:

str

no_empty_report

skip empty report generation

Type:

bool

password

password to authenticate via SMTP

Type:

str | None

port

SMTP port to connect

Type:

int

receivers

list of receivers emails

Type:

list[str]

sender

sender email address

Type:

str

ssl

SSL mode for SMTP connection

Type:

SmtpSSLSettings

template

path or name to template for built packages

Type:

Path | str

template_full

path or name to template for full package list

Type:

Path | str | None

user

username to authenticate via SMTP

Type:

str | None

default constructor

Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • section (str) – settings section name

generate(packages: list[Package], result: Result) None

generate report for the specified packages

Parameters:
  • packages (list[Package]) – list of packages to generate report

  • result (Result) – build result

ahriman.core.report.html module

class HTML(repository_id: RepositoryId, configuration: Configuration, section: str)

Bases: Report, JinjaTemplate

html report generator

report_path

output path to html report

Type:

Path

template

name or path to template for full package list

Type:

Path | str

default constructor

Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • section (str) – settings section name

generate(packages: list[Package], result: Result) None

generate report for the specified packages

Parameters:
  • packages (list[Package]) – list of packages to generate report

  • result (Result) – build result

ahriman.core.report.jinja_template module

class JinjaTemplate(repository_id: RepositoryId, configuration: Configuration, section: str)

Bases: object

jinja based report generator

It uses jinja2 templates for report generation, the following variables are allowed:

  • homepage - link to homepage, string, optional

  • link_path - prefix fo packages to download, string, required

  • has_package_signed - True in case if package sign enabled, False otherwise, required

  • has_repo_signed - True in case if repository database sign enabled, False otherwise, required

  • packages - sorted list of packages properties, required
    • architecture, string

    • archive_size, pretty printed size, string

    • build_date, pretty printed datetime, string

    • depends, sorted list of strings

    • description, string

    • filename, string,

    • groups, sorted list of strings

    • installed_size, pretty printed datetime, string

    • licenses, sorted list of strings

    • name, string

    • url, string

    • version, string

  • pgp_key - default PGP key ID, string, optional

  • repository - repository name, string, required

default_pgp_key

default PGP key

Type:

str | None

homepage

homepage link if any (for footer)

Type:

str | None

prefix fo packages to download

Type:

str

name

repository name

Type:

str

sign_targets

targets to sign enabled in configuration

Type:

set[SignSettings]

templates

list of directories with templates

Type:

list[Path]

default constructor

Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • section (str) – settings section name

make_html(result: Result, template_name: Path | str) str

generate report for the specified packages

Parameters:
  • result (Result) – build result

  • template_name (Path | str) – name of the template or path to it (legacy configuration)

ahriman.core.report.remote_call module

class RemoteCall(repository_id: RepositoryId, configuration: Configuration, section: str)

Bases: Report

trigger implementation which call remote service with update

client

web client instance

Type:

WebClient

update_aur

check for AUR updates

Type:

bool

update_local

check for local packages update

Type:

bool

update_manual

check for manually built packages

Type:

bool

wait_timeout

timeout to wait external process

Type:

int

default constructor

Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • section (str) – settings section name

generate(packages: list[Package], result: Result) None

generate report for the specified packages

Parameters:
  • packages (list[Package]) – list of packages to generate report

  • result (Result) – build result

is_process_alive(process_id: str) bool

check if process is alive

Parameters:

process_id (str) – remote process id

Returns:

True in case if remote process is alive and False otherwise

Return type:

bool

remote_update() str

call remote server for update

Returns:

remote process id

Return type:

str

remote_wait(process_id: str) None

wait for remote process termination

Parameters:

process_id (str) – remote process id

ahriman.core.report.report module

class Report(repository_id: RepositoryId, configuration: Configuration)

Bases: LazyLogging

base report generator

configuration

configuration instance

Type:

Configuration

repository_id

repository unique identifier

Type:

RepositoryId

Examples

Report subclasses provide several method in order to operate with the report generation and additional class method load() which can be used in order to determine right report instance:

>>> configuration = Configuration()
>>> report = Report.load(RepositoryId("x86_64", "aur-clone"), configuration, "email")

The generate() method can be used in order to perform the report itself, whereas run() method handles exception and raises ahriman.core.exceptions.ReportError instead:

>>> try:
>>>     report.generate([], Result())
>>> except Exception as exception:
>>>     handle_exceptions(exception)
>>>
>>> report.run(Result(), [])

default constructor

Parameters:
generate(packages: list[Package], result: Result) None

generate report for the specified packages

Parameters:
  • packages (list[Package]) – list of packages to generate report

  • result (Result) – build result

static load(repository_id: RepositoryId, configuration: Configuration, target: str) Report

load client from settings

Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • target (str) – target to generate report aka section name (e.g. html)

Returns:

client according to current settings

Return type:

Report

run(result: Result, packages: list[Package]) None

run report generation

Parameters:
  • result (Result) – build result

  • packages (list[Package]) – list of packages to generate report

Raises:

ReportError – in case of any report unmatched exception

ahriman.core.report.report_trigger module

class ReportTrigger(repository_id: RepositoryId, configuration: Configuration)

Bases: Trigger

report trigger

targets

report target list

Type:

list[str]

default constructor

Parameters:
classmethod configuration_sections(configuration: Configuration) list[str]

extract configuration sections from configuration

Parameters:

configuration (Configuration) – configuration instance

Returns:

read configuration sections belong to this trigger

Return type:

list[str]

on_result(result: Result, packages: list[Package]) None

run trigger

Parameters:
  • result (Result) – build result

  • packages (list[Package]) – list of all available packages

ahriman.core.report.telegram module

class Telegram(repository_id: RepositoryId, configuration: Configuration, section: str)

Bases: Report, JinjaTemplate, SyncHttpClient

telegram report generator

TELEGRAM_API_URL

(class attribute) telegram api base url

Type:

str

TELEGRAM_MAX_CONTENT_LENGTH

(class attribute) max content length of the message

Type:

int

api_key

bot api key

Type:

str

chat_id

chat id to post message, either string with @ or integer

Type:

str

template

name or path to template for built packages

Type:

Path | str

template_type

template message type to be used in parse mode, one of MarkdownV2, HTML, Markdown

Type:

str

default constructor

Parameters:
  • repository_id (RepositoryId) – repository unique identifier

  • configuration (Configuration) – configuration instance

  • section (str) – settings section name

generate(packages: list[Package], result: Result) None

generate report for the specified packages

Parameters:
  • packages (list[Package]) – list of packages to generate report

  • result (Result) – build result

Raises:

ValueError – impossible to split message by chunks

Module contents