Index: pykota/trunk/bin/warnpykota
===================================================================
--- pykota/trunk/bin/warnpykota (revision 3411)
+++ pykota/trunk/bin/warnpykota (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/>.
@@ -25,5 +25,5 @@
 notifications to users or groups who have reached the limit of their
 printing quota."""
-        
+
 import sys
 import os
@@ -41,12 +41,12 @@
 from pykota.tool import PyKotaTool
 
-class WarnPyKota(PyKotaTool) :        
+class WarnPyKota(PyKotaTool) :
     """A class for warnpykota."""
     def sendMessage(self, adminmail, touser, fullmessage) :
         """Sends an email message containing headers to some user."""
         smtpserver = self.smtpserver
-        try :    
+        try :
             server = smtplib.SMTP(smtpserver)
-        except socket.error, msg :    
+        except socket.error, msg :
             self.printInfo(_("Impossible to connect to SMTP server : %(smtpserver)s") \
                                                 % locals(), \
@@ -55,5 +55,5 @@
             try :
                 server.sendmail(adminmail, [touser], fullmessage)
-            except smtplib.SMTPException, answer :    
+            except smtplib.SMTPException, answer :
                 for (k, v) in answer.recipients.items() :
                     errormsg = v[0]
@@ -63,5 +63,5 @@
                                    "error")
             server.quit()
-            
+
     def sendMessageToUser(self, admin, adminmail, user, subject, message) :
         """Sends an email message to a user."""
@@ -76,5 +76,5 @@
         msg["Date"] = email.Utils.formatdate(localtime=True)
         self.sendMessage(adminmail, usermail, msg.as_string())
-        
+
     def sendMessageToAdmin(self, adminmail, subject, message) :
         """Sends an email message to the Print Quota administrator."""
@@ -86,5 +86,5 @@
         msg["To"] = adminmail
         self.sendMessage(adminmail, adminmail, msg.as_string())
-        
+
     def warnGroupPQuota(self, grouppquota) :
         """Checks a group quota and send messages if quota is exceeded on current printer."""
@@ -98,5 +98,5 @@
         if group.LimitBy in ("noquota", "nochange") :
             action = "ALLOW"
-        else :    
+        else :
             action = self.checkGroupPQuota(grouppquota)
             if action.startswith("POLICY_") :
@@ -111,14 +111,14 @@
                         if mailto != "EXTERNAL" :
                             self.sendMessageToUser(admin, adminmail, user, _("Print Quota Exceeded"), self.config.getHardWarn(printername))
-                        else :    
+                        else :
                             self.externalMailTo(arguments, action, user, printer, self.config.getHardWarn(printername))
-            elif action == "WARN" :    
+            elif action == "WARN" :
                 adminmessage = _("Print Quota low for group %(groupname)s on printer %(printername)s") % locals()
                 self.printInfo(adminmessage)
                 if mailto in [ "BOTH", "ADMIN" ] :
                     self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage)
-                if group.LimitBy and (group.LimitBy.lower() == "balance") : 
+                if group.LimitBy and (group.LimitBy.lower() == "balance") :
                     message = self.config.getPoorWarn()
-                else :     
+                else :
                     message = self.config.getSoftWarn(printername)
                 if mailto in [ "BOTH", "USER", "EXTERNAL" ] :
@@ -126,8 +126,8 @@
                         if mailto != "EXTERNAL" :
                             self.sendMessageToUser(admin, adminmail, user, _("Print Quota Exceeded"), message)
-                        else :    
+                        else :
                             self.externalMailTo(arguments, action, user, printer, message)
-        return action        
-        
+        return action
+
     def warnUserPQuota(self, userpquota) :
         """Checks a user quota and send him a message if quota is exceeded on current printer."""
@@ -139,5 +139,5 @@
         adminmail = self.config.getAdminMail(printername)
         (mailto, arguments) = self.config.getMailTo(printername)
-        
+
         if user.LimitBy in ("noquota", "nochange") :
             action = "ALLOW"
@@ -149,5 +149,5 @@
                 if mailto != "EXTERNAL" :
                     self.sendMessageToUser(admin, adminmail, user, _("Printing denied."), message)
-                else :    
+                else :
                     self.externalMailTo(arguments, action, user, printer, message)
             if mailto in [ "BOTH", "ADMIN" ] :
@@ -157,5 +157,5 @@
             if action.startswith("POLICY_") :
                 action = action[7:]
-                
+
             if action == "DENY" :
                 adminmessage = _("Print Quota exceeded for user %(username)s on printer %(printername)s") % locals()
@@ -165,24 +165,24 @@
                     if mailto != "EXTERNAL" :
                         self.sendMessageToUser(admin, adminmail, user, _("Print Quota Exceeded"), message)
-                    else :    
+                    else :
                         self.externalMailTo(arguments, action, user, printer, message)
                 if mailto in [ "BOTH", "ADMIN" ] :
                     self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage)
-            elif action == "WARN" :    
+            elif action == "WARN" :
                 adminmessage = _("Print Quota low for user %(username)s on printer %(printername)s") % locals()
                 self.printInfo(adminmessage)
                 if mailto in [ "BOTH", "USER", "EXTERNAL" ] :
-                    if user.LimitBy and (user.LimitBy.lower() == "balance") : 
+                    if user.LimitBy and (user.LimitBy.lower() == "balance") :
                         message = self.config.getPoorWarn()
-                    else :     
+                    else :
                         message = self.config.getSoftWarn(printername)
-                    if mailto != "EXTERNAL" :    
+                    if mailto != "EXTERNAL" :
                         self.sendMessageToUser(admin, adminmail, user, _("Print Quota Low"), message)
-                    else :    
+                    else :
                         self.externalMailTo(arguments, action, user, printer, message)
                 if mailto in [ "BOTH", "ADMIN" ] :
                     self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage)
-        return action        
-        
+        return action
+
     def main(self, ugnames, options) :
         """Warn users or groups over print quota."""
@@ -192,5 +192,5 @@
                 # no username, means all usernames
                 ugnames = [ "*" ]
-        else :        
+        else :
             # not a PyKota administrator
             # warns only the current user
@@ -203,9 +203,9 @@
                 if user.Exists :
                     ugnames = [ g.Name for g in self.storage.getUserGroups(user) ]
-                else :    
+                else :
                     ugnames = [ ]
             else :
                 ugnames = [ username ]
-                
+
         printername = options.printer
         printers = self.storage.getMatchingPrinters(printername)
@@ -231,6 +231,6 @@
                             if not done :
                                 alreadydone[user.Name] = (action in ('WARN', 'DENY'))
-                     
-if __name__ == "__main__" : 
+
+if __name__ == "__main__" :
     parser = PyKotaOptionParser(description=_("A tool to warn users and groups who have reached the limit of their printing quota."),
                                 usage="warnpykota [options] [usernames|groupnames]")
@@ -243,5 +243,5 @@
                             default="*",
                             help=_("Acts on this printer only. You can specify several printer names by separating them with commas. The default value is '%default', which means all printers."))
-                            
+
     parser.add_example('',
                        _("This would notify all users who have reached the limit of their printing quota on any printer."))
@@ -250,4 +250,4 @@
     parser.add_example('--groups --printer "HP*,XER*" "dev*"',
                        _("This would notify all users of the groups whose name begins with 'dev' and for which the printing quota limit is reached on any printer whose name begins with 'HP' or 'XER'."))
-                       
+
     run(parser, WarnPyKota)
