Show
Ignore:
Timestamp:
01/02/04 18:31:26 (20 years ago)
Author:
jalet
Message:

Forgot to remove some code

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/tool.py

    r1240 r1245  
    2222# 
    2323# $Log$ 
    24 # Revision 1.65  2003/12/27 16:49:25  uid67467 
    25 # Should be ok now. 
     24# Revision 1.66  2004/01/02 17:31:26  jalet 
     25# Forgot to remove some code 
    2626# 
    2727# Revision 1.65  2003/12/06 08:14:38  jalet 
     
    294294        self.documentation = doc 
    295295        self.config = config.PyKotaConfig("/etc/pykota") 
    296         self.logger = logger.openLogger(self.config.getLoggingBackend()) 
     296        self.logger = logger.openLogger(self) 
    297297        self.debug = self.config.getDebug() 
    298298        self.storage = storage.openConnection(self) 
     
    580580                self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
    581581            if mailto in [ "BOTH", "USER", "EXTERNAL" ] : 
    582                 message = self.config.getHardWarn(printer.Name) 
    583582                for user in self.storage.getGroupMembers(group) : 
    584583                    if mailto != "EXTERNAL" : 
    585                         self.sendMessageToUser(admin, adminmail, user, _("Print Quota Exceeded"), message) 
     584                        self.sendMessageToUser(admin, adminmail, user, _("Print Quota Exceeded"), self.config.getHardWarn(printer.Name)) 
    586585                    else :     
    587586                        self.externalMailTo(arguments, action, user, printer, message) 
     
    606605        """Checks a user quota and send him a message if quota is exceeded on current printer.""" 
    607606        user = userpquota.User 
    608         actions = [] 
    609         for upq in [userpquota] + userpquota.ParentPrintersUserPQuota : 
    610             printer = upq.Printer 
    611             admin = self.config.getAdmin(printer.Name) 
    612             adminmail = self.config.getAdminMail(printer.Name) 
    613             (mailto, arguments) = self.config.getMailTo(printer.Name) 
    614             self.logdebug("Checking quota for user %s on printer %s" % (upq.User.Name, printer.Name)) 
    615             action = self.checkUserPQuota(upq) 
    616             self.logdebug("Result is %s" % action) 
    617             if action.startswith("POLICY_") : 
    618                 action = action[7:] 
    619             if action == "DENY" : 
    620                 adminmessage = _("Print Quota exceeded for user %s on printer %s") % (user.Name, printer.Name) 
    621                 self.logger.log_message(adminmessage) 
    622                 if mailto in [ "BOTH", "USER", "EXTERNAL" ] : 
    623                     message = self.config.getHardWarn(printer.Name) 
    624                     if mailto != "EXTERNAL" : 
    625                         self.sendMessageToUser(admin, adminmail, user, _("Print Quota Exceeded"), message) 
    626                     else :     
    627                         self.externalMailTo(arguments, action, user, printer, message) 
    628                 if mailto in [ "BOTH", "ADMIN" ] : 
    629                     self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
    630             elif action == "WARN" :     
    631                 adminmessage = _("Print Quota low for user %s on printer %s") % (user.Name, printer.Name) 
    632                 self.logger.log_message(adminmessage) 
    633                 if mailto in [ "BOTH", "USER", "EXTERNAL" ] : 
    634                     if user.LimitBy and (user.LimitBy.lower() == "balance") :  
    635                         message = self.config.getPoorWarn() 
    636                     else :      
    637                         message = self.config.getSoftWarn(printer.Name) 
    638                     if mailto != "EXTERNAL" :     
    639                         self.sendMessageToUser(admin, adminmail, user, _("Print Quota Low"), message) 
    640                     else :     
    641                         self.externalMailTo(arguments, action, user, printer, message) 
    642                 if mailto in [ "BOTH", "ADMIN" ] : 
    643                     self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
    644             actions.append(action)         
    645         if "DENY" in actions :     
    646             self.logdebug("Final result is %s" % action) 
    647             return "DENY" 
    648         elif "WARN" in actions :     
    649             self.logdebug("Final result is %s" % action) 
    650             return "WARN" 
    651         else :     
    652             self.logdebug("Final result is %s" % action) 
    653             return "ALLOW" 
     607        printer = userpquota.Printer 
     608        admin = self.config.getAdmin(printer.Name) 
     609        adminmail = self.config.getAdminMail(printer.Name) 
     610        (mailto, arguments) = self.config.getMailTo(printer.Name) 
     611        action = self.checkUserPQuota(userpquota) 
     612        if action.startswith("POLICY_") : 
     613            action = action[7:] 
     614        if action == "DENY" : 
     615            adminmessage = _("Print Quota exceeded for user %s on printer %s") % (user.Name, printer.Name) 
     616            self.logger.log_message(adminmessage) 
     617            if mailto in [ "BOTH", "USER", "EXTERNAL" ] : 
     618                message = self.config.getHardWarn(printer.Name) 
     619                if mailto != "EXTERNAL" : 
     620                    self.sendMessageToUser(admin, adminmail, user, _("Print Quota Exceeded"), message) 
     621                else :     
     622                    self.externalMailTo(arguments, action, user, printer, message) 
     623            if mailto in [ "BOTH", "ADMIN" ] : 
     624                self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
     625        elif action == "WARN" :     
     626            adminmessage = _("Print Quota low for user %s on printer %s") % (user.Name, printer.Name) 
     627            self.logger.log_message(adminmessage) 
     628            if mailto in [ "BOTH", "USER", "EXTERNAL" ] : 
     629                if user.LimitBy and (user.LimitBy.lower() == "balance") :  
     630                    message = self.config.getPoorWarn() 
     631                else :      
     632                    message = self.config.getSoftWarn(printer.Name) 
     633                if mailto != "EXTERNAL" :     
     634                    self.sendMessageToUser(admin, adminmail, user, _("Print Quota Low"), message) 
     635                else :     
     636                    self.externalMailTo(arguments, action, user, printer, message) 
     637            if mailto in [ "BOTH", "ADMIN" ] : 
     638                self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
     639        return action         
    654640         
    655641class PyKotaFilterOrBackend(PyKotaTool) :     
     
    671657            self.username = self.username.lower() 
    672658        self.preserveinputfile = self.inputfile  
    673         # 
    674         # Export internal data to the environment 
    675         os.environ["PYKOTAUSERNAME"] = str(self.username) 
    676         os.environ["PYKOTAPRINTERNAME"] = str(self.printername) 
    677         os.environ["PYKOTACOPIES"] = str(self.copies) 
    678         os.environ["PYKOTATITLE"] = str(self.title) 
    679         os.environ["PYKOTAOPTIONS"] = str(self.options) 
    680         os.environ["PYKOTAFILENAME"] = str(self.inputfile) 
    681         # 
    682         # And opens the correct accounter  
    683659        self.accounter = accounter.openAccounter(self) 
    684660     
     
    770746           was returned by the external command. 
    771747        """ 
    772         for dummy in range(1, 3) : 
     748        for passnumber in range(1, 3) : 
    773749            printer = self.storage.getPrinter(self.printername) 
    774750            user = self.storage.getUser(self.username)