From patchwork Tue Dec 18 21:02:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Terceiro X-Patchwork-Id: 13646 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 6BAED23E04 for ; Tue, 18 Dec 2012 21:02:17 +0000 (UTC) Received: from mail-ie0-f169.google.com (mail-ie0-f169.google.com [209.85.223.169]) by fiordland.canonical.com (Postfix) with ESMTP id 900A7A18699 for ; Tue, 18 Dec 2012 21:02:16 +0000 (UTC) Received: by mail-ie0-f169.google.com with SMTP id c14so1649195ieb.28 for ; Tue, 18 Dec 2012 13:02:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:content-type:mime-version:x-launchpad-project :x-launchpad-branch:x-launchpad-message-rationale :x-launchpad-branch-revision-number:x-launchpad-notification-type:to :from:subject:message-id:date:reply-to:sender:errors-to:precedence :x-generated-by:x-launchpad-hash:x-gm-message-state; bh=bYUw9xFJGmiEKmJX2FMuVSDE9HnToTm0mCZPjQFWqQs=; b=Vmk6Bm6sUT5iVLLCL/Ct55/QD7CgbBlUfrTw4gpYUsxJc2lYmX9wMxrIdnLfl8HFZZ wtmb2f2semn7x8giyymWVPD8sLCFCT6FAoFBb0EKCrbW2Ux5sS4stsn++e9f4olAnOHA HAAPU5EV1+VwH5wvShoqUG0+hfnyr6WqM+4iHPRRcP3LqTg6KhTnpINhGlgkWyilu7Ze 3snMhCF7ihW8mV1pp952wLDts4dTfxCXVmV95Qq5jAI2rd92ABpt3vI8xDaJXnzYqlDm i0AhdFg6U9o9eW3t2PYkalSkFUC6cC5h2Rd6P9R86PYwHbe3FFCgK1h/x/pNTGa2fyEo RbAg== X-Received: by 10.50.170.102 with SMTP id al6mr4412500igc.70.1355864535958; Tue, 18 Dec 2012 13:02:15 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp168276igt; Tue, 18 Dec 2012 13:02:15 -0800 (PST) X-Received: by 10.180.99.1 with SMTP id em1mr6964753wib.20.1355864534432; Tue, 18 Dec 2012 13:02:14 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id gn5si16745683wib.6.2012.12.18.13.02.13 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Dec 2012 13:02:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1Tl4In-0001HP-Kn for ; Tue, 18 Dec 2012 21:02:13 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 765B4E018A for ; Tue, 18 Dec 2012 21:02:13 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dispatcher X-Launchpad-Branch: ~linaro-validation/lava-dispatcher/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 506 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 506: Replace all usage of shutil.rmtree with a shell call to `rm -rf` Message-Id: <20121218210213.14683.32686.launchpad@ackee.canonical.com> Date: Tue, 18 Dec 2012 21:02:13 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="16372"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: b62e21e9b4846767e46590969b22c4d035658586 X-Gm-Message-State: ALoCoQne5OrC+zUVvvdHKdHKCMhE2z8OZAQR/OYAI5kpUXTJjrCYZ0bXyGIweOcCbEtdzs43XiGV ------------------------------------------------------------ revno: 506 fixes bug: https://launchpad.net/bugs/1091811 committer: Antonio Terceiro branch nick: reliable-rmtree timestamp: Tue 2012-12-18 16:50:48 -0300 message: Replace all usage of shutil.rmtree with a shell call to `rm -rf` modified: lava_dispatcher/context.py lava_dispatcher/device/master.py lava_dispatcher/downloader.py lava_dispatcher/signals/shellhooks.py lava_dispatcher/utils.py --- lp:lava-dispatcher https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk You are subscribed to branch lp:lava-dispatcher. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription === modified file 'lava_dispatcher/context.py' --- lava_dispatcher/context.py 2012-10-08 22:19:31 +0000 +++ lava_dispatcher/context.py 2012-12-18 19:50:48 +0000 @@ -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' --- lava_dispatcher/device/master.py 2012-12-14 16:37:42 +0000 +++ lava_dispatcher/device/master.py 2012-12-18 19:50:48 +0000 @@ -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' --- lava_dispatcher/downloader.py 2012-11-20 21:25:42 +0000 +++ lava_dispatcher/downloader.py 2012-12-18 19:50:48 +0000 @@ -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' --- lava_dispatcher/signals/shellhooks.py 2012-12-05 00:24:13 +0000 +++ lava_dispatcher/signals/shellhooks.py 2012-12-18 19:50:48 +0000 @@ -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' --- lava_dispatcher/utils.py 2012-12-14 16:37:42 +0000 +++ lava_dispatcher/utils.py 2012-12-18 19:50:48 +0000 @@ -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)