Changeset 3252 for pykota/trunk/pykota
- Timestamp:
- 11/03/07 11:09:17 (17 years ago)
- Location:
- pykota/trunk/pykota
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/accounters/ink.py
r3245 r3252 88 88 jobsize = len(pages) 89 89 try : 90 if self.filter. InputFile is not None :90 if self.filter.Ticket.FileName is not None : 91 91 # when a filename is passed as an argument, the backend 92 92 # must generate the correct number of copies. 93 jobsize *= self.filter. Copies94 self.inkUsage *= self.filter. Copies93 jobsize *= self.filter.Ticket.Copies 94 self.inkUsage *= self.filter.Ticket.Copies 95 95 except AttributeError : # When not run from the cupspykota backend 96 96 pass -
pykota/trunk/pykota/accounters/software.py
r3245 r3252 67 67 else : 68 68 try : 69 if self.filter. InputFile is not None :69 if self.filter.Ticket.FileName is not None : 70 70 # when a filename is passed as an argument, the backend 71 71 # must generate the correct number of copies. 72 jobsize *= self.filter. Copies72 jobsize *= self.filter.Ticket.Copies 73 73 except AttributeError : # When not run from the cupspykota backend 74 74 pass … … 128 128 129 129 pagecounter = pagecounter or 0 130 if self.filter. InputFile is not None :130 if self.filter.Ticket.FileName is not None : 131 131 # when a filename is passed as an argument, the backend 132 132 # must generate the correct number of copies. 133 pagecounter *= self.filter. Copies133 pagecounter *= self.filter.Ticket.Copies 134 134 135 135 return pagecounter -
pykota/trunk/pykota/cups.py
r3249 r3252 30 30 raise RuntimeError, "The python-pkipplib module is now mandatory. You can download pkipplib from http://www.pykota.com/" 31 31 32 class Job :32 class JobTicket : 33 33 """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) : 35 36 """Initializes a print job's information.""" 36 37 self.JobId = jobid 38 self.PrinterName = printername 37 39 self.Copies = copies 38 40 self.FileName = filename 41 self.Options = options 39 42 self.Charset = None 40 self.UserName = None 43 self.OriginatingUserName = None 44 self.OriginalUserName = None 41 45 self.Title = None 42 46 self.BillingCode = None … … 61 65 def retrieveAttributesFromCUPS(self) : 62 66 """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() 63 71 server = pkipplib.CUPS() # TODO : username and password and/or encryption 64 72 answer = server.getJobAttributes(self.JobId) … … 66 74 raise PyKotaToolError, "Network error while querying the CUPS server : %s" \ 67 75 % 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") 70 78 (dummy, self.Title) = self.getAttributeTypeAndValue(answer, "job-name") 71 79 (dummy, self.BillingCode) = self.getAttributeTypeAndValue(answer, "job-billing") … … 75 83 (dummy, self.TimeAtProcessing) = self.getAttributeTypeAndValue(answer, "time-at-processing") 76 84 (dummy, self.MimeType) = self.getAttributeTypeAndValue(answer, "document-format") 85 self.OriginalUserName = self.OriginatingUserName[:] 77 86 78 87 if __name__ == "__main__" : … … 81 90 sys.stderr.write("usage : python cups.py jobid\n") 82 91 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", 85 94 "Title", "BillingCode", "OriginatingHostName", 86 95 "TimeAtCreation", "TimeAtProcessing", "UUID",