Skip to content

Commit 0bfe73f

Browse files
committed
feat: update console ui and handle errors
Signed-off-by: Demolus13 <[email protected]>
1 parent 4743d6d commit 0bfe73f

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

src/macaron/build_spec_generator/reproducible_central/reproducible_central.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,10 @@ def gen_reproducible_central_build_spec(
355355
group = purl.namespace
356356
artifact = purl.name
357357
version = purl.version
358+
rich_handler = access_handler.get_handler()
359+
rich_handler.update_gen_build_spec("Package URL:", purl.to_string())
358360
if group is None or version is None:
359361
logger.error("Missing group and/or version for purl %s.", purl.to_string())
360-
rich_handler = access_handler.get_handler()
361-
rich_handler.update_gen_build_spec("Repository PURL:", "[red]FAILED[/]")
362362
rich_handler.update_gen_build_spec("Repository URL:", "[red]FAILED[/]")
363363
rich_handler.update_gen_build_spec("Commit Hash:", "[red]FAILED[/]")
364364
rich_handler.update_gen_build_spec("Build Tools:", "[red]FAILED[/]")
@@ -382,6 +382,9 @@ def gen_reproducible_central_build_spec(
382382
+ "Please check if an analysis for it exists in the database.",
383383
purl.to_string(),
384384
)
385+
rich_handler.update_gen_build_spec("Repository URL:", "[red]FAILED[/]")
386+
rich_handler.update_gen_build_spec("Commit Hash:", "[red]FAILED[/]")
387+
rich_handler.update_gen_build_spec("Build Tools:", "[red]FAILED[/]")
385388
return None
386389

387390
latest_component_repository = latest_component.repository
@@ -397,8 +400,6 @@ def gen_reproducible_central_build_spec(
397400
latest_component_repository.remote_path,
398401
latest_component_repository.commit_sha,
399402
)
400-
rich_handler = access_handler.get_handler()
401-
rich_handler.update_gen_build_spec("Repository PURL:", purl.to_string())
402403
rich_handler.update_gen_build_spec("Repository URL:", latest_component_repository.remote_path)
403404
rich_handler.update_gen_build_spec("Commit Hash:", latest_component_repository.commit_sha)
404405

src/macaron/console.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self, *args: Any, verbose: bool = False, **kwargs: Any) -> None:
4343
self.logs: list[str] = []
4444
self.description_table = Table(show_header=False, box=None)
4545
self.description_table_content: dict[str, str | Status] = {
46-
"Full Name:": Status("[green]Processing[/]"),
46+
"Package URL:": Status("[green]Processing[/]"),
4747
"Local Cloned Path:": Status("[green]Processing[/]"),
4848
"Remote Path:": Status("[green]Processing[/]"),
4949
"Branch:": Status("[green]Processing[/]"),
@@ -81,15 +81,15 @@ def __init__(self, *args: Any, verbose: bool = False, **kwargs: Any) -> None:
8181
self.verification_summary_attestation: str | None = None
8282
self.find_source_table = Table(show_header=False, box=None)
8383
self.find_source_content: dict[str, str | Status] = {
84-
"Repository PURL:": Status("[green]Processing[/]"),
84+
"Repository URL:": Status("[green]Processing[/]"),
8585
"Commit Hash:": Status("[green]Processing[/]"),
8686
"JSON Report:": "Not Generated",
8787
}
8888
for key, value in self.find_source_content.items():
8989
self.find_source_table.add_row(key, value)
9090
self.dump_defaults: str | Status = Status("[green]Generating[/]")
9191
self.gen_build_spec: dict[str, str | Status] = {
92-
"Repository PURL:": Status("[green]Processing[/]"),
92+
"Package URL:": Status("[green]Processing[/]"),
9393
"Repository URL:": Status("[green]Processing[/]"),
9494
"Commit Hash:": Status("[green]Processing[/]"),
9595
"Build Tools:": Status("[green]Processing[/]"),

src/macaron/repo_finder/repo_finder.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,26 @@ def find_repo(
123123

124124
# Try to find the latest version repo.
125125
logger.debug("Could not find repo for PURL: %s", purl)
126+
rich_handler = access_handler.get_handler()
126127
latest_version_purl = get_latest_purl_if_different(purl)
127128
if not latest_version_purl:
128129
logger.debug("Could not find newer PURL than provided: %s", purl)
130+
rich_handler.add_description_table_content("Local Cloned Path:", "[red]Not Found[/]")
131+
rich_handler.add_description_table_content("Remote Path:", "[red]Not Found[/]")
129132
return "", RepoFinderInfo.NO_NEWER_VERSION
130-
131133
found_repo, outcome = DepsDevRepoFinder().find_repo(latest_version_purl)
132134
if found_repo:
135+
rich_handler.add_description_table_content("Local Cloned Path:", found_repo)
136+
rich_handler.add_description_table_content("Remote Path:", found_repo)
133137
return found_repo, outcome
134138

135139
if not found_repo:
136140
found_repo, outcome = find_repo_alternative(latest_version_purl, outcome, package_registries_info)
137141

138142
if not found_repo:
139143
logger.debug("Could not find repo from latest version of PURL: %s", latest_version_purl)
144+
rich_handler.add_description_table_content("Local Cloned Path:", "[red]Not Found[/]")
145+
rich_handler.add_description_table_content("Remote Path:", "[red]Not Found[/]")
140146
return "", RepoFinderInfo.LATEST_VERSION_INVALID
141147

142148
return found_repo, outcome
@@ -327,9 +333,9 @@ def find_source(purl_string: str, input_repo: str | None, latest_version_fallbac
327333
rich_handler = access_handler.get_handler()
328334
if not input_repo:
329335
logger.info("Found repository for PURL: %s", found_repo)
330-
rich_handler.update_find_source_table("Repository PURL:", found_repo)
336+
rich_handler.update_find_source_table("Repository URL:", found_repo)
331337
else:
332-
rich_handler.update_find_source_table("Repository PURL:", input_repo)
338+
rich_handler.update_find_source_table("Repository URL:", input_repo)
333339

334340
logger.info("Found commit for PURL: %s", digest)
335341
rich_handler.update_find_source_table("Commit Hash:", digest)

src/macaron/slsa_analyzer/analyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def run_single(
501501
logger.info("Analyzing %s", repo_id)
502502
logger.info("With PURL: %s", component.purl)
503503
logger.info("=====================================")
504-
self.rich_handler.add_description_table_content("Full Name:", component.purl)
504+
self.rich_handler.add_description_table_content("Package URL:", component.purl)
505505

506506
analyze_ctx = self.create_analyze_ctx(component)
507507
analyze_ctx.dynamic_data["expectation"] = self.expectations.get_expectation_for_target(

0 commit comments

Comments
 (0)