|
| 1 | +#!/usr/bin/env python3 |
1 | 2 | from abc import ABC, abstractmethod |
2 | 3 | from collections import defaultdict |
3 | 4 | from contextlib import closing |
@@ -228,7 +229,7 @@ class Notifier(ABC): |
228 | 229 | * server_uri: URL of the notification endpoint |
229 | 230 | """ |
230 | 231 | @abstractmethod |
231 | | - def discover_server_uri(self): |
| 232 | + def discover_server_uri(self, resp_content=None, resp_headers=None): |
232 | 233 | """ |
233 | 234 | Sets .server_uri if a notification endpoint is found for target_url. |
234 | 235 | Must be called before calling send(). |
@@ -379,37 +380,4 @@ def cli(html_filepath): |
379 | 380 | cache.dump_to_json() |
380 | 381 |
|
381 | 382 | if __name__ == '__main__': |
382 | | - try: # Optional logs coloring: |
383 | | - from colorama import Back, Fore, Style |
384 | | - # Recipe from: https://chezsoi.org/lucas/blog/colored-logs-in-python.html |
385 | | - class ColorLogsWrapper: |
386 | | - COLOR_MAP = { |
387 | | - 'debug': Fore.CYAN, |
388 | | - 'info': Fore.GREEN, |
389 | | - 'warning': Fore.YELLOW, |
390 | | - 'error': Fore.RED, |
391 | | - 'critical': Back.RED, |
392 | | - } |
393 | | - def __init__(self, logger): |
394 | | - self.logger = logger |
395 | | - def __getattr__(self, attr_name): |
396 | | - if attr_name == 'warn': |
397 | | - attr_name = 'warning' |
398 | | - if attr_name not in 'debug info warning error critical': |
399 | | - return getattr(self.logger, attr_name) |
400 | | - log_level = getattr(logging, attr_name.upper()) |
401 | | - # mimicking logging/__init__.py behaviour |
402 | | - if not self.logger.isEnabledFor(log_level): |
403 | | - return None |
404 | | - def wrapped_attr(msg, *args, **kwargs): |
405 | | - style_prefix = self.COLOR_MAP[attr_name] |
406 | | - msg = style_prefix + msg + Style.RESET_ALL |
407 | | - # We call _.log directly to not increase the callstack |
408 | | - # so that Logger.findCaller extract the corrects filename/lineno |
409 | | - # pylint: disable=protected-access |
410 | | - return self.logger._log(log_level, msg, args, **kwargs) |
411 | | - return wrapped_attr |
412 | | - LOGGER = ColorLogsWrapper(LOGGER) |
413 | | - except ImportError: |
414 | | - print("colorama not available - Logs coloring disabled") |
415 | 383 | cli(sys.argv[1]) |
0 commit comments