From b3a3575ecf134aac9445570520a8c78e470f29d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 5 Apr 2018 15:21:39 +0200 Subject: [PATCH] gather: Simplify creating temporary directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no need to create the directory in work/, as it will get deleted immediately. Let's move it to /tmp and use the context manager to clean it up. Signed-off-by: Lubomír Sedlář --- pungi/phases/gather/methods/method_deps.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pungi/phases/gather/methods/method_deps.py b/pungi/phases/gather/methods/method_deps.py index f6a765a9..a7957601 100644 --- a/pungi/phases/gather/methods/method_deps.py +++ b/pungi/phases/gather/methods/method_deps.py @@ -20,7 +20,7 @@ from kobo.shortcuts import run from kobo.pkgset import SimpleRpmWrapper, RpmWrapper from kobo.rpmlib import parse_nvra -from pungi.util import rmtree, get_arch_variant_data +from pungi.util import rmtree, get_arch_variant_data, temp_dir from pungi.wrappers.pungi import PungiWrapper from pungi.arch import tree_arch_to_yum_arch, get_valid_arches @@ -179,11 +179,8 @@ def resolve_deps(compose, arch, variant, source_name=None): profiler=profiler) # Use temp working directory directory as workaround for # https://bugzilla.redhat.com/show_bug.cgi?id=795137 - tmp_dir = compose.mkdtemp(prefix="pungi_") - try: + with temp_dir(prefix='pungi_') as tmp_dir: run(cmd, logfile=pungi_log, show_cmd=True, workdir=tmp_dir, env=os.environ) - finally: - rmtree(tmp_dir) with open(pungi_log, "r") as f: packages, broken_deps, missing_comps_pkgs = pungi_wrapper.parse_log(f)