diff options
Diffstat (limited to 'scripts/lib/scriptutils.py')
| -rw-r--r-- | scripts/lib/scriptutils.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py index adf81476f0..f7c1bd9e4e 100644 --- a/scripts/lib/scriptutils.py +++ b/scripts/lib/scriptutils.py | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | # SPDX-License-Identifier: GPL-2.0-only | 5 | # SPDX-License-Identifier: GPL-2.0-only |
| 6 | # | 6 | # |
| 7 | 7 | ||
| 8 | import argparse | ||
| 9 | import glob | 8 | import glob |
| 10 | import logging | 9 | import logging |
| 11 | import os | 10 | import os |
| @@ -25,7 +24,7 @@ class KeepAliveStreamHandler(logging.StreamHandler): | |||
| 25 | def __init__(self, keepalive=True, **kwargs): | 24 | def __init__(self, keepalive=True, **kwargs): |
| 26 | super().__init__(**kwargs) | 25 | super().__init__(**kwargs) |
| 27 | if keepalive is True: | 26 | if keepalive is True: |
| 28 | keepalive = 5000 # default timeout | 27 | keepalive = 5000 # default timeout |
| 29 | self._timeout = threading.Condition() | 28 | self._timeout = threading.Condition() |
| 30 | self._stop = False | 29 | self._stop = False |
| 31 | 30 | ||
| @@ -36,9 +35,9 @@ class KeepAliveStreamHandler(logging.StreamHandler): | |||
| 36 | with self._timeout: | 35 | with self._timeout: |
| 37 | if not self._timeout.wait(keepalive): | 36 | if not self._timeout.wait(keepalive): |
| 38 | self.emit(logging.LogRecord("keepalive", logging.INFO, | 37 | self.emit(logging.LogRecord("keepalive", logging.INFO, |
| 39 | None, None, "Keepalive message", None, None)) | 38 | None, None, "Keepalive message", None, None)) |
| 40 | 39 | ||
| 41 | self._thread = threading.Thread(target = thread, daemon = True) | 40 | self._thread = threading.Thread(target=thread, daemon=True) |
| 42 | self._thread.start() | 41 | self._thread.start() |
| 43 | 42 | ||
| 44 | def close(self): | 43 | def close(self): |
| @@ -72,16 +71,15 @@ def logger_setup_color(logger, color='auto'): | |||
| 72 | 71 | ||
| 73 | for handler in logger.handlers: | 72 | for handler in logger.handlers: |
| 74 | if (isinstance(handler, logging.StreamHandler) and | 73 | if (isinstance(handler, logging.StreamHandler) and |
| 75 | isinstance(handler.formatter, BBLogFormatter)): | 74 | isinstance(handler.formatter, BBLogFormatter)): |
| 76 | if color == 'always' or (color == 'auto' and handler.stream.isatty()): | 75 | if color == 'always' or (color == 'auto' and handler.stream.isatty()): |
| 77 | handler.formatter.enable_color() | 76 | handler.formatter.enable_color() |
| 78 | 77 | ||
| 79 | 78 | ||
| 80 | def load_plugins(logger, plugins, pluginpath): | 79 | def load_plugins(logger, plugins, pluginpath): |
| 81 | |||
| 82 | def load_plugin(name): | 80 | def load_plugin(name): |
| 83 | logger.debug('Loading plugin %s' % name) | 81 | logger.debug('Loading plugin %s' % name) |
| 84 | spec = importlib.machinery.PathFinder.find_spec(name, path=[pluginpath] ) | 82 | spec = importlib.machinery.PathFinder.find_spec(name, path=[pluginpath]) |
| 85 | if spec: | 83 | if spec: |
| 86 | mod = importlib.util.module_from_spec(spec) | 84 | mod = importlib.util.module_from_spec(spec) |
| 87 | spec.loader.exec_module(mod) | 85 | spec.loader.exec_module(mod) |
