Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display sha256 of downloaded files while signing release assets #816

Merged
merged 1 commit into from
Jul 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions pontos/release/sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#

import asyncio
import hashlib
import subprocess
from argparse import Namespace
from asyncio.subprocess import Process
Expand All @@ -26,6 +27,7 @@

import httpx
from rich.progress import Progress as RichProgress
from rich.progress import TextColumn

from pontos.errors import PontosError
from pontos.git.git import GitError
Expand Down Expand Up @@ -88,13 +90,19 @@
with destination.open("wb") as f:
task_description = f"Downloading [blue]{progress.url}"
task_id = rich_progress.add_task(
task_description, total=progress.length
task_description,
total=progress.length,
sha256="",
)
sha256 = hashlib.sha256()

Check warning on line 97 in pontos/release/sign.py

View check run for this annotation

Codecov / codecov/patch

pontos/release/sign.py#L97

Added line #L97 was not covered by tests
async for content, percent in progress:
rich_progress.advance(task_id, percent or 1)
f.write(content)
sha256.update(content)

Check warning on line 101 in pontos/release/sign.py

View check run for this annotation

Codecov / codecov/patch

pontos/release/sign.py#L101

Added line #L101 was not covered by tests

rich_progress.update(task_id, total=1, completed=1)
rich_progress.update(

Check warning on line 103 in pontos/release/sign.py

View check run for this annotation

Codecov / codecov/patch

pontos/release/sign.py#L103

Added line #L103 was not covered by tests
task_id, total=1, completed=1, sha256=sha256.hexdigest()
)

async def download_zip(
self,
Expand Down Expand Up @@ -266,7 +274,11 @@
zip_destination = Path(f"{project}-{release_version}.zip")
tarball_destination = Path(f"{project}-{release_version}.tar.gz")

with self.terminal.progress() as rich_progress:
with self.terminal.progress(
additional_columns=[
TextColumn("[progress.description]{task.fields[sha256]}"),
]
) as rich_progress:
tasks.append(
asyncio.create_task(
self.download_zip(
Expand Down
Loading