mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-22 18:29:56 +00:00
feat: suppress info log during vcs version calculation
This commit is contained in:
@ -99,3 +99,24 @@ class LazyLogging:
|
||||
yield
|
||||
finally:
|
||||
self._package_logger_reset()
|
||||
|
||||
@contextlib.contextmanager
|
||||
def suppress_logging(self, log_level: int = logging.WARNING) -> Generator[None, None, None]:
|
||||
"""
|
||||
silence log messages in context
|
||||
|
||||
Args:
|
||||
log_level(int, optional): the highest log level to keep (Default value = logging.WARNING)
|
||||
|
||||
Examples:
|
||||
This function is designed to be used to suppress all log messages in context, e.g.:
|
||||
|
||||
>>> with self.suppress_logging():
|
||||
>>> do_some_noisy_actions()
|
||||
"""
|
||||
current_level = self.logger.manager.disable
|
||||
try:
|
||||
logging.disable(log_level)
|
||||
yield
|
||||
finally:
|
||||
logging.disable(current_level)
|
||||
|
@ -429,13 +429,14 @@ class Package(LazyLogging):
|
||||
task = Task(self, configuration, repository_id.architecture, paths)
|
||||
|
||||
try:
|
||||
# create fresh chroot environment, fetch sources and - automagically - update PKGBUILD
|
||||
task.init(paths.cache_for(self.base), [], None)
|
||||
task.build(paths.cache_for(self.base), dry_run=True)
|
||||
with self.suppress_logging():
|
||||
# create fresh chroot environment, fetch sources and - automagically - update PKGBUILD
|
||||
task.init(paths.cache_for(self.base), [], None)
|
||||
task.build(paths.cache_for(self.base), dry_run=True)
|
||||
|
||||
pkgbuild = Pkgbuild.from_file(paths.cache_for(self.base) / "PKGBUILD")
|
||||
pkgbuild = Pkgbuild.from_file(paths.cache_for(self.base) / "PKGBUILD")
|
||||
|
||||
return full_version(pkgbuild.get("epoch"), pkgbuild["pkgver"], pkgbuild["pkgrel"])
|
||||
return full_version(pkgbuild.get("epoch"), pkgbuild["pkgver"], pkgbuild["pkgrel"])
|
||||
except Exception:
|
||||
self.logger.exception("cannot determine version of VCS package")
|
||||
finally:
|
||||
|
Reference in New Issue
Block a user