Changeset 9 for pkipplib

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

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

Location:
pkipplib/trunk
Files:
2 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             
  • pkipplib/trunk/tests/test.py

    r5 r9  
    2727     
    2828cups = ipplib.CUPS()     
    29 answer = cups.getJobAttributes(566) 
     29answer = cups.getPPD("HL6050DN") 
     30#answer = cups.getJobAttributes(566) 
    3031print answer 
    3132#print answer.operation["attributes-charset"]