Download-logs with nvr without task ID downloads a logs
Fixes: https://pagure.io/koji/issue/3232
This commit is contained in:
parent
47c4cb05b9
commit
6c8359fd44
2 changed files with 111 additions and 35 deletions
|
|
@ -7274,21 +7274,39 @@ def anon_handle_download_logs(options, session, args):
|
|||
save_logs(child_task['id'], match, task_log_dir, recurse)
|
||||
|
||||
ensure_connection(session, options)
|
||||
task_id = None
|
||||
build_id = None
|
||||
for arg in args:
|
||||
if suboptions.nvr:
|
||||
suboptions.recurse = True
|
||||
binfo = session.getBuild(arg)
|
||||
if binfo is None:
|
||||
error("There is no build with n-v-r: %s" % arg)
|
||||
assert binfo['task_id'], binfo
|
||||
task_id = binfo['task_id']
|
||||
sys.stdout.write("Using task ID: %s\n" % task_id)
|
||||
if binfo.get('task_id'):
|
||||
task_id = binfo['task_id']
|
||||
sys.stdout.write("Using task ID: %s\n" % task_id)
|
||||
elif binfo.get('build_id'):
|
||||
build_id = binfo['build_id']
|
||||
sys.stdout.write("Using build ID: %s\n" % build_id)
|
||||
else:
|
||||
try:
|
||||
task_id = int(arg)
|
||||
except ValueError:
|
||||
error("Task id must be number: %r" % arg)
|
||||
save_logs(task_id, suboptions.match, suboptions.dir, suboptions.recurse)
|
||||
if task_id:
|
||||
save_logs(task_id, suboptions.match, suboptions.dir, suboptions.recurse)
|
||||
elif build_id:
|
||||
logs = session.getBuildLogs(build_id)
|
||||
match = suboptions.match
|
||||
for log in logs:
|
||||
url = os.path.join(options.topurl, log['path'])
|
||||
filepath = os.path.join(os.getcwd(), '%s/%s/%s' % (suboptions.dir,
|
||||
arg, log['name']))
|
||||
if not filepath.endswith(".log"):
|
||||
continue
|
||||
if match and not koji.util.multi_fnmatch(log['name'], match):
|
||||
continue
|
||||
download_file(url, filepath)
|
||||
|
||||
|
||||
def anon_handle_download_task(options, session, args):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue