(self, value, status=CONTENT_STATUS.IN_PROGRESS, content_type=None)
| 232 | sys.stderr = self |
| 233 | |
| 234 | def write(self, value, status=CONTENT_STATUS.IN_PROGRESS, content_type=None): |
| 235 | if self.messagetype == "stdout": |
| 236 | if content_type is None: |
| 237 | if kb.partRun is not None: |
| 238 | content_type = PART_RUN_CONTENT_TYPES.get(kb.partRun) |
| 239 | else: |
| 240 | # Ignore all non-relevant messages |
| 241 | return |
| 242 | |
| 243 | output = conf.databaseCursor.execute("SELECT id, status, value FROM data WHERE taskid = ? AND content_type = ?", (self.taskid, content_type)) |
| 244 | |
| 245 | # Delete partial output from IPC database if we have got a complete output |
| 246 | if status == CONTENT_STATUS.COMPLETE: |
| 247 | if len(output) > 0: |
| 248 | for index in xrange(len(output)): |
| 249 | conf.databaseCursor.execute("DELETE FROM data WHERE id = ?", (output[index][0],)) |
| 250 | |
| 251 | conf.databaseCursor.execute("INSERT INTO data VALUES(NULL, ?, ?, ?, ?)", (self.taskid, status, content_type, jsonize(value))) |
| 252 | if kb.partRun: |
| 253 | kb.partRun = None |
| 254 | |
| 255 | elif status == CONTENT_STATUS.IN_PROGRESS: |
| 256 | if len(output) == 0: |
| 257 | conf.databaseCursor.execute("INSERT INTO data VALUES(NULL, ?, ?, ?, ?)", (self.taskid, status, content_type, jsonize(value))) |
| 258 | else: |
| 259 | new_value = "%s%s" % (dejsonize(output[0][2]), value) |
| 260 | conf.databaseCursor.execute("UPDATE data SET value = ? WHERE id = ?", (jsonize(new_value), output[0][0])) |
| 261 | else: |
| 262 | conf.databaseCursor.execute("INSERT INTO errors VALUES(NULL, ?, ?)", (self.taskid, str(value) if value else "")) |
| 263 | |
| 264 | def flush(self): |
| 265 | pass |
no test coverage detected