stage: use exist stack in the run method
Simplify context management in the `Stage.run` method by using an `ExitStack` instead of a multiline `with` statement.
This commit is contained in:
parent
79d9066861
commit
93010c7e16
1 changed files with 8 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
import contextlib
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
|
|
@ -56,8 +56,13 @@ class Stage:
|
|||
|
||||
def run(self, tree, runner, build_tree, store, monitor, libdir):
|
||||
var = store.store
|
||||
with buildroot.BuildRoot(build_tree, runner, libdir, var) as build_root, \
|
||||
tempfile.TemporaryDirectory(prefix="osbuild-sources-output-", dir=var) as sources_output:
|
||||
with contextlib.ExitStack() as cm:
|
||||
|
||||
build_root = buildroot.BuildRoot(build_tree, runner, libdir, var)
|
||||
cm.enter_context(build_root)
|
||||
|
||||
sources_tmp = tempfile.TemporaryDirectory(prefix="osbuild-sources-output-", dir=var)
|
||||
sources_output = cm.enter_context(sources_tmp)
|
||||
|
||||
args = {
|
||||
"tree": "/run/osbuild/tree",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue