Reports alerts :return: the list of alerts.
(self)
| 76 | print("The alert thread is already stopped") |
| 77 | |
| 78 | def _get_alerts(self) -> list[str]: |
| 79 | """Reports alerts |
| 80 | :return: the list of alerts. |
| 81 | """ |
| 82 | cur_time = time.monotonic() |
| 83 | if cur_time < self._next_alert_time: |
| 84 | return [] |
| 85 | |
| 86 | alerts = [] |
| 87 | |
| 88 | if self._alert_count < len(ALERTS): |
| 89 | alerts.append(ALERTS[self._alert_count]) |
| 90 | self._alert_count += 1 |
| 91 | self._next_alert_time = cur_time + 4 |
| 92 | |
| 93 | else: |
| 94 | rand_num = random.randint(1, 20) |
| 95 | if rand_num > 2: |
| 96 | return [] |
| 97 | |
| 98 | for _ in range(rand_num): |
| 99 | self._alert_count += 1 |
| 100 | alerts.append(f"Alert {self._alert_count}") |
| 101 | |
| 102 | self._next_alert_time = 0 |
| 103 | |
| 104 | return alerts |
| 105 | |
| 106 | def _build_alert_str(self) -> str: |
| 107 | """Combines alerts into one string that can be printed to the terminal |
no test coverage detected