(self)
| 471 | logger.info("{}".format(report_address)) |
| 472 | |
| 473 | def broadcast_report(self): |
| 474 | |
| 475 | logger.info(colored_print("Preparing to broacast reports...", |
| 476 | "green_bold")) |
| 477 | |
| 478 | report_hash = self._get_report_id() |
| 479 | |
| 480 | # When in watch mode, |
| 481 | if self.watch: |
| 482 | logger.info(colored_print("\tFetching pipeline run status", |
| 483 | "green_bold")) |
| 484 | self._update_pipeline_status() |
| 485 | logger.info(colored_print( |
| 486 | "\tSending initial request to test service", "green_bold")) |
| 487 | self._init_live_reports(report_hash) |
| 488 | logger.info(colored_print("\tInitial parsing of trace file", |
| 489 | "green_bold")) |
| 490 | self.update_trace_watch() |
| 491 | |
| 492 | self._print_msg(report_hash) |
| 493 | |
| 494 | logger.debug("Establishing connection...") |
| 495 | |
| 496 | stay_alive = True |
| 497 | _broadcast_sent = False |
| 498 | try: |
| 499 | while stay_alive: |
| 500 | |
| 501 | # When not in watch mode, send the report JSON once |
| 502 | if not _broadcast_sent and not self.watch: |
| 503 | self._send_report(report_hash) |
| 504 | self._print_msg(report_hash) |
| 505 | _broadcast_sent = True |
| 506 | |
| 507 | # When in watch mode, continuously monitor the trace file for |
| 508 | # updates |
| 509 | if self.watch: |
| 510 | self.update_trace_watch() |
| 511 | self.update_log_watch() |
| 512 | # When new report JSON files are available, send then |
| 513 | # via a PUT request |
| 514 | if self.send: |
| 515 | self._send_live_report(report_hash) |
| 516 | self.send = False |
| 517 | |
| 518 | sleep(self.refresh_rate) |
| 519 | |
| 520 | except FileNotFoundError as e: |
| 521 | print(e) |
| 522 | logger.error(colored_print( |
| 523 | "ERROR: Report JSON file is not reachable!", "red_bold")) |
| 524 | except Exception as e: |
| 525 | logger.exception("ERROR: " + e) |
| 526 | finally: |
| 527 | logger.info("Closing connection") |
| 528 | self._close_connection(report_hash) |
no test coverage detected