- Timestamp:
- 06/27/07 18:48:21 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/accounters/pjl.py
r3194 r3195 78 78 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 79 79 try : 80 sock.settimeout(2.0)81 80 sock.connect((self.printerHostname, self.port)) 82 81 except socket.error, msg : … … 84 83 return False 85 84 else : 85 sock.setblocking(False) 86 86 self.sock = sock 87 87 self.closed = False … … 90 90 self.readthread = threading.Thread(target=self.readloop) 91 91 self.readthread.start() 92 time.sleep(1)93 92 self.parent.filter.logdebug("Connected to printer %s:%s" % (self.printerHostname, self.port)) 94 93 return True … … 114 113 while not self.quitEvent.isSet() : 115 114 try : 116 answer = self.sock.recv(1) 117 except socket.timeout : 118 self.parent.filter.logdebug("Timed out when reading answer from %s:%s" \ 119 % (self.printerHostname, self.port)) 115 answer = self.sock.recv(4096) 120 116 except socket.error, (err, msg) : 121 self.parent.filter.printInfo(_("Problem while receiving PJL answer from %s:%s : %s") % (self.printerHostname, self.port, str(msg)), "warn") 117 time.sleep(0.1) # We will try again later in all cases 118 if err != errno.EAGAIN : 119 self.parent.filter.printInfo(_("Problem while receiving PJL answer from %s:%s : %s") % (self.printerHostname, self.port, str(msg)), "warn") 122 120 else : 123 121 if answer : … … 133 131 """Retrieves a printer's internal page counter and status via PJL.""" 134 132 try : 135 nbsent = self.sock.send(pjlMessage) 136 if nbsent != len(pjlMessage) : 137 raise socket.error, "Short write" 133 self.sock.sendall(pjlMessage) 138 134 except socket.error, msg : 139 135 self.parent.filter.printInfo(_("Problem while sending PJL query to %s:%s : %s") % (self.printerHostname, self.port, str(msg)), "warn")