From 98ad7442d9c01bd664b8b553aea8a310bbd87c71 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Tue, 7 Apr 2026 12:44:05 +0200 Subject: [PATCH] cmds.projects.CmdListRepos: Beautify error logging Call run_curl() with parse_json=True to make that explicit, and be a little more verbose about the outcome. Signed-off-by: Jan Lindemann --- src/python/jw/pkg/cmds/projects/CmdListRepos.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/python/jw/pkg/cmds/projects/CmdListRepos.py b/src/python/jw/pkg/cmds/projects/CmdListRepos.py index 2b6c0b88..9b28aa7a 100644 --- a/src/python/jw/pkg/cmds/projects/CmdListRepos.py +++ b/src/python/jw/pkg/cmds/projects/CmdListRepos.py @@ -55,7 +55,7 @@ class CmdListRepos(Cmd): # export cmd_input = (f'-u {username}:{password}').encode('utf-8') curl_args.extend(['-K-']) curl_args.append(f'https://api.github.com/users/{args.from_owner}/repos') - repos, stderr, status = await run_curl(curl_args, cmd_input=cmd_input) + repos, stderr, status = await run_curl(curl_args, cmd_input=cmd_input, parse_json=True) for repo in repos: print(repo['name']) return @@ -71,12 +71,18 @@ class CmdListRepos(Cmd): # export api_url = f'{args.base_url}/api/v1/{entities_dir}/{args.from_owner}/repos' try: tried.append(api_url) - repos, stderr, status = await run_curl(curl_args + [api_url], cmd_input=cmd_input) + repos, stderr, status = await run_curl(curl_args + [api_url], cmd_input=cmd_input, parse_json=True) for repo in repos: print(repo['name']) break except Exception as e: - pass + msg = 'curl {} failed ({}), trying next'.format( + ' '.join(curl_args + [api_url]), + str(e) + ) + log(DEBUG, msg) + tried[-1] += ': ' + msg + raise else: raise RuntimeError(f'Failed to fetch repository list from assumed Forgejo instance at {args.base_url}, tried {', '.join(tried)}') return