[Reportbug-commits] [SCM] Reportbug - reports bugs in the Debian distribution branch, master, updated. 4.2-12-gdd14d15

Sandro Tosi morph at debian.org
Sat May 9 09:39:44 UTC 2009


The following commit has been merged in the master branch:
commit 23bd5b175f312be96b356d2359dbfa978c8d78e8
Author: Carl Chenet <carl.chenet at ohmytux.com>
Date:   Thu Apr 23 19:36:25 2009 +0200

    Check if the mua exists.

diff --git a/bin/reportbug b/bin/reportbug
index be27a5c..da0cab9 100755
--- a/bin/reportbug
+++ b/bin/reportbug
@@ -244,10 +244,13 @@ def handle_editing(filename, dmessage, options, sendto, attachments, package,
             mailer = ui.menu('Choose a mailer for your report', mailers,
                              'Select mailer: ', default='', empty_ok=True)
             if mailer:
-                mailer = utils.MUA.get(mailer)
-                if mailer:
-                    options.mua = mailer
-                    break
+                if not utils.mua_exists(utils.MUA[mailer]):
+                    ewrite("Your mail user agent can not be found.\n")
+                else:
+                    mailer = utils.MUA.get(mailer)
+                    if mailer:
+                        options.mua = mailer
+                        break
             skip_editing = True
         elif x in ('n', 'q'):
             stopmsg(filename)
@@ -835,6 +838,12 @@ def main():
             print "The above files are missing, so can't be attached; exiting"
             sys.exit(1)
 
+
+    if options.mua:
+        if not utils.mua_exists(options.mua):
+            ewrite("Your mail user agent can not be found; exiting.\n")
+            sys.exit(1)
+
     if options.interface:
         interface = options.interface
 
diff --git a/reportbug/utils.py b/reportbug/utils.py
index 7341633..31ccbea 100644
--- a/reportbug/utils.py
+++ b/reportbug/utils.py
@@ -759,6 +759,28 @@ MUA = {
     }
 MUA['nmh'] = MUA['mh']
 
+MUAVERSION = {
+    MUA['mutt'] : 'mutt -v',
+    MUA[ 'af'] : 'af -v ',
+    MUA['mh'] : '/usr/bin/mh/comp -use -file',
+    MUA['gnus'] : 'emacs --version',
+    }
+
+def mua_exists(mua):
+    output = '/dev/null'
+    if os.path.exists(output):
+        try:
+            returnvalue = subprocess.call(MUAVERSION[mua], stdout=open(output, 'w'), stderr=subprocess.STDOUT, shell=True)
+        except IOError, OSError:
+            returnvalue = subprocess.call(MUAVERSION[mua], shell=True)
+    else:
+        returnvalue = subprocess.call(MUAVERSION[mua], shell=True)
+    # 127 is the shell standard return value to indicate a 'command not found' result
+    if returnvalue == 127:
+        return False
+    else:
+        return True        
+
 def first_run():
     return not os.path.exists(USERFILE)
 

-- 
Reportbug - reports bugs in the Debian distribution



More information about the Reportbug-commits mailing list