Show
Ignore:
Timestamp:
11/03/07 11:09:17 (17 years ago)
Author:
jerome
Message:

Can now print again under limited circumstances.

Files:
1 modified

Legend:

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

    r3249 r3252  
    3030    raise RuntimeError, "The python-pkipplib module is now mandatory. You can download pkipplib from http://www.pykota.com/" 
    3131 
    32 class Job :     
     32class JobTicket :     
    3333    """A class to hold CUPS print job informations.""" 
    34     def __init__(self, jobid=None, copies=1, filename=None) : 
     34    def __init__(self, jobid=None, printername=None, copies=1, filename=None, \ 
     35                       options=None) : 
    3536        """Initializes a print job's information.""" 
    3637        self.JobId = jobid 
     38        self.PrinterName = printername 
    3739        self.Copies = copies 
    3840        self.FileName = filename 
     41        self.Options = options 
    3942        self.Charset = None 
    40         self.UserName = None 
     43        self.OriginatingUserName = None 
     44        self.OriginalUserName = None 
    4145        self.Title = None 
    4246        self.BillingCode = None 
     
    6165    def retrieveAttributesFromCUPS(self) : 
    6266        """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() 
    6371        server = pkipplib.CUPS() # TODO : username and password and/or encryption 
    6472        answer = server.getJobAttributes(self.JobId) 
     
    6674            raise PyKotaToolError, "Network error while querying the CUPS server : %s" \ 
    6775                                      % server.lastErrorMessage 
    68         (dummy, self.Charset) = self.getAttributeTypeAndValue(answer, "attributes-charset", "operation")                               
    69         (dummy, self.UserName) = self.getAttributeTypeAndValue(answer, "job-originating-user-name") 
     76        (dummy, self.Charset) = self.getAttributeTypeAndValue(answer, "attributes-charset", "operation") 
     77        (dummy, self.OriginatingUserName) = self.getAttributeTypeAndValue(answer, "job-originating-user-name") 
    7078        (dummy, self.Title) = self.getAttributeTypeAndValue(answer, "job-name") 
    7179        (dummy, self.BillingCode) = self.getAttributeTypeAndValue(answer, "job-billing") 
     
    7583        (dummy, self.TimeAtProcessing) = self.getAttributeTypeAndValue(answer, "time-at-processing") 
    7684        (dummy, self.MimeType) = self.getAttributeTypeAndValue(answer, "document-format") 
     85        self.OriginalUserName = self.OriginatingUserName[:] 
    7786     
    7887if __name__ == "__main__" :     
     
    8190        sys.stderr.write("usage : python cups.py jobid\n") 
    8291    else :     
    83         job = Job(int(sys.argv[1])) 
    84         for attribute in ("Charset", "JobId", "Copies", "FileName", "UserName",  
     92        job = JobTicket(int(sys.argv[1])) 
     93        for attribute in ("Charset", "JobId", "Copies", "FileName", "OriginatingUserName",  
    8594                          "Title", "BillingCode", "OriginatingHostName",  
    8695                          "TimeAtCreation", "TimeAtProcessing", "UUID",