| 141 | return None |
| 142 | |
| 143 | def poll(self): |
| 144 | if not self.started: |
| 145 | s = self.statFile() |
| 146 | if s == self.old_logfile_stats: |
| 147 | return # not started yet |
| 148 | if not s: |
| 149 | # the file was there, but now it's deleted. Forget about the |
| 150 | # initial state, clearly the process has deleted the logfile |
| 151 | # in preparation for creating a new one. |
| 152 | self.old_logfile_stats = None |
| 153 | return # no file to work with |
| 154 | self.f = open(self.logfile, "rb") |
| 155 | # if we only want new lines, seek to |
| 156 | # where we stat'd so we only find new |
| 157 | # lines |
| 158 | if self.follow: |
| 159 | self.f.seek(s[2], 0) |
| 160 | self.started = True |
| 161 | |
| 162 | # Mac OS X and Linux differ in behaviour when reading from a file that has previously |
| 163 | # reached EOF. On Linux, any new data that has been appended to the file will be returned. |
| 164 | # On Mac OS X, the empty string will always be returned. Seeking to the current position |
| 165 | # in the file resets the EOF flag on Mac OS X and will allow future reads to work as |
| 166 | # intended. |
| 167 | self.f.seek(self.f.tell(), 0) |
| 168 | |
| 169 | while True: |
| 170 | data = self.f.read(10000) |
| 171 | if not data: |
| 172 | return |
| 173 | decodedData = self.logDecode.decode(data) |
| 174 | self.command.addLogfile(self.name, decodedData) |
| 175 | |
| 176 | |
| 177 | if runtime.platformType == 'posix': |