Changeset 23 for pkipplib

Show
Ignore:
Timestamp:
06/05/06 23:14:50 (18 years ago)
Author:
jerome
Message:

Now keeps the latest error and error messages seen.

Location:
pkipplib/trunk/pkipplib
Files:
2 modified

Legend:

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

    r22 r23  
    598598        except (urllib2.URLError, urllib2.HTTPError, socket.error), error :     
    599599            self.error = error 
    600             sys.stderr.write("ERROR : %s\n" % str(error)) 
    601600            return None 
    602601        else :     
     
    617616        self.charset = charset 
    618617        self.language = language 
     618        self.lastError = None 
     619        self.lastErrorMessage = None 
    619620         
    620621    def identifierToURI(self, service, ident) : 
     
    635636            return req 
    636637     
     638    def doRequest(self, req) : 
     639        """Does a request and saves its error status in the lastErrorMessage attribute.""" 
     640        result = req.doRequest() 
     641        self.lastError = req.error 
     642        self.lastErrorMessage = str(req.error) 
     643        return result 
     644         
    637645    def getDefault(self) : 
    638646        """Retrieves CUPS' default printer.""" 
    639         return self.newRequest(CUPS_GET_DEFAULT).doRequest() 
     647        return self.doRequest(self.newRequest(CUPS_GET_DEFAULT)) 
    640648     
    641649    def getJobAttributes(self, jobid) :     
     
    643651        req = self.newRequest(IPP_GET_JOB_ATTRIBUTES) 
    644652        req.operation["job-uri"] = ("uri", self.identifierToURI("jobs", jobid)) 
    645         return req.doRequest() 
     653        return self.doRequest(req) 
    646654         
    647655    def getPPD(self, queuename) :     
     
    651659        for attrib in ("printer-uri-supported", "printer-type", "member-uris") : 
    652660            req.operation["requested-attributes"] = ("nameWithoutLanguage", attrib) 
    653         return req.doRequest()  # TODO : get the PPD from the actual print server 
     661        return self.doRequest(req)  # TODO : get the PPD from the actual print server 
    654662         
    655663             
    656664if __name__ == "__main__" :             
    657665    if (len(sys.argv) < 2) or (sys.argv[1] == "--debug") : 
    658         print "usage : python ipp.py /var/spool/cups/c00005 [--debug] (for example)\n" 
     666        print "usage : python pkipplib.py /var/spool/cups/c00005 [--debug] (for example)\n" 
    659667    else :     
    660668        infile = open(sys.argv[1], "rb") 
  • pkipplib/trunk/pkipplib/version.py

    r22 r23  
    2121# 
    2222 
    23 __version__ = "0.05" 
     23__version__ = "0.06" 
    2424 
    2525__doc__ = "pkipplib : IPP and CUPS support for Python."