Improve logs during manifests handle

This commit is contained in:
Ayaz Salikhov
2023-11-06 20:24:26 +01:00
parent 74dfec85fb
commit 5a2225e126

View File

@@ -22,7 +22,7 @@ def update_home_wiki_page(wiki_dir: Path, month: str) -> None:
TABLE_BEGINNING, TABLE_BEGINNING + month_line TABLE_BEGINNING, TABLE_BEGINNING + month_line
) )
wiki_home_file.write_text(wiki_home_content) wiki_home_file.write_text(wiki_home_content)
LOGGER.info(f"Wiki home file updated with month: {month}") LOGGER.info(f"Update wiki home page with month: {month}")
def update_monthly_wiki_page( def update_monthly_wiki_page(
@@ -43,6 +43,7 @@ def update_monthly_wiki_page(
MONTHLY_PAGE_HEADER, MONTHLY_PAGE_HEADER + build_history_line + "\n" MONTHLY_PAGE_HEADER, MONTHLY_PAGE_HEADER + build_history_line + "\n"
) )
monthly_page.write_text(monthly_page_content) monthly_page.write_text(monthly_page_content)
LOGGER.info(f"Updated monthly page: {month}")
def get_manifest_timestamp(manifest_file: Path) -> str: def get_manifest_timestamp(manifest_file: Path) -> str:
@@ -58,24 +59,24 @@ def get_manifest_month(manifest_file: Path) -> str:
def remove_old_manifests(wiki_dir: Path) -> None: def remove_old_manifests(wiki_dir: Path) -> None:
MAX_NUMBER_OF_MANIFESTS = 4500 MAX_NUMBER_OF_MANIFESTS = 4500
manifest_files = [] manifest_files: list[tuple[str, Path]] = []
for file in (wiki_dir / "manifests").rglob("*.md"): for file in (wiki_dir / "manifests").rglob("*.md"):
manifest_files.append((get_manifest_timestamp(file), file)) manifest_files.append((get_manifest_timestamp(file), file))
manifest_files.sort(reverse=True) manifest_files.sort(reverse=True)
for _, file in manifest_files[MAX_NUMBER_OF_MANIFESTS:]: for _, file in manifest_files[MAX_NUMBER_OF_MANIFESTS:]:
LOGGER.info(f"Removing manifest: {file.name}")
file.unlink() file.unlink()
LOGGER.info(f"Removed manifest: {file.relative_to(wiki_dir)}")
def update_wiki(wiki_dir: Path, hist_line_dir: Path, manifest_dir: Path) -> None: def update_wiki(wiki_dir: Path, hist_line_dir: Path, manifest_dir: Path) -> None:
LOGGER.info("Updating wiki") LOGGER.info("Updating wiki")
LOGGER.info("Copying manifest files")
for manifest_file in manifest_dir.glob("*.md"): for manifest_file in manifest_dir.glob("*.md"):
month = get_manifest_month(manifest_file) month = get_manifest_month(manifest_file)
shutil.copy(manifest_file, wiki_dir / "manifests" / month / manifest_file.name) copy_to = wiki_dir / "manifests" / month / manifest_file.name
LOGGER.info(f"Manifest file added: {manifest_file.name}") shutil.copy(manifest_file, copy_to)
LOGGER.info(f"Added manifest file: {copy_to.relative_to(wiki_dir)}")
for build_history_line_file in sorted(hist_line_dir.glob("*.txt")): for build_history_line_file in sorted(hist_line_dir.glob("*.txt")):
build_history_line = build_history_line_file.read_text() build_history_line = build_history_line_file.read_text()