From 194e454b7ec5cc9dab93bd63b509640ae056b399 Mon Sep 17 00:00:00 2001 From: Till Maas Date: Mon, 28 May 2018 08:55:36 +0200 Subject: [PATCH 1/3] Set file_name for attached build logs Signed-off-by: Till Maas --- scripts/mass_rebuild_file_bugs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/mass_rebuild_file_bugs.py b/scripts/mass_rebuild_file_bugs.py index e9fbdf1..a0fc3a3 100755 --- a/scripts/mass_rebuild_file_bugs.py +++ b/scripts/mass_rebuild_file_bugs.py @@ -114,8 +114,9 @@ def attach_logs(bug, logs): fp.seek(0) try: print('Attaching file %s to the ticket' % name) + # arguments are: idlist, attachfile, description, ... attid = BZCLIENT.attachfile( - bug.id, fp, name, content_type='text/plain') + bug.id, fp, name, content_type='text/plain', file_name=name) except Fault as ex: print(ex) raise -- 2.55.0 From ebb59149c8df1c3c742ec4aa336091d5ae5b802b Mon Sep 17 00:00:00 2001 From: Till Maas Date: Tue, 29 May 2018 12:50:22 +0200 Subject: [PATCH 2/3] mass_rebuild_file_bugs: Allow extrainfo for bugs Signed-off-by: Till Maas --- scripts/mass_rebuild_file_bugs.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/mass_rebuild_file_bugs.py b/scripts/mass_rebuild_file_bugs.py index a0fc3a3..707618b 100755 --- a/scripts/mass_rebuild_file_bugs.py +++ b/scripts/mass_rebuild_file_bugs.py @@ -35,10 +35,11 @@ DEFAULT_COMMENT = \ """{component} failed to build from source in {product} {version} https://koji.fedoraproject.org/koji/taskinfo?taskID={task_id} +{extrainfo} For details on the mass rebuild see: -{wikipage} +{wikipage} Please fix {component} at your earliest convenience and set the bug's status to ASSIGNED when you start fixing it. If the bug remains in NEW state for 8 weeks, {component} will be orphaned. Before branching of {product} {nextversion}, @@ -50,7 +51,7 @@ https://fedoraproject.org/wiki/Fails_to_build_from_source def report_failure(massrebuild, component, task_id, logs, summary="{component}: FTBFS in {product} {version}", - comment=DEFAULT_COMMENT): + comment=DEFAULT_COMMENT, extrainfo=""): """This function files a new bugzilla bug for component with given arguments @@ -68,6 +69,7 @@ def report_failure(massrebuild, component, task_id, logs, format_values["task_id"] = task_id format_values["component"] = component format_values["nextversion"] = str(int(massrebuild["version"]) + 1) + format_values["extrainfo"] = extrainfo summary = summary.format(**format_values) comment = comment.format(**format_values) -- 2.55.0 From ccceff2232d8802dc680ecfab558c9a5649ce3f6 Mon Sep 17 00:00:00 2001 From: Till Maas Date: Tue, 29 May 2018 12:51:12 +0200 Subject: [PATCH 3/3] mass_rebuild_file_bugs: Improve log attachment - download data in chunks - handle log files, that are too large Signed-off-by: Till Maas --- scripts/mass_rebuild_file_bugs.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/scripts/mass_rebuild_file_bugs.py b/scripts/mass_rebuild_file_bugs.py index 707618b..fe08a3e 100755 --- a/scripts/mass_rebuild_file_bugs.py +++ b/scripts/mass_rebuild_file_bugs.py @@ -112,13 +112,33 @@ def attach_logs(bug, logs): name = log.rsplit('/', 1)[-1] response = urllib2.urlopen(log) fp = tempfile.TemporaryFile() - fp.write(response.read()) - fp.seek(0) + + CHUNK = 2 ** 20 + while True: + chunk = response.read(CHUNK) + if not chunk: + break + fp.write(chunk) + + filesize = fp.tell() + # Bugzilla file limit, still possibly too much + # FILELIMIT = 20000 * 1024 + # Just use 1 MiB: + FILELIMIT = 2 ** 10 + if filesize > FILELIMIT: + fp.seek(filesize - FILELIMIT) + comment = "file {} too big, will only attach last {} bytes".format( + name, FILELIMIT) + else: + comment = "" + fp.seek(0) try: print('Attaching file %s to the ticket' % name) # arguments are: idlist, attachfile, description, ... attid = BZCLIENT.attachfile( - bug.id, fp, name, content_type='text/plain', file_name=name) + bug.id, fp, name, content_type='text/plain', file_name=name, + comment=comment + ) except Fault as ex: print(ex) raise -- 2.55.0