From 4be91230948f3c79ff38533a3645cf02d335bc15 Mon Sep 17 00:00:00 2001 From: Ryan Roberts Date: Tue, 7 May 2024 15:19:07 +0100 Subject: [PATCH 1/2] utils: Squash SyntaxWarning with Python 3.12 When running with Python 3.12, the following warnings are emitted. Let's fix them. utils/config.py:240: SyntaxWarning: invalid escape sequence '\$' utils/config.py:241: SyntaxWarning: invalid escape sequence '\$' utils/config.py:242: SyntaxWarning: invalid escape sequence '\{' utils/config.py:245: SyntaxWarning: invalid escape sequence '\}' Signed-off-by: Ryan Roberts --- shrinkwrap/utils/config.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/shrinkwrap/utils/config.py b/shrinkwrap/utils/config.py index fbf6731..52246ef 100644 --- a/shrinkwrap/utils/config.py +++ b/shrinkwrap/utils/config.py @@ -237,14 +237,14 @@ def _string_tokenize(string, escape=True): 'value'. If 'type' is 'literal', 'value' is the literal string. If 'type' is 'macro', 'value' is a dict defining 'type' and 'name'. """ - regex = '\$(?:' \ - '(?P\$)|' \ - '(?:\{' \ - '(?P[_a-zA-Z][_a-zA-Z0-9]*):' \ - '(?P[_a-zA-Z][_a-zA-Z0-9]*)?' \ - '\})|' \ - '(?P)' \ - ')' + regex = r'\$(?:' \ + r'(?P\$)|' \ + r'(?:\{' \ + r'(?P[_a-zA-Z][_a-zA-Z0-9]*):' \ + r'(?P[_a-zA-Z][_a-zA-Z0-9]*)?' \ + r'\})|' \ + r'(?P)' \ + r')' pattern = re.compile(regex) tokens = [] lit_start = 0 -- GitLab From 3549013ad07ad27181b0b8c9ab338c3ddb1bbda5 Mon Sep 17 00:00:00 2001 From: Ryan Roberts Date: Tue, 7 May 2024 15:27:24 +0100 Subject: [PATCH 2/2] build: Fix output to logfile Log files are per-script fragment and are named based on the component to which they are associated. Until commit 7be0dac ("build: Split per-component artifact copy step"), there was at most, 1 script fragment associated with each component, so this all worked as intended. But that commit changed the "copy" script fragment to be per-component instead of global. This meant that there were multiple log files with the same name and the latter ones overwrote the former ones. Fix this by introducing a per-component log file number, which is appended to the log file name. It starts at 0 and increments for each script fragment that is bound to a component. Fixes: 7be0dac ("build: Split per-component artifact copy step") Signed-off-by: Ryan Roberts --- shrinkwrap/utils/graph.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/shrinkwrap/utils/graph.py b/shrinkwrap/utils/graph.py index 5ecff5e..bf843b9 100644 --- a/shrinkwrap/utils/graph.py +++ b/shrinkwrap/utils/graph.py @@ -115,20 +115,25 @@ def execute(graph, tasks, verbose=False, colorize=True): active = 0 log = logger.Logger(27) ts = graphlib.TopologicalSorter(graph) + lognum = {} def _pump(pm): nonlocal queue nonlocal active nonlocal log + nonlocal lognum while len(queue) > 0 and active < tasks: frag = queue.pop() logname = None if frag.config and frag.component: + if frag.component not in lognum: + lognum[frag.component] = 0 logname = os.path.join(workspace.build, 'log', frag.config, - f'{frag.component}.log') + f'{frag.component}{lognum[frag.component]}.log') os.makedirs(os.path.dirname(logname), exist_ok=True) + lognum[frag.component] += 1 _update_labels(labels, mask, frag.config, -- GitLab