Show
Ignore:
Timestamp:
04/29/03 20:37:54 (21 years ago)
Author:
jalet
Message:

Pluggable accounting methods (actually doesn't support external scripts)

Files:
1 modified

Legend:

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

    r956 r973  
    2121# 
    2222# $Log$ 
     23# Revision 1.39  2003/04/29 18:37:54  jalet 
     24# Pluggable accounting methods (actually doesn't support external scripts) 
     25# 
    2326# Revision 1.38  2003/04/24 11:53:48  jalet 
    2427# Default policy for unknown users/groups is to DENY printing instead 
     
    200203        self.storage = storage.openConnection(self.config, asadmin=asadmin) 
    201204        self.smtpserver = self.config.getSMTPServer() 
    202          
    203     def extractInfoFromCupsOrLprng(self) :     
    204         """Returns a tuple (printingsystem, printerhostname, printername, username, jobid, filename) depending on the printing system in use (as seen by the print filter). 
    205          
    206            Returns (None, None, None, None, None, None) if no printing system is recognized. 
    207         """ 
    208         # Try to detect CUPS 
    209         if os.environ.has_key("CUPS_SERVERROOT") and os.path.isdir(os.environ.get("CUPS_SERVERROOT", "")) : 
    210             if len(sys.argv) == 7 : 
    211                 inputfile = sys.argv[6] 
    212             else :     
    213                 inputfile = None 
    214                  
    215             device_uri = os.environ.get("DEVICE_URI", "") 
    216             # TODO : check this for more complex urls than ipp://myprinter.dot.com:631/printers/lp 
    217             try : 
    218                 (backend, destination) = device_uri.split(":", 1)  
    219             except ValueError :     
    220                 raise PyKotaToolError, "Invalid DEVICE_URI : %s\n" % device_uri 
    221             while destination.startswith("/") : 
    222                 destination = destination[1:] 
    223             printerhostname = destination.split("/")[0].split(":")[0] 
    224             return ("CUPS", printerhostname, os.environ.get("PRINTER"), sys.argv[2].strip(), sys.argv[1].strip(), inputfile) 
    225         else :     
    226             # Try to detect LPRng 
    227             jseen = Jseen = Pseen = nseen = rseen = None 
    228             for arg in sys.argv : 
    229                 if arg.startswith("-j") : 
    230                     jseen = arg[2:].strip() 
    231                 elif arg.startswith("-J") :     
    232                     Jseen = arg[2:].strip() 
    233                     if Jseen == "(STDIN)" : 
    234                         Jseen = None 
    235                 elif arg.startswith("-n") :      
    236                     nseen = arg[2:].strip() 
    237                 elif arg.startswith("-P") :     
    238                     Pseen = arg[2:].strip() 
    239                 elif arg.startswith("-r") :     
    240                     rseen = arg[2:].strip() 
    241             if jseen and Pseen and nseen and rseen :         
    242                 return ("LPRNG", rseen, Pseen, nseen, jseen, Jseen) 
    243         return (None, None, None, None, None, None)   # Unknown printing system           
    244205         
    245206    def display_version_and_quit(self) :