[25690] in Source-Commits

home help back first fref pref prev next nref lref last post

/svn/athena r25172 - in trunk/debathena/config/printing-config: debathena/printing debian

daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Mon Jun 27 15:15:15 2011

Date: Mon, 27 Jun 2011 15:15:09 -0400
From: Jonathan D Reed <jdreed@MIT.EDU>
Message-Id: <201106271915.p5RJF9Hv012368@drugstore.mit.edu>
To: source-commits@mit.edu
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: jdreed
Date: 2011-06-27 15:15:09 -0400 (Mon, 27 Jun 2011)
New Revision: 25172

Modified:
   trunk/debathena/config/printing-config/debathena/printing/common.py
   trunk/debathena/config/printing-config/debathena/printing/simple.py
   trunk/debathena/config/printing-config/debian/changelog
Log:
In printing-config:
  * No, really, don't barf on unexpected args (Trac: #719)


Modified: trunk/debathena/config/printing-config/debathena/printing/common.py
===================================================================
--- trunk/debathena/config/printing-config/debathena/printing/common.py	2011-06-27 14:34:09 UTC (rev 25171)
+++ trunk/debathena/config/printing-config/debathena/printing/common.py	2011-06-27 19:15:09 UTC (rev 25172)
@@ -6,6 +6,8 @@
 import socket
 import sys
 import urllib
+import string
+import re
 
 import cups
 import hesiod
@@ -103,6 +105,11 @@
       except getopt.GetoptError:
           # That version doesn't work, so try the next one
           continue
+    
+    # If we got this far, they both failed (read: syntax error)
+    error(2, "Syntax Error: Incorrect option passed.  See the man page for more information.\nA common cause is mixing CUPS and LPRng syntax.\nValid options: %s\n" % 
+          (string.replace(re.sub(r'([a-zA-Z])', r'-\1 ',
+                                 optinfos[SYSTEM_CUPS][1]), ':', '[arg] ')))
 
 
 def extract_opt(options, optname):

Modified: trunk/debathena/config/printing-config/debathena/printing/simple.py
===================================================================
--- trunk/debathena/config/printing-config/debathena/printing/simple.py	2011-06-27 14:34:09 UTC (rev 25171)
+++ trunk/debathena/config/printing-config/debathena/printing/simple.py	2011-06-27 19:15:09 UTC (rev 25172)
@@ -10,8 +10,6 @@
 
 import os
 import sys
-import string
-import re
 
 from debathena.printing import common
 
@@ -21,17 +19,7 @@
 
     queue = common.get_default_printer()
     try:
-        parseresult = common.parse_args(args, optinfo)
-        if parseresult == None:
-            # Don't barf if neither CUPS nor LPRng syntax was valid (and
-            # hence parse_args returns None)
-            # Remove this stupidity when we kill LPRng with fire
-            print "Syntax Error: Incorrect option passed."
-            print "Valid options: " +
-                  string.replace(re.sub(r'([a-zA-Z])', r'-\1 ',
-                                 optinfo[common.SYSTEM_CUPS][1]), ':', '[arg] ')
-            sys.exit(2)
-        argstyle, options, arguments = parseresult
+        argstyle, options, arguments = common.parse_args(args, optinfo)
 
         # Find the last queue specified in the arguments
         queue_args, options = common.extract_opt(options, queue_opt)

Modified: trunk/debathena/config/printing-config/debian/changelog
===================================================================
--- trunk/debathena/config/printing-config/debian/changelog	2011-06-27 14:34:09 UTC (rev 25171)
+++ trunk/debathena/config/printing-config/debian/changelog	2011-06-27 19:15:09 UTC (rev 25172)
@@ -1,8 +1,8 @@
 debathena-printing-config (1.23.4) unstable; urgency=low
 
-  * Minor style fixups
+  * No, really, don't barf on unexpected args (Trac: #719)
 
- -- Benjamin Kaduk <kaduk@mit.edu>  Sun, 19 Jun 2011 17:58:50 -0400
+ -- Jonathan Reed <jdreed@mit.edu>  Mon, 27 Jun 2011 15:14:20 -0400
 
 debathena-printing-config (1.23.3) unstable; urgency=low
 


home help back first fref pref prev next nref lref last post