control: tags -1 + patch Hi Michael, Joachim, Sandro,
Michael Biebl <bi...@debian.org> writes: > On Wed, Apr 29, 2009 at 12:01:39PM +0200, Joachim Breitner wrote: >> I’m considering to add a /usr/share/bug/$package/script file to one of >> my package that would attach (possibly after getting permission from the >> user) a configuration file. Currently, I’m only able to include it in >> the mail body, which I find unpleasant. In my case, it might even be >> problematic, as spaces and tabs are important, and the editor might >> break that. >> >> Therefore, I’d like to be able to tell reportbug to attach a specific >> file. This would avoid such issues and also make the bug reports much >> easier to read. > > I'm in a similar situation. I want to attach larger amounts of data to a > bug report. Doing that in the mail body makes the bug report almost > unreadable. So I would very much welcome also if reportbug offered the > ability to add information to bug reports as attachments via a > bug-script. I wrote a patch which adds support for this (see attachment). Sandro, you seem to be the current reportbug maintainer. Is there any chance we can get a relatively quick upload of a new version of reportbug (6.4.5) with this patch applied? Is there anything I can do to help? We’d really like to change our bugscript to use this mechanism ASAP — the reports are really inconvenient to handle because of the mail body length, but at the same time, the information itself is really valuable. -- Best regards, Michael
>From 7c8e88aff06801b50602c02b45cefbb6cc5fd1b3 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg <stapelb...@debian.org> Date: Sun, 8 Dec 2013 17:05:27 +0100 Subject: [PATCH] implement support for attachments in bugscripts Similar to headers and pseudo-headers, you can use -- BEGIN ATTACHMENTS -- and -- END ATTACHMENTS --, with file names in between, to make reportbug attach these files to the report. --- bin/reportbug | 6 +++++- reportbug/utils.py | 10 +++++++++- test/data/bugscript | 5 ++++- test/test_utils.py | 3 ++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/bin/reportbug b/bin/reportbug index 774eaad..9da01be 100755 --- a/bin/reportbug +++ b/bin/reportbug @@ -2030,7 +2030,7 @@ For more details, please see: http://www.debian.org/devel/wnpp/''') # we get the return code of the script, headers and pseudo- set # by the script, and last the text output of the script - (rc, bugscript_hdrs, bugscript_pseudo, text) = \ + (rc, bugscript_hdrs, bugscript_pseudo, text, bugscript_attachments) = \ utils.exec_and_parse_bugscript(handler, bugexec) if rc and not notatty: @@ -2046,6 +2046,10 @@ For more details, please see: http://www.debian.org/devel/wnpp/''') headers.extend(bugscript_hdrs.split('\n')) if bugscript_pseudo: pseudos.append(bugscript_pseudo.strip()) + # add attachments only if no MUA is used, using attachments with a + # MUA is not yet supported by reportbug. + if bugscript_attachments and not mua: + attachments += bugscript_attachments addinfo = None if not self.options.noconf: addinfo = u"\n-- Package-specific info:\n"+text diff --git a/reportbug/utils.py b/reportbug/utils.py index 01f7062..c2a1a82 100644 --- a/reportbug/utils.py +++ b/reportbug/utils.py @@ -1181,7 +1181,9 @@ def exec_and_parse_bugscript(handler, bugscript): isheaders = False ispseudoheaders = False + isattachments = False headers = pseudoheaders = text = '' + attachments = [] fp = open(filename) for line in fp.readlines(): # we identify the blocks for headers and pseudo-h @@ -1193,15 +1195,21 @@ def exec_and_parse_bugscript(handler, bugscript): ispseudoheaders = True elif line == '-- END PSEUDOHEADERS --\n': ispseudoheaders = False + elif line == '-- BEGIN ATTACHMENTS --\n': + isattachments = True + elif line == '-- END ATTACHMENTS --\n': + isattachments = False else: if isheaders: headers += line elif ispseudoheaders: pseudoheaders += line + elif isattachments: + attachments.append(line.strip()) else: text += line fp.close() cleanup_temp_file(filename) text = text.decode('utf-8', 'replace') - return (rc, headers, pseudoheaders, text) + return (rc, headers, pseudoheaders, text, attachments) diff --git a/test/data/bugscript b/test/data/bugscript index 425ad97..0b35f95 100755 --- a/test/data/bugscript +++ b/test/data/bugscript @@ -16,4 +16,7 @@ echo "python" echo "-- BEGIN HEADERS --" echo "X-Test: this is a test" echo "X-Dummy-Reportbug-Header: dummy" -echo "-- END HEADERS --" \ No newline at end of file +echo "-- END HEADERS --" +echo "-- BEGIN ATTACHMENTS --" +echo "/etc/fstab" +echo "-- END ATTACHMENTS --" diff --git a/test/test_utils.py b/test/test_utils.py index c158ed8..f1c9e2c 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -576,9 +576,10 @@ class TestMisc(unittest2.TestCase): handler = os.path.dirname(__file__) + '/../share/handle_bugscript' bugscript_file = os.path.dirname(__file__) + '/data/bugscript' - (rc, h, ph, t) = utils.exec_and_parse_bugscript(handler, bugscript_file) + (rc, h, ph, t, a) = utils.exec_and_parse_bugscript(handler, bugscript_file) self.assertIn('python', t) self.assertIn('debian', t) self.assertIn('From: mo...@dummy.int', h) self.assertIn('User: mo...@debian.org', ph) + self.assertIn('/etc/fstab', a) -- 1.8.4.rc3
_______________________________________________ Reportbug-maint mailing list Reportbug-maint@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reportbug-maint