[PATCH] add savepath option to change draft directory

Carl Chenet carl.chenet at ohmytux.com
Tue May 12 19:06:11 UTC 2009


---
 bin/reportbug |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/bin/reportbug b/bin/reportbug
index 3fba286..a20f5a9 100755
--- a/bin/reportbug
+++ b/bin/reportbug
@@ -97,7 +97,7 @@ def stopmsg(filename):
 
 def include_file_in_report(message, message_filename,
                            attachment_filenames, package_name,
-                           include_filename, charset, inline=False):
+                           include_filename, charset, inline=False, savepath=None):
     """ Include a file in the report.
 
         :parameters:
@@ -129,7 +129,7 @@ def include_file_in_report(message, message_filename,
                        fp.read().decode(charset, 'replace'))
             fp.close()
             fp, temp_filename = TempFile(
-                prefix=tempfile_prefix(package_name))
+                prefix=tempfile_prefix(package_name), dir=savepath)
             fp.write(message.encode(charset, 'replace'))
             fp.close()
             os.unlink(message_filename)
@@ -234,7 +234,7 @@ def handle_editing(filename, dmessage, options, sendto, attachments, package,
                         inline = (x == 'i')
                         (message, filename, attachments) = include_file_in_report(
                             message, filename, attachments, package,
-                            attachfile, charset, inline=inline)
+                            attachfile, charset, inline=inline, savepath=options.savepath)
                         if not inline:
                             skip_editing = True
                     else:
@@ -839,6 +839,8 @@ def main():
     parser.add_option('--no-paranoid', action='store_false', dest='paranoid',
                       help='don\'t show contents of message before sending '
                       '(default)')
+    parser.add_option('--savepath', dest="savepath",
+                      help='Save the draft in this directory')
 
     (options, args) = parser.parse_args()
 
@@ -857,6 +859,11 @@ def main():
             print "The above files are missing, so can't be attached; exiting"
             sys.exit(1)
 
+    if options.savepath:
+        options.savepath = os.path.expanduser(options.savepath)
+        if not os.path.exists(options.savepath):
+            print "The directory % does not exist; exiting." % options.savepath
+            sys.exit(1)
 
     if options.mua:
         if not utils.mua_exists(options.mua):
@@ -1730,7 +1737,7 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
             else:
                 handler = '/usr/share/reportbug/handle_bugscript'
 
-            fh, filename = TempFile(prefix=tfprefix)
+            fh, filename = TempFile(prefix=tfprefix, dir=self.options.savepath)
             fh.close()
             ui.system('%s %s %s' % (handler, commands.mkarg(bugexec),
                                  commands.mkarg(filename)))
@@ -1801,7 +1808,7 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
         message = u"Subject: %s\n%s" % (subject, message)
 
         if mailing:
-            fh, filename = TempFile(prefix=tfprefix)
+            fh, filename = TempFile(prefix=tfprefix, dir=self.options.savepath)
             fh.write(message.encode(charset, 'replace'))
             fh.close()
             oldmua = mua or self.options.mua
-- 
1.5.4.3


--=-y6ApeJmTwZ7fWnqlpYJe--






More information about the Reportbug-maint mailing list