mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 09:13:37 +02:00
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 <jan@janware.com>
This commit is contained in:
parent
f18575a267
commit
98ad7442d9
1 changed files with 9 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue