Changeset 2891

Show
Ignore:
Timestamp:
05/22/06 23:32:15 (18 years ago)
Author:
jerome
Message:

Now uses pkipplib if present.

Location:
pykota/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r2889 r2891  
    4747from pykota.tool import PyKotaTool, PyKotaToolError, crashed 
    4848from pykota.accounter import openAccounter 
    49 from pykota.ipp import IPPRequest, IPPError 
    50          
     49# TODO : remove the three lines below and the code which handles 
     50# TODO : them in a future release. 
     51from pykota.ipp import IPPRequest as oldIPPRequest 
     52from pykota.ipp import IPPError as oldIPPError 
     53 
     54try : 
     55    from pkipplib import pkipplib 
     56except ImportError :         
     57    haspkipplib = False 
     58else :     
     59    haspkipplib = True 
     60     
    5161class FakeObject :         
    5262    """Fake object.""" 
     
    272282                   (self.myname, self.PrinterName, self.UserName, self.JobId)) 
    273283         
    274         (ippfilename, ippmessage) = self.parseIPPRequestFile() 
    275         self.ControlFile = ippfilename 
    276         john = ippmessage.operation_attributes.get("job-originating-host-name", \ 
    277                ippmessage.job_attributes.get("job-originating-host-name", \ 
    278                (None, None))) 
     284        if not haspkipplib : 
     285            (ippfilename, ippmessage) = self.parseIPPRequestFile() 
     286            self.ControlFile = ippfilename 
     287            john = ippmessage.operation_attributes.get("job-originating-host-name", \ 
     288                   ippmessage.job_attributes.get("job-originating-host-name", \ 
     289                   (None, None))) 
     290            jbing = ippmessage.job_attributes.get("job-billing", (None, None)) 
     291        else : 
     292            cupsserver = pkipplib.CUPS(url="http://%s:%s" % \ 
     293                                  (os.environ.get("CUPS_SERVER", "localhost"), \ 
     294                                   os.environ.get("IPP_PORT", "631"))) 
     295            answer = cupsserver.getJobAttributes(self.JobId) 
     296            self.ControlFile = "NotUsedAnymore" 
     297            try : 
     298                john = answer.job["job-originating-host-name"] 
     299            except KeyError :     
     300                try : 
     301                    john = answer.operation["job-originating-host-name"] 
     302                except KeyError :     
     303                    john = (None, None) 
     304            try :         
     305                jbing = answer.job["job-billing"] 
     306            except KeyError :     
     307                jbing = (None, None) 
    279308        if type(john) == type([]) :  
    280309            john = john[-1] 
    281310        (chtype, self.ClientHost) = john  
    282         jbing = ippmessage.job_attributes.get("job-billing", (None, None)) 
    283311        if type(jbing) == type([]) :  
    284312            jbing = jbing[-1] 
     
    520548            self.logdebug("Parsing of IPP request file %s begins." % ippmessagefile) 
    521549            try : 
    522                 ippmessage = IPPRequest(ippdatafile.read()) 
     550                ippmessage = oldIPPRequest(ippdatafile.read()) 
    523551                ippmessage.parse() 
    524             except IPPError, msg :     
     552            except oldIPPError, msg :     
    525553                self.printInfo("Error while parsing %s : %s" \ 
    526554                                      % (ippmessagefile, msg), "warn") 
  • pykota/trunk/NEWS

    r2883 r2891  
    2222PyKota NEWS : 
    2323        
     24    - 1.25alpha4 (2006-05-22) : 
     25     
     26        - Now uses pkipplib if present to directly retrieve the job 
     27          information from the CUPS server over IPP. 
     28           
    2429    - 1.25alpha3 (2006-05-11) : 
    2530     
  • pykota/trunk/pykota/version.py

    r2882 r2891  
    2222# 
    2323 
    24 __version__ = "1.25alpha3_unofficial" 
     24__version__ = "1.25alpha4_unofficial" 
    2525 
    2626__doc__ = "PyKota : a complete Printing Quota Solution for CUPS." 
  • pykota/trunk/README

    r2877 r2891  
    369369      tool is now mandatory for PyKota to work.  
    370370      (http://www.librelogiciel.com/software/) 
     371    - The pkipplib Python library (http://www.pykota.com/software/pkipplib)   
    371372    - The JAXML Python module to be able to dump datas in the XML format. 
    372373      (http://www.librelogiciel.com/software/)