Show
Ignore:
Timestamp:
05/18/04 16:49:34 (20 years ago)
Author:
jalet
Message:

Big code changes to completely remove the need for "requester" directives,
jsut use "hardware(... your previous requester directive's content ...)"

Files:
1 modified

Legend:

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

    r1475 r1483  
    2222# 
    2323# $Log$ 
     24# Revision 1.47  2004/05/18 14:49:20  jalet 
     25# Big code changes to completely remove the need for "requester" directives, 
     26# jsut use "hardware(... your previous requester directive's content ...)" 
     27# 
    2428# Revision 1.46  2004/05/13 13:59:28  jalet 
    2529# Code simplifications 
     
    311315        validaccounters = [ "hardware", "software" ]      
    312316        fullaccounter = self.getPrinterOption(printername, "accounter").strip() 
    313         if fullaccounter.lower().startswith("software") :     
     317        flower = fullaccounter.lower() 
     318        if flower.startswith("software") or flower.startswith("hardware") :     
    314319            try : 
    315320                (accounter, args) = [x.strip() for x in fullaccounter.split('(', 1)] 
    316321            except ValueError :     
    317                 raise PyKotaConfigError, _("Invalid external accounter %s for printer %s") % (fullaccounter, printername) 
     322                raise PyKotaConfigError, _("Invalid accounter %s for printer %s") % (fullaccounter, printername) 
    318323            if args.endswith(')') : 
    319324                args = args[:-1] 
    320325            if not args : 
    321                 raise PyKotaConfigError, _("Invalid external accounter %s for printer %s") % (fullaccounter, printername) 
     326                raise PyKotaConfigError, _("Invalid accounter %s for printer %s") % (fullaccounter, printername) 
    322327            return (accounter.lower(), args)     
    323         elif fullaccounter.lower() not in validaccounters : 
     328        else : 
    324329            raise PyKotaConfigError, _("Option accounter in section %s only supports values in %s") % (printername, str(validaccounters)) 
    325         else :     
    326             return (fullaccounter.lower(), None) 
    327330         
    328331    def getPreHook(self, printername) :     
     
    340343            return      # No command to launch in the post-hook 
    341344             
    342     def getRequesterBackend(self, printername) :     
    343         """Returns the requester backend to use for a given printer, with its arguments.""" 
    344         try : 
    345             fullrequester = self.getPrinterOption(printername, "requester") 
    346         except PyKotaConfigError :     
    347             # No requester defined, maybe it is not needed if accounting method 
    348             # is not set to 'hardware', but if we are called, then the accounting 
    349             # method really IS 'hardware', and so there's a big problem. 
    350             raise PyKotaConfigError, _("Option requester for printer %s was not set") % printername 
    351         else :     
    352             try : 
    353                 (requester, args) = [x.strip() for x in fullrequester.split('(', 1)] 
    354             except ValueError :     
    355                 raise PyKotaConfigError, _("Invalid requester %s for printer %s") % (fullrequester, printername) 
    356             if args.endswith(')') : 
    357                 args = args[:-1] 
    358             if not args : 
    359                 raise PyKotaConfigError, _("Invalid requester %s for printer %s") % (fullrequester, printername) 
    360             validrequesters = [ "external" ]  
    361             requester = requester.lower() 
    362             if requester not in validrequesters : 
    363                 raise PyKotaConfigError, _("Option requester for printer %s only supports values in %s") % (printername, str(validrequesters)) 
    364             return (requester, args) 
    365          
    366345    def getPrinterPolicy(self, printername) :     
    367346        """Returns the default policy for the current printer."""