Changeset 3252 for pykota/trunk/pykota

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

Can now print again under limited circumstances.

Location:
pykota/trunk/pykota
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/accounters/ink.py

    r3245 r3252  
    8888                    jobsize = len(pages) 
    8989                    try : 
    90                         if self.filter.InputFile is not None : 
     90                        if self.filter.Ticket.FileName is not None : 
    9191                            # when a filename is passed as an argument, the backend  
    9292                            # must generate the correct number of copies. 
    93                             jobsize *= self.filter.Copies 
    94                             self.inkUsage *= self.filter.Copies 
     93                            jobsize *= self.filter.Ticket.Copies 
     94                            self.inkUsage *= self.filter.Ticket.Copies 
    9595                    except AttributeError : # When not run from the cupspykota backend  
    9696                        pass 
  • pykota/trunk/pykota/accounters/software.py

    r3245 r3252  
    6767                else :     
    6868                    try : 
    69                         if self.filter.InputFile is not None : 
     69                        if self.filter.Ticket.FileName is not None : 
    7070                            # when a filename is passed as an argument, the backend  
    7171                            # must generate the correct number of copies. 
    72                             jobsize *= self.filter.Copies 
     72                            jobsize *= self.filter.Ticket.Copies 
    7373                    except AttributeError : # When not run from the cupspykota backend         
    7474                        pass 
     
    128128             
    129129        pagecounter = pagecounter or 0     
    130         if self.filter.InputFile is not None : 
     130        if self.filter.Ticket.FileName is not None : 
    131131            # when a filename is passed as an argument, the backend  
    132132            # must generate the correct number of copies. 
    133             pagecounter *= self.filter.Copies 
     133            pagecounter *= self.filter.Ticket.Copies 
    134134                         
    135135        return pagecounter 
  • 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",