63 def __checkMode(self, mode): |
63 def __checkMode(self, mode): |
64 """ |
64 """ |
65 Private method to check the mode. |
65 Private method to check the mode. |
66 |
66 |
67 This method checks, if an operation is permitted according to |
67 This method checks, if an operation is permitted according to |
68 the mode of the file. If it is not, an IOError is raised. |
68 the mode of the file. If it is not, an OSError is raised. |
69 |
69 |
70 @param mode the mode to be checked |
70 @param mode the mode to be checked |
71 @type string |
71 @type string |
72 @exception IOError raised to indicate a bad file descriptor |
72 @exception OSError raised to indicate a bad file descriptor |
73 """ |
73 """ |
74 if mode != self.mode: |
74 if mode != self.mode: |
75 raise IOError((9, '[Errno 9] Bad file descriptor')) |
75 raise OSError((9, '[Errno 9] Bad file descriptor')) |
76 |
76 |
77 def pendingWrite(self): |
77 def pendingWrite(self): |
78 """ |
78 """ |
79 Public method that returns the number of strings waiting to be written. |
79 Public method that returns the number of strings waiting to be written. |
80 |
80 |
110 buf = buf.encode('utf-8', 'backslashreplace') |
110 buf = buf.encode('utf-8', 'backslashreplace') |
111 except (UnicodeEncodeError, UnicodeDecodeError): |
111 except (UnicodeEncodeError, UnicodeDecodeError): |
112 pass |
112 pass |
113 self.sock.sendall(buf) |
113 self.sock.sendall(buf) |
114 self.nWriteErrors = 0 |
114 self.nWriteErrors = 0 |
115 except socket.error: |
115 except OSError: |
116 self.nWriteErrors += 1 |
116 self.nWriteErrors += 1 |
117 if self.nWriteErrors > self.maxtries: |
117 if self.nWriteErrors > self.maxtries: |
118 self.wpending = [] # delete all output |
118 self.wpending = [] # delete all output |
119 |
119 |
120 def isatty(self): |
120 def isatty(self): |
292 |
292 |
293 @param offset offset to move the filepointer to |
293 @param offset offset to move the filepointer to |
294 @type int |
294 @type int |
295 @param whence position the offset relates to |
295 @param whence position the offset relates to |
296 @type int |
296 @type int |
297 @exception IOError This method is not supported and always raises an |
297 @exception OSError This method is not supported and always raises an |
298 IOError. |
298 OSError. |
299 """ |
299 """ |
300 raise IOError((29, '[Errno 29] Illegal seek')) |
300 raise OSError((29, '[Errno 29] Illegal seek')) |
301 |
301 |
302 def tell(self): |
302 def tell(self): |
303 """ |
303 """ |
304 Public method to get the filepointer position. |
304 Public method to get the filepointer position. |
305 |
305 |
306 @exception IOError This method is not supported and always raises an |
306 @exception OSError This method is not supported and always raises an |
307 IOError. |
307 OSError. |
308 """ |
308 """ |
309 raise IOError((29, '[Errno 29] Illegal seek')) |
309 raise OSError((29, '[Errno 29] Illegal seek')) |
310 |
310 |
311 def truncate(self, size=-1): |
311 def truncate(self, size=-1): |
312 """ |
312 """ |
313 Public method to truncate the file. |
313 Public method to truncate the file. |
314 |
314 |
315 @param size size to truncate to |
315 @param size size to truncate to |
316 @type int |
316 @type int |
317 @exception IOError This method is not supported and always raises an |
317 @exception OSError This method is not supported and always raises an |
318 IOError. |
318 OSError. |
319 """ |
319 """ |
320 raise IOError((29, '[Errno 29] Illegal seek')) |
320 raise OSError((29, '[Errno 29] Illegal seek')) |
321 |
321 |
322 def writable(self): |
322 def writable(self): |
323 """ |
323 """ |
324 Public method to check, if a stream is writable. |
324 Public method to check, if a stream is writable. |
325 |
325 |