Index: pykota/trunk/bin/pkbanner
===================================================================
--- pykota/trunk/bin/pkbanner (revision 3411)
+++ pykota/trunk/bin/pkbanner (revision 3413)
@@ -9,10 +9,10 @@
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
@@ -22,5 +22,5 @@
 #
 
-"""A banner generator for PyKota"""        
+"""A banner generator for PyKota"""
 
 import sys
@@ -34,16 +34,16 @@
     import reportlab.lib
     from reportlab.lib.units import cm
-except ImportError :    
+except ImportError :
     hasRL = False
-else :    
+else :
     hasRL = True
-    
+
 try :
-    import PIL.Image 
-except ImportError :    
+    import PIL.Image
+except ImportError :
     hasPIL = False
-else :    
+else :
     hasPIL = True
-    
+
 import pykota.appinit
 from pykota.utils import run
@@ -56,15 +56,15 @@
 from pykota import version
 
-class PyKotaBanner(Tool) :        
+class PyKotaBanner(Tool) :
     """A class for pkbanner."""
-    def getVar(self, varname) :            
+    def getVar(self, varname) :
         """Extracts a variable from the environment and returns its value or 'Unknown' in the current locale."""
         return os.environ.get(varname) or _("Unknown")
-        
+
     def printVar(self, canvas, x, y, label, value, size, savetoner) :
         """Outputs a variable onto the PDF canvas.
-        
+
            Returns the number of points to substract to current Y coordinate.
-        """   
+        """
         canvas.saveState()
         canvas.setFont("Helvetica-Bold", size)
@@ -79,27 +79,27 @@
         canvas.restoreState()
         return (size + 4)
-    
+
     def genPDF(self, pagesize, logo, url, text, savetoner) :
         """Generates the banner in PDF format, return the PDF document as a string."""
         document = cStringIO.StringIO()
         c = canvas.Canvas(document, pagesize=pagesize, pageCompression=1)
-        
+
         c.setAuthor(self.effectiveUserName)
         c.setTitle(_("PyKota generated Banner"))
         c.setSubject(_("This is a print banner generated with PyKota"))
-        
+
         xcenter = pagesize[0] / 2.0
         ycenter = pagesize[1] / 2.0
-                    
-        ypos = pagesize[1] - (2 * cm)            
-        
+
+        ypos = pagesize[1] - (2 * cm)
+
         if logo :
-            try :    
+            try :
                 imglogo = PIL.Image.open(logo)
-            except :    
+            except :
                 self.printInfo("Unable to open image %s" % logo, "warn")
             else :
                 (width, height) = imglogo.size
-                multi = float(width) / (8 * cm) 
+                multi = float(width) / (8 * cm)
                 width = float(width) / multi
                 height = float(height) / multi
@@ -107,78 +107,78 @@
                 ypos -= height
                 c.drawImage(logo, xpos, ypos, width, height)
-        
+
         # New top
         xpos = pagesize[0] / 5.0
         ypos -= (1 * cm) + 20
-        
+
         printername = self.getVar("PYKOTAPRINTERNAME")
         username = self.getVar("PYKOTAUSERNAME")
         accountbanner = self.config.getAccountBanner(printername)
-        
+
         # Outputs the username
-        ypos -= self.printVar(c, xcenter, ypos, _("Username"), username, 20, savetoner) 
-        
-        # Text    
+        ypos -= self.printVar(c, xcenter, ypos, _("Username"), username, 20, savetoner)
+
+        # Text
         if text :
-            ypos -= self.printVar(c, xcenter, ypos, _("More Info"), text, 20, savetoner) 
-        
+            ypos -= self.printVar(c, xcenter, ypos, _("More Info"), text, 20, savetoner)
+
         # Printer and Job Id
         job = "%s - %s" % (printername, self.getVar("PYKOTAJOBID"))
-        ypos -= self.printVar(c, xcenter, ypos, _("Job"), job, 14, savetoner) 
-        
+        ypos -= self.printVar(c, xcenter, ypos, _("Job"), job, 14, savetoner)
+
         # Current date (TODO : at the time the banner was printed ! Change this to job's submission date)
         datetime = time.strftime("%c", time.localtime()).decode(self.charset, "replace")
-        ypos -= self.printVar(c, xcenter, ypos, _("Date"), datetime, 14, savetoner) 
-        
+        ypos -= self.printVar(c, xcenter, ypos, _("Date"), datetime, 14, savetoner)
+
         # Result of the print job
         action = self.getVar("PYKOTAACTION")
         if action == "ALLOW" :
             action = _("Allowed")
-        elif action == "DENY" :    
+        elif action == "DENY" :
             action = _("Denied")
-        elif action == "WARN" :    
+        elif action == "WARN" :
             action = _("Allowed with Warning")
-        elif action == "PROBLEM" :    
+        elif action == "PROBLEM" :
             # should never occur
             action = _("Problem")
-        elif action == "CANCEL" :    
+        elif action == "CANCEL" :
             # should never occur
             action = _("Cancelled")
-        ypos -= self.printVar(c, xcenter, ypos, _("Result"), action, 14, savetoner) 
-        
+        ypos -= self.printVar(c, xcenter, ypos, _("Result"), action, 14, savetoner)
+
         # skip some space
         ypos -= 20
-        
+
         # Outputs title and filename
         # We put them at x=0.25*pagewidth so that the line is long enough to hold them
         title = self.getVar("PYKOTATITLE")
-        ypos -= self.printVar(c, xcenter / 2.0, ypos, _("Title"), title, 10, savetoner) 
-        
+        ypos -= self.printVar(c, xcenter / 2.0, ypos, _("Title"), title, 10, savetoner)
+
         filename = self.getVar("PYKOTAFILENAME")
-        ypos -= self.printVar(c, xcenter / 2.0, ypos, _("Filename"), filename, 10, savetoner) 
-        
+        ypos -= self.printVar(c, xcenter / 2.0, ypos, _("Filename"), filename, 10, savetoner)
+
         # skip some space
         ypos -= 20
-        
+
         # Now outputs the user's account balance or page counter
-        ypos -= self.printVar(c, xcenter, ypos, _("Pages printed so far on %s") % printername, self.getVar("PYKOTAPAGECOUNTER"), 14, savetoner) 
+        ypos -= self.printVar(c, xcenter, ypos, _("Pages printed so far on %s") % printername, self.getVar("PYKOTAPAGECOUNTER"), 14, savetoner)
         limitby = self.getVar("PYKOTALIMITBY")
-        if limitby == "balance" :  
-            ypos -= self.printVar(c, xcenter, ypos, _("Account balance"), self.getVar("PYKOTABALANCE"), 14, savetoner) 
+        if limitby == "balance" :
+            ypos -= self.printVar(c, xcenter, ypos, _("Account balance"), self.getVar("PYKOTABALANCE"), 14, savetoner)
         elif limitby == "quota" :
-            ypos -= self.printVar(c, xcenter, ypos, _("Soft Limit"), self.getVar("PYKOTASOFTLIMIT"), 14, savetoner) 
-            ypos -= self.printVar(c, xcenter, ypos, _("Hard Limit"), self.getVar("PYKOTAHARDLIMIT"), 14, savetoner) 
-            ypos -= self.printVar(c, xcenter, ypos, _("Date Limit"), self.getVar("PYKOTADATELIMIT"), 14, savetoner) 
+            ypos -= self.printVar(c, xcenter, ypos, _("Soft Limit"), self.getVar("PYKOTASOFTLIMIT"), 14, savetoner)
+            ypos -= self.printVar(c, xcenter, ypos, _("Hard Limit"), self.getVar("PYKOTAHARDLIMIT"), 14, savetoner)
+            ypos -= self.printVar(c, xcenter, ypos, _("Date Limit"), self.getVar("PYKOTADATELIMIT"), 14, savetoner)
         else :
             if limitby == "noquota" :
                 msg = _("No Limit")
-            elif limitby == "nochange" :    
+            elif limitby == "nochange" :
                 msg = _("No Accounting")
-            elif limitby == "noprint" :    
+            elif limitby == "noprint" :
                 msg = _("Forbidden")
-            else :    
+            else :
                 msg = _("Unknown")
             ypos -= self.printVar(c, xcenter, ypos, _("Printing Mode"), msg, 14, savetoner)
-            
+
         # URL
         if url :
@@ -189,9 +189,9 @@
             c.drawCentredString(xcenter, 2 * cm, url)
             c.restoreState()
-        
+
         c.showPage()
         c.save()
         return document.getvalue()
-        
+
     def main(self, arguments, options) :
         """Generates a banner."""
@@ -200,13 +200,13 @@
         if not hasPIL :
             raise PyKotaToolError, "The Python Imaging Library is missing. Download it from http://www.pythonware.com/downloads"
-            
-        self.logdebug("Generating the banner in PDF format...")    
+
+        self.logdebug("Generating the banner in PDF format...")
         doc = self.genPDF(getPageSize(options.pagesize),
-                          options.logo.strip().encode(sys.getfilesystemencoding(), "replace"), 
-                          options.url.strip(), 
-                          " ".join(arguments).strip(), 
+                          options.logo.strip().encode(sys.getfilesystemencoding(), "replace"),
+                          options.url.strip(),
+                          " ".join(arguments).strip(),
                           options.savetoner / 100.0)
-        
-        self.logdebug("Converting the banner to PostScript...")    
+
+        self.logdebug("Converting the banner to PostScript...")
         command = "gs -q -dNOPAUSE -dBATCH -dPARANOIDSAFER -sDEVICE=pswrite -sOutputFile=- -"
         subpr = subprocess.Popen(command,
@@ -215,7 +215,7 @@
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)
-        try :                         
+        try :
             (out, err) = subpr.communicate(doc)
-        except OSError, msg :    
+        except OSError, msg :
             raise PyKotaToolError, _("Impossible to execute '%(command)s'") % locals()
         status = subpr.wait()
@@ -255,4 +255,4 @@
     parser.add_example('--logo="" --savetoner=75',
                        _("This would generate a banner in the default page size, with no logo, and text luminosity would be increased by 75%."))
-                       
+
     run(parser, PyKotaBanner)
