Show
Ignore:
Timestamp:
11/19/07 14:13:38 (16 years ago)
Author:
jerome
Message:

Now all job attributes are stored as unicode values.

Files:
1 modified

Legend:

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

    r3252 r3255  
    6565    def retrieveAttributesFromCUPS(self) : 
    6666        """Retrieve attribute's values from CUPS.""" 
    67         import os 
    68         f = open("/tmp/debug", "w") 
    69         f.write("%s\n" % os.environ.get("CUPS_SERVER", "")) 
    70         f.close() 
    7167        server = pkipplib.CUPS() # TODO : username and password and/or encryption 
    7268        answer = server.getJobAttributes(self.JobId) 
     
    8379        (dummy, self.TimeAtProcessing) = self.getAttributeTypeAndValue(answer, "time-at-processing") 
    8480        (dummy, self.MimeType) = self.getAttributeTypeAndValue(answer, "document-format") 
     81         
     82        for attrib in ("OriginatingUserName",  
     83                       "OriginatingHostName", 
     84                       "Title",  
     85                       "BillingCode", 
     86                       "PrinterName", 
     87                       "Options", 
     88                       "Charset", 
     89                       "UUID", 
     90                       "MimeType") : 
     91            try :            
     92                setattr(self, attrib,  
     93                              getattr(self, attrib).decode("UTF-8", "replace")) 
     94            except AttributeError :                   
     95                pass 
     96                 
    8597        self.OriginalUserName = self.OriginatingUserName[:] 
    8698     
     
    90102        sys.stderr.write("usage : python cups.py jobid\n") 
    91103    else :     
    92         job = JobTicket(int(sys.argv[1])) 
    93         for attribute in ("Charset", "JobId", "Copies", "FileName", "OriginatingUserName",  
     104        job = JobTicket(int(sys.argv[1]), "FakePrinter") 
     105        for attribute in ("PrinterName", "Charset", "JobId", "Copies",  
     106                          "FileName", "OriginatingUserName",  
    94107                          "Title", "BillingCode", "OriginatingHostName",  
    95                           "TimeAtCreation", "TimeAtProcessing", "UUID", 
     108                          "TimeAtCreation", "TimeAtProcessing", "UUID",  
    96109                          "MimeType") : 
    97110            sys.stdout.write("%s : %s\n" % (attribute, repr(getattr(job, attribute))))