Changeset 9 for pkipplib/trunk/ipplib

Show
Ignore:
Timestamp:
05/19/06 16:37:38 (18 years ago)
Author:
jerome
Message:

Added a new method (not finished) to CUPS' API.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pkipplib/trunk/ipplib/ipplib.py

    r8 r9  
    591591        self.language = language 
    592592         
     593    def identifierToURI(self, service, ident) : 
     594        """Transforms an identifier into a particular URI depending on requested service.""" 
     595        return "%s/%s/%s" % (self.url.replace("http://", "ipp://"), 
     596                             service, 
     597                             ident) 
     598         
    593599    def newRequest(self, operationid=None) : 
    594600        """Generates a new empty request.""" 
     
    609615        """Retrieves a print job's attributes.""" 
    610616        req = self.newRequest(IPP_GET_JOB_ATTRIBUTES) 
    611         req.operation["job-uri"] = ("uri", "%s/jobs/%s" % (self.url.replace("http://", "ipp://"), jobid)) 
     617        req.operation["job-uri"] = ("uri", self.identifierToURI("jobs", jobid)) 
    612618        return req.doRequest() 
     619         
     620    def getPPD(self, queuename) :     
     621        """Retrieves the PPD for a particular queuename.""" 
     622        req = self.newRequest(IPP_GET_PRINTER_ATTRIBUTES) 
     623        req.operation["printer-uri"] = ("uri", self.identifierToURI("printers", queuename)) 
     624        for attrib in ("printer-uri-supported", "printer-type", "member-uris") : 
     625            req.operation["requested-attributes"] = ("nameWithoutLanguage", attrib) 
     626        return req.doRequest()  # TODO : get the PPD from the actual print server 
    613627         
    614628