[Reportbug-commits] [SCM] Reportbug - reports bugs in the Debian distribution branch, master, updated. 4.3-4-g43e387c

Sandro Tosi morph at debian.org
Mon May 25 18:23:05 UTC 2009


The following commit has been merged in the master branch:
commit 7c8442c5bc36c41f506347c01d852aa78daeae9a
Author: Carl Chenet <carl.chenet at ohmytux.com>
Date:   Fri May 15 01:14:31 2009 +0200

    enforce mua checking for --mua option

diff --git a/bin/reportbug b/bin/reportbug
index b48f268..ed0bff1 100755
--- a/bin/reportbug
+++ b/bin/reportbug
@@ -859,10 +859,16 @@ def main():
 
 
     if options.mua:
+        if not utils.mua_is_supported(options.mua):
+            ewrite("Specified mail user agent is not supported; exiting.\n")
+            sys.exit(1)
+
         if not utils.mua_exists(options.mua):
             ewrite("Selected mail user agent cannot be found; exiting.\n")
             sys.exit(1)
 
+        options.mua = utils.mua_name(options.mua)
+
     if options.interface:
         interface = options.interface
 
diff --git a/reportbug/utils.py b/reportbug/utils.py
index 877afb9..4b53d16 100644
--- a/reportbug/utils.py
+++ b/reportbug/utils.py
@@ -761,14 +761,22 @@ MUA = {
 MUA['nmh'] = MUA['mh']
 
 MUAVERSION = {
-    'mutt' : 'mutt -v',
-    'af' : 'af -v ',
-    'mh' : '/usr/bin/mh/comp -use -file',
-    'gnus' : 'emacs --version',
+    MUA['mutt'] : 'mutt -v',
+    MUA[ 'af'] : 'af -v ',
+    MUA['mh'] : '/usr/bin/mh/comp -use -file',
+    MUA['gnus'] : 'emacs --version',
     }
-MUAVERSION['nmh'] = MUAVERSION['mh']
+
+def mua_is_supported(mua):
+    # check if the mua is supported by reportbug
+    if mua.split()[0] not in MUA:
+        return False
+    else:
+        return True
 
 def mua_exists(mua):
+    # check if the mua is available on the system
+    mua = MUA[mua.split()[0]]
     output = '/dev/null'
     if os.path.exists(output):
         try:
@@ -783,6 +791,13 @@ def mua_exists(mua):
     else:
         return True
 
+def mua_name(mua):
+    # in case the user specifies only the mua name in --mua, returns the default options
+    if mua in MUA:
+        return MUA[mua]
+    else:
+        return mua
+
 def first_run():
     return not os.path.exists(USERFILE)
 

-- 
Reportbug - reports bugs in the Debian distribution



More information about the Reportbug-commits mailing list