mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-09-02 06:49:55 +00:00
Extended package status page (#76)
* implement log storage at backend * handle process id during removal. During one process we can write logs from different packages in different times (e.g. check and update later) and we would like to store all logs belong to the same process * set package context in main functions * implement logs support in interface * filter out logs posting http logs * add timestamp to log records * hide getting logs under reporter permission List of breaking changes: * `ahriman.core.lazy_logging.LazyLogging` has been renamed to `ahriman.core.log.LazyLogging` * `ahriman.core.configuration.Configuration.from_path` does not have `quiet` attribute now * `ahriman.core.configuration.Configuration` class does not have `load_logging` method now * `ahriman.core.status.client.Client.load` requires `report` argument now
This commit is contained in:
@ -19,6 +19,8 @@
|
||||
#
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from typing import List, Optional, Tuple, Type
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
@ -33,19 +35,24 @@ class Client:
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def load(cls: Type[Client], configuration: Configuration) -> Client:
|
||||
def load(cls: Type[Client], configuration: Configuration, *, report: bool) -> Client:
|
||||
"""
|
||||
load client from settings
|
||||
|
||||
Args:
|
||||
configuration(Configuration): configuration instance
|
||||
report(bool): force enable or disable reporting
|
||||
|
||||
Returns:
|
||||
Client: client according to current settings
|
||||
"""
|
||||
if not report:
|
||||
return cls()
|
||||
|
||||
address = configuration.get("web", "address", fallback=None)
|
||||
host = configuration.get("web", "host", fallback=None)
|
||||
port = configuration.getint("web", "port", fallback=None)
|
||||
|
||||
if address or (host and port):
|
||||
from ahriman.core.status.web_client import WebClient
|
||||
return WebClient(configuration)
|
||||
@ -60,17 +67,17 @@ class Client:
|
||||
status(BuildStatusEnum): current package build status
|
||||
"""
|
||||
|
||||
def get(self, base: Optional[str]) -> List[Tuple[Package, BuildStatus]]:
|
||||
def get(self, package_base: Optional[str]) -> List[Tuple[Package, BuildStatus]]:
|
||||
"""
|
||||
get package status
|
||||
|
||||
Args:
|
||||
base(Optional[str]): package base to get
|
||||
package_base(Optional[str]): package base to get
|
||||
|
||||
Returns:
|
||||
List[Tuple[Package, BuildStatus]]: list of current package description and status if it has been found
|
||||
"""
|
||||
del base
|
||||
del package_base
|
||||
return []
|
||||
|
||||
def get_internal(self) -> InternalStatus:
|
||||
@ -82,20 +89,28 @@ class Client:
|
||||
"""
|
||||
return InternalStatus(status=BuildStatus())
|
||||
|
||||
def remove(self, base: str) -> None:
|
||||
def logs(self, record: logging.LogRecord) -> None:
|
||||
"""
|
||||
post log record
|
||||
|
||||
Args:
|
||||
record(logging.LogRecord): log record to post to api
|
||||
"""
|
||||
|
||||
def remove(self, package_base: str) -> None:
|
||||
"""
|
||||
remove packages from watcher
|
||||
|
||||
Args:
|
||||
base(str): package base to remove
|
||||
package_base(str): package base to remove
|
||||
"""
|
||||
|
||||
def update(self, base: str, status: BuildStatusEnum) -> None:
|
||||
def update(self, package_base: str, status: BuildStatusEnum) -> None:
|
||||
"""
|
||||
update package build status. Unlike ``add`` it does not update package properties
|
||||
|
||||
Args:
|
||||
base(str): package base to update
|
||||
package_base(str): package base to update
|
||||
status(BuildStatusEnum): current package build status
|
||||
"""
|
||||
|
||||
@ -107,32 +122,32 @@ class Client:
|
||||
status(BuildStatusEnum): current ahriman status
|
||||
"""
|
||||
|
||||
def set_building(self, base: str) -> None:
|
||||
def set_building(self, package_base: str) -> None:
|
||||
"""
|
||||
set package status to building
|
||||
|
||||
Args:
|
||||
base(str): package base to update
|
||||
package_base(str): package base to update
|
||||
"""
|
||||
return self.update(base, BuildStatusEnum.Building)
|
||||
return self.update(package_base, BuildStatusEnum.Building)
|
||||
|
||||
def set_failed(self, base: str) -> None:
|
||||
def set_failed(self, package_base: str) -> None:
|
||||
"""
|
||||
set package status to failed
|
||||
|
||||
Args:
|
||||
base(str): package base to update
|
||||
package_base(str): package base to update
|
||||
"""
|
||||
return self.update(base, BuildStatusEnum.Failed)
|
||||
return self.update(package_base, BuildStatusEnum.Failed)
|
||||
|
||||
def set_pending(self, base: str) -> None:
|
||||
def set_pending(self, package_base: str) -> None:
|
||||
"""
|
||||
set package status to pending
|
||||
|
||||
Args:
|
||||
base(str): package base to update
|
||||
package_base(str): package base to update
|
||||
"""
|
||||
return self.update(base, BuildStatusEnum.Pending)
|
||||
return self.update(package_base, BuildStatusEnum.Pending)
|
||||
|
||||
def set_success(self, package: Package) -> None:
|
||||
"""
|
||||
|
Reference in New Issue
Block a user