summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-07-09 15:59:23 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-07-09 16:10:05 +0900
commit8c06300651065ed38912557304b4a49870b12f8a (patch)
treeb3be4bb27253602895fe651238c515e2c78c0f46
parente5b21704e9ed68f29590f428ca70b7c97ae7925a (diff)
downloadbuildstream-8c06300651065ed38912557304b4a49870b12f8a.tar.gz
source.py: Use the new utils._tempdir() utility to implement Source.tempdir()
-rw-r--r--buildstream/source.py13
1 files changed, 2 insertions, 11 deletions
diff --git a/buildstream/source.py b/buildstream/source.py
index fe03f29ed..0c546213a 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -19,11 +19,10 @@
# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
import os
-import tempfile
import shutil
from contextlib import contextmanager
-from . import _yaml, _signals
+from . import _yaml, _signals, utils
from . import ImplError
from . import Plugin
@@ -96,17 +95,9 @@ class Source(Plugin):
directory in the case of forced termination.
"""
mirrordir = self.get_mirror_directory()
- tempdir = tempfile.mkdtemp(dir=mirrordir)
-
- def cleanup_tempdir():
- if os.path.isdir(tempdir):
- shutil.rmtree(tempdir)
-
- with _signals.terminator(cleanup_tempdir):
+ with utils._tempdir(dir=mirrordir) as tempdir:
yield tempdir
- cleanup_tempdir()
-
def get_consistency(self):
"""Report whether the source has a resolved reference