From patchwork Tue Feb 26 16:09:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stevan Radakovic X-Patchwork-Id: 15088 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 9D75023DFE for ; Tue, 26 Feb 2013 16:09:30 +0000 (UTC) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by fiordland.canonical.com (Postfix) with ESMTP id 251B7A188B6 for ; Tue, 26 Feb 2013 16:09:30 +0000 (UTC) Received: by mail-ve0-f171.google.com with SMTP id b10so3721759vea.2 for ; Tue, 26 Feb 2013 08:09:29 -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=Ojl0HBVwcD3qHh26nbGgfwUuqEu8t13C3NDoNs862Ws=; b=SoUza3HY8XN31Yi1XePYCFBAuEXb+ih0h3qZNbSU98iffvlq40KXBKNTDtP9Ipbq4Y SP4yRDFZQ0MCVl9raHR7xL+JqPETD2MBO75QzbNwsvR1quauF0v5SdBliuOCggRwAFx2 8R1Z/Srd0edhBMEFqZjUgpuXBL3tz4YHrxg5A7lUFVFfbzMiLWUZOxVCAS7UQmh9UCrN w1fB9RHLxVufJPUnzCgn8Oase8NAS1jegvZqGq7uvIbL8yaHi3PPmug4gD2N4nFpLMwW SsN2X7rjhHEGAgg8y7JA3PJDHhqyB0QjXQpzAkiYywZlD3umqvAeTPwl7shwoCKNjfy6 rPzg== X-Received: by 10.52.93.235 with SMTP id cx11mr10125087vdb.51.1361894969472; Tue, 26 Feb 2013 08:09:29 -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.58.145.101 with SMTP id st5csp121656veb; Tue, 26 Feb 2013 08:09:28 -0800 (PST) X-Received: by 10.180.79.227 with SMTP id m3mr20393605wix.12.1361894968087; Tue, 26 Feb 2013 08:09:28 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id q5si630107wic.50.2013.02.26.08.09.27 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 26 Feb 2013 08:09:28 -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 1UAN5r-0006mU-1n for ; Tue, 26 Feb 2013 16:09:27 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id F0102E058E for ; Tue, 26 Feb 2013 16:09:26 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: linaro-image-tools X-Launchpad-Branch: ~linaro-image-tools/linaro-image-tools/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 607 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 607: Fix for bug 1118544. Reviewed by milo. Message-Id: <20130226160926.25663.55698.launchpad@ackee.canonical.com> Date: Tue, 26 Feb 2013 16:09:26 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="16506"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 3010e7445eef496aedbdc04ab6f0b9c30c2dba0d X-Gm-Message-State: ALoCoQng5awnBhNerMVPDBevjXekTMlt8Nra2TQcXiBvOPPd6x14T1FaZAZswb4QpKLz2nCORDy2 Merge authors: Stevan Radaković (stevanr) Related merge proposals: https://code.launchpad.net/~stevanr/linaro-image-tools/bug1118544/+merge/150516 proposed by: Stevan Radaković (stevanr) review: Approve - Milo Casagrande (milo) ------------------------------------------------------------ revno: 607 [merge] committer: Stevan Radakovic branch nick: trunk timestamp: Tue 2013-02-26 17:05:10 +0100 message: Fix for bug 1118544. Reviewed by milo. modified: README linaro-media-create linaro_image_tools/tests/test_utils.py linaro_image_tools/utils.py --- lp:linaro-image-tools https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk You are subscribed to branch lp:linaro-image-tools. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk/+edit-subscription === modified file 'README' --- README 2013-01-07 14:21:55 +0000 +++ README 2013-02-25 19:52:53 +0000 @@ -36,6 +36,7 @@ - apt-utils - pep8 - python-mock + - python-commandnotfound (as of Ubuntu 12.10) Also consider installing pyflakes, which is optional but will enable more tests. @@ -50,7 +51,8 @@ $ sudo apt-get install testrepository python-testtools python-debian \ python-argparse dpkg-dev python-parted dbus udisks python-dbus \ - python-apt qemu-kvm util-linux apt-utils pep8 pyflakes + python-apt qemu-kvm util-linux apt-utils pep8 pyflakes \ + python-commandnotfound To initialized testsuite, run the following command: === modified file 'linaro-media-create' --- linaro-media-create 2013-01-02 14:36:38 +0000 +++ linaro-media-create 2013-02-25 18:18:09 +0000 @@ -98,8 +98,13 @@ required_commands.append('mkfs.%s' % args.rootfs) else: raise AssertionError('Unsupported rootfs type %s' % args.rootfs) + for command in required_commands: - ensure_command(command) + try: + ensure_command(command) + except UnableToFindPackageProvidingCommand: + logger.error("Could not look up command %s. Please ensure that command %s is installed." % (command, command)) + raise if __name__ == '__main__': @@ -177,7 +182,10 @@ ROOTFS_DIR = os.path.join(BIN_DIR, filesystem_dir) - ensure_required_commands(args) + try: + ensure_required_commands(args) + except UnableToFindPackageProvidingCommand: + sys.exit(1) sig_file_list = args.hwpacksigs[:] if args.binarysig is not None: === modified file 'linaro_image_tools/tests/test_utils.py' --- linaro_image_tools/tests/test_utils.py 2013-02-18 09:40:15 +0000 +++ linaro_image_tools/tests/test_utils.py 2013-02-25 18:31:26 +0000 @@ -47,6 +47,7 @@ path_in_tarfile_exists, preferred_tools_dir, prep_media_path, + try_import, verify_file_integrity, ) @@ -270,11 +271,17 @@ StringIO('Y'))) fixture = self.useFixture( MockCmdRunnerPopenFixture(self.output_string)) - install_package_providing('mkfs.vfat') - self.assertEqual( - ['apt-get -s install dosfstools', - '%s apt-get --yes install dosfstools' % sudo_args], - fixture.mock.commands_executed) + + try: + install_package_providing('mkfs.vfat') + except UnableToFindPackageProvidingCommand as inst: + self.assertEqual("CommandNotFound python module does not exist.", + inst.args[0]) + else: + self.assertEqual( + ['apt-get -s install dosfstools', + '%s apt-get --yes install dosfstools' % sudo_args], + fixture.mock.commands_executed) def test_package_installation_refused(self): self.useFixture(MockSomethingFixture(sys, @@ -286,7 +293,15 @@ 'stdin', StringIO('n'))) self.useFixture(MockCmdRunnerPopenFixture(self.output_string)) - self.assertRaises(SystemExit, install_package_providing, 'mkfs.vfat') + + CommandNotFound = try_import('CommandNotFound.CommandNotFound') + + if CommandNotFound is None: + self.assertRaises(UnableToFindPackageProvidingCommand, + install_package_providing, 'mkfs.vfat') + else: + self.assertRaises(SystemExit, install_package_providing, + 'mkfs.vfat') def test_not_found_package(self): self.assertRaises(UnableToFindPackageProvidingCommand, === modified file 'linaro_image_tools/utils.py' --- linaro_image_tools/utils.py 2013-02-18 09:40:15 +0000 +++ linaro_image_tools/utils.py 2013-02-25 18:18:09 +0000 @@ -186,7 +186,7 @@ if CommandNotFound is None: raise UnableToFindPackageProvidingCommand( - "Cannot lookup a package which provides %s" % command) + "CommandNotFound python module does not exist.") packages = CommandNotFound().getPackages(command) if len(packages) == 0: