=== modified file 'lava_dispatcher/context.py'
@@ -26,6 +26,7 @@
from lava_dispatcher.config import get_device_config
from lava_dispatcher.client.targetdevice import TargetBasedClient
from lava_dispatcher.test_data import LavaTestData
+from lava_dispatcher.utils import rmtree
class LavaContext(object):
@@ -53,7 +54,7 @@
def host_result_dir(self):
if self._host_result_dir is None:
self._host_result_dir = tempfile.mkdtemp()
- atexit.register(shutil.rmtree, self._host_result_dir)
+ atexit.register(rmtree, self._host_result_dir)
return self._host_result_dir
def get_device_version(self):
=== modified file 'lava_dispatcher/device/master.py'
@@ -23,7 +23,6 @@
import contextlib
import logging
import os
-import shutil
import time
import traceback
@@ -52,6 +51,7 @@
logging_system,
mk_targz,
string_to_list,
+ rmtree,
)
from lava_dispatcher.client.lmc_utils import (
generate_image,
@@ -291,7 +291,7 @@
finally:
tf = os.path.join(self.scratch_dir, 'fs.tgz')
mk_targz(tf, tfdir)
- shutil.rmtree(tfdir)
+ rmtree(tfdir)
self.proc.sendcontrol('c') # kill SimpleHTTPServer
=== modified file 'lava_dispatcher/downloader.py'
@@ -33,6 +33,7 @@
import zlib
from tempfile import mkdtemp
+from lava_dispatcher.utils import rmtree
@contextlib.contextmanager
@@ -145,7 +146,7 @@
if not imgdir:
imgdir = mkdtemp(dir=context.config.lava_image_tmpdir)
if delete_on_exit:
- atexit.register(shutil.rmtree, imgdir)
+ atexit.register(rmtree, imgdir)
url = _url_mapping(url, context)
=== modified file 'lava_dispatcher/signals/shellhooks.py'
@@ -11,7 +11,7 @@
_result_from_dir)
from lava_dispatcher.signals import SignalHandler
from lava_dispatcher.test_data import create_attachment
-from lava_dispatcher.utils import mkdtemp
+from lava_dispatcher.utils import mkdtemp, rmtree
class ShellHooks(SignalHandler):
@@ -75,7 +75,7 @@
test_result.clear()
test_result.update(_result_from_dir(result_dir))
finally:
- shutil.rmtree(scratch_dir)
+ rmtree(scratch_dir)
for key in 'start_testcase_output', 'end_testcase_output', \
'postprocess_test_result_output':
path = case_data.get(key)
=== modified file 'lava_dispatcher/utils.py'
@@ -56,13 +56,15 @@
os.makedirs(dir)
shutil.copy(src, dest)
+def rmtree(directory):
+ subprocess.call(['rm', '-rf', directory])
def mkdtemp(basedir='/tmp'):
""" returns a temporary directory that's deleted when the process exits
"""
d = tempfile.mkdtemp(dir=basedir)
- atexit.register(shutil.rmtree, d)
+ atexit.register(rmtree, d)
os.chmod(d, 0755)
return d
@@ -111,7 +113,7 @@
The directory contents if needed.
"""
if os.path.exists(path):
- shutil.rmtree(path)
+ rmtree(path)
os.mkdir(path)