diff options
Diffstat (limited to 'scripts/lib/scriptutils.py')
-rw-r--r-- | scripts/lib/scriptutils.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py index f92255d8dc..f23e53cba9 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 |
@@ -18,13 +17,14 @@ import sys | |||
18 | import tempfile | 17 | import tempfile |
19 | import threading | 18 | import threading |
20 | import importlib | 19 | import importlib |
21 | from importlib import machinery | 20 | import importlib.machinery |
21 | import importlib.util | ||
22 | 22 | ||
23 | class KeepAliveStreamHandler(logging.StreamHandler): | 23 | class KeepAliveStreamHandler(logging.StreamHandler): |
24 | def __init__(self, keepalive=True, **kwargs): | 24 | def __init__(self, keepalive=True, **kwargs): |
25 | super().__init__(**kwargs) | 25 | super().__init__(**kwargs) |
26 | if keepalive is True: | 26 | if keepalive is True: |
27 | keepalive = 5000 # default timeout | 27 | keepalive = 5000 # default timeout |
28 | self._timeout = threading.Condition() | 28 | self._timeout = threading.Condition() |
29 | self._stop = False | 29 | self._stop = False |
30 | 30 | ||
@@ -35,9 +35,9 @@ class KeepAliveStreamHandler(logging.StreamHandler): | |||
35 | with self._timeout: | 35 | with self._timeout: |
36 | if not self._timeout.wait(keepalive): | 36 | if not self._timeout.wait(keepalive): |
37 | self.emit(logging.LogRecord("keepalive", logging.INFO, | 37 | self.emit(logging.LogRecord("keepalive", logging.INFO, |
38 | None, None, "Keepalive message", None, None)) | 38 | None, None, "Keepalive message", None, None)) |
39 | 39 | ||
40 | self._thread = threading.Thread(target = thread, daemon = True) | 40 | self._thread = threading.Thread(target=thread, daemon=True) |
41 | self._thread.start() | 41 | self._thread.start() |
42 | 42 | ||
43 | def close(self): | 43 | def close(self): |
@@ -71,18 +71,19 @@ def logger_setup_color(logger, color='auto'): | |||
71 | 71 | ||
72 | for handler in logger.handlers: | 72 | for handler in logger.handlers: |
73 | if (isinstance(handler, logging.StreamHandler) and | 73 | if (isinstance(handler, logging.StreamHandler) and |
74 | isinstance(handler.formatter, BBLogFormatter)): | 74 | isinstance(handler.formatter, BBLogFormatter)): |
75 | if color == 'always' or (color == 'auto' and handler.stream.isatty()): | 75 | if color == 'always' or (color == 'auto' and handler.stream.isatty()): |
76 | handler.formatter.enable_color() | 76 | handler.formatter.enable_color() |
77 | 77 | ||
78 | 78 | ||
79 | def load_plugins(logger, plugins, pluginpath): | 79 | def load_plugins(logger, plugins, pluginpath): |
80 | |||
81 | def load_plugin(name): | 80 | def load_plugin(name): |
82 | logger.debug('Loading plugin %s' % name) | 81 | logger.debug('Loading plugin %s' % name) |
83 | spec = importlib.machinery.PathFinder.find_spec(name, path=[pluginpath] ) | 82 | spec = importlib.machinery.PathFinder.find_spec(name, path=[pluginpath]) |
84 | if spec: | 83 | if spec: |
85 | return spec.loader.load_module() | 84 | mod = importlib.util.module_from_spec(spec) |
85 | spec.loader.exec_module(mod) | ||
86 | return mod | ||
86 | 87 | ||
87 | def plugin_name(filename): | 88 | def plugin_name(filename): |
88 | return os.path.splitext(os.path.basename(filename))[0] | 89 | return os.path.splitext(os.path.basename(filename))[0] |
@@ -176,6 +177,7 @@ def fetch_url(tinfoil, srcuri, srcrev, destdir, logger, preserve_tmp=False, mirr | |||
176 | f.write('BB_STRICT_CHECKSUM = "ignore"\n') | 177 | f.write('BB_STRICT_CHECKSUM = "ignore"\n') |
177 | f.write('SRC_URI = "%s"\n' % srcuri) | 178 | f.write('SRC_URI = "%s"\n' % srcuri) |
178 | f.write('SRCREV = "%s"\n' % srcrev) | 179 | f.write('SRCREV = "%s"\n' % srcrev) |
180 | f.write('PV = "0.0+"\n') | ||
179 | f.write('WORKDIR = "%s"\n' % tmpworkdir) | 181 | f.write('WORKDIR = "%s"\n' % tmpworkdir) |
180 | # Set S out of the way so it doesn't get created under the workdir | 182 | # Set S out of the way so it doesn't get created under the workdir |
181 | f.write('S = "%s"\n' % os.path.join(tmpdir, 'emptysrc')) | 183 | f.write('S = "%s"\n' % os.path.join(tmpdir, 'emptysrc')) |
@@ -215,7 +217,8 @@ def fetch_url(tinfoil, srcuri, srcrev, destdir, logger, preserve_tmp=False, mirr | |||
215 | pathvars = ['T', 'RECIPE_SYSROOT', 'RECIPE_SYSROOT_NATIVE'] | 217 | pathvars = ['T', 'RECIPE_SYSROOT', 'RECIPE_SYSROOT_NATIVE'] |
216 | for pathvar in pathvars: | 218 | for pathvar in pathvars: |
217 | path = rd.getVar(pathvar) | 219 | path = rd.getVar(pathvar) |
218 | shutil.rmtree(path) | 220 | if os.path.exists(path): |
221 | shutil.rmtree(path) | ||
219 | finally: | 222 | finally: |
220 | if fetchrecipe: | 223 | if fetchrecipe: |
221 | try: | 224 | try: |
@@ -274,6 +277,6 @@ def filter_src_subdirs(pth): | |||
274 | Used by devtool and recipetool. | 277 | Used by devtool and recipetool. |
275 | """ | 278 | """ |
276 | dirlist = os.listdir(pth) | 279 | dirlist = os.listdir(pth) |
277 | filterout = ['git.indirectionsymlink', 'source-date-epoch'] | 280 | filterout = ['git.indirectionsymlink', 'source-date-epoch', 'sstate-install-recipe_qa'] |
278 | dirlist = [x for x in dirlist if x not in filterout] | 281 | dirlist = [x for x in dirlist if x not in filterout] |
279 | return dirlist | 282 | return dirlist |