From patchwork Wed Jun 6 14:05:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Milo Casagrande X-Patchwork-Id: 9144 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 7199B23F0A for ; Wed, 6 Jun 2012 14:05:20 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 2B474A18A28 for ; Wed, 6 Jun 2012 14:05:20 +0000 (UTC) Received: by yhpp61 with SMTP id p61so5432501yhp.11 for ; Wed, 06 Jun 2012 07:05:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to: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=yZwU1xq147lp/1og4oP7DFRy77GGR78eAndDCJbqUjI=; b=WctU6lPOJ/Uhxt4dChwg2DVb6cyJvgnCYSZDmPwjmEEh+Qd3/KRqMhyDbmtHiY/XKJ SLPGU2pGQbO5LUbYkpVqm19mLMJ4IIpFuoVpUYikMnVs7pizbqQSdz8nZlIm94Sv2LiL iSJ75TgU4XO7oHaJkWSX5roL9eqUMK+Vlxw2GNkPqPE5WbCFXF4SI0MOh9GvRQI16/8E eS2FE6F79ZQj8h6dEh7+pum17MHyxIb8iT8+kALIvVbj3uYhINwDCWgRPECMSkRVkepb hBok9XRvUjZU/5Q5d54nF5XTfb8YcWRZBynHfho+SZkDtpuB/akfgSZaAEC6hXJCGOtr wXNg== Received: by 10.50.163.99 with SMTP id yh3mr6562361igb.53.1338991519329; Wed, 06 Jun 2012 07:05:19 -0700 (PDT) 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.231.24.148 with SMTP id v20csp87517ibb; Wed, 6 Jun 2012 07:05:18 -0700 (PDT) Received: by 10.204.136.195 with SMTP id s3mr12167939bkt.117.1338991516922; Wed, 06 Jun 2012 07:05:16 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id w20si2897562wew.63.2012.06.06.07.05.15 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 06 Jun 2012 07:05:16 -0700 (PDT) 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 1ScGrL-0002eN-1a for ; Wed, 06 Jun 2012 14:05:15 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 02455E0023 for ; Wed, 6 Jun 2012 14:05:15 +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: 523 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 523: Merged fixes for PEP8 conformity. Message-Id: <20120606140515.20913.52067.launchpad@ackee.canonical.com> Date: Wed, 06 Jun 2012 14:05:15 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="15353"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 03843a9fc23b2767c6c981becbaafe8facb7df39 X-Gm-Message-State: ALoCoQmptYDHBynJsOl0832pnZGFQfkzl1g0D4JkTBo3nJbXZsPb2/OGcK+15sLSMAIG67Z3xWDc Merge authors: Milo Casagrande (milo) Related merge proposals: https://code.launchpad.net/~milo/linaro-image-tools/bug727776/+merge/107724 proposed by: Milo Casagrande (milo) review: Approve - Данило Шеган (danilo) ------------------------------------------------------------ revno: 523 [merge] committer: Milo Casagrande branch nick: trunk timestamp: Wed 2012-06-06 16:02:23 +0200 message: Merged fixes for PEP8 conformity. modified: 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 'linaro_image_tools/tests/test_utils.py' --- linaro_image_tools/tests/test_utils.py 2012-05-31 04:30:32 +0000 +++ linaro_image_tools/tests/test_utils.py 2012-06-06 13:59:32 +0000 @@ -79,7 +79,7 @@ self.returncode = 0 return self - def communicate(self, input = None): + def communicate(self, input=None): self.wait() return ': OK\n'.join( TestVerifyFileIntegrity.filenames_in_shafile) + ': OK\n', '' @@ -87,13 +87,12 @@ def wait(self): return self.returncode - class MockCmdRunnerPopen_sha1sum_fail(object): def __call__(self, cmd, *args, **kwargs): self.returncode = 0 return self - def communicate(self, input = None): + def communicate(self, input=None): self.wait() return ': ERROR\n'.join( TestVerifyFileIntegrity.filenames_in_shafile) + ': ERROR\n', '' @@ -101,13 +100,12 @@ def wait(self): return self.returncode - class MockCmdRunnerPopen_wait_fails(object): def __call__(self, cmd, *args, **kwargs): self.returncode = 0 return self - def communicate(self, input = None): + def communicate(self, input=None): self.wait() return ': OK\n'.join( TestVerifyFileIntegrity.filenames_in_shafile) + ': OK\n', '' @@ -196,6 +194,7 @@ self.assertFalse(result) logging.getLogger().setLevel(logging.WARNING) + class TestEnsureCommand(TestCaseWithFixtures): install_pkg_providing_called = False @@ -238,7 +237,7 @@ if prefer_dir is None: expected, _ = cmd_runner.run( ['which', lmc, ], - stdout = subprocess.PIPE).communicate() + stdout=subprocess.PIPE).communicate() expected = expected.strip() else: expected = os.path.join(prefer_dir, lmc) @@ -279,14 +278,14 @@ self.useFixture(MockSomethingFixture(os, "makedirs", lambda x: x)) self.assertEqual("testdevice", - prep_media_path(Args(directory = None, - device = "testdevice", - board = "testboard"))) + prep_media_path(Args(directory=None, + device="testdevice", + board="testboard"))) self.assertEqual("/foo/bar/testdevice", - prep_media_path(Args(directory = "/foo/bar", - device = "testdevice", - board = "testboard"))) + prep_media_path(Args(directory="/foo/bar", + device="testdevice", + board="testboard"))) class TestPrepMediaPath(TestCaseWithFixtures): @@ -296,15 +295,15 @@ self.useFixture(MockSomethingFixture(os, "makedirs", lambda x: x)) self.assertRaises(IncompatibleOptions, additional_option_checks, - Args(directory = "/foo/bar", - device = "/testdevice", - board = "testboard")) + Args(directory="/foo/bar", + device="/testdevice", + board="testboard")) sys.argv.append("--mmc") self.assertRaises(IncompatibleOptions, additional_option_checks, - Args(directory = "/foo/bar", - device = "testdevice", - board = "testboard")) + Args(directory="/foo/bar", + device="testdevice", + board="testboard")) sys.argv.remove("--mmc") @@ -321,11 +320,10 @@ try: tmpdir = tempfile.mkdtemp() self.assertRaises(InvalidHwpackFile, additional_option_checks, - HwPackArgs(hwpack = tmpdir)) + HwPackArgs(hwpack=tmpdir)) finally: os.rmdir(tmpdir) - def test_hwpacks_are_files(self): """ === modified file 'linaro_image_tools/utils.py' --- linaro_image_tools/utils.py 2012-05-31 04:30:32 +0000 +++ linaro_image_tools/utils.py 2012-06-06 13:59:32 +0000 @@ -43,8 +43,8 @@ ``os.path.join``. :param alternative: The value to return if no module can be imported. Defaults to None. - :param error_callback: If non-None, a callable that is passed the ImportError - when the module cannot be loaded. + :param error_callback: If non-None, a callable that is passed the + ImportError when the module cannot be loaded. """ module_segments = name.split('.') last_error = None @@ -84,6 +84,7 @@ return False tarinfo.close() + def verify_file_integrity(sig_file_list): """Verify a list of signature files. @@ -104,8 +105,8 @@ tmp = tempfile.NamedTemporaryFile() try: - cmd_runner.run(['gpg', '--status-file={0}'.format(tmp.name), - '--verify', sig_file]).wait() + cmd_runner.run(['gpg', '--status-file={0}'.format(tmp.name), + '--verify', sig_file]).wait() except cmd_runner.SubcommandNonZeroReturnValue: gpg_sig_ok = False gpg_out = gpg_out + tmp.read() @@ -134,6 +135,7 @@ return verified_files, gpg_sig_ok, gpg_out + def check_file_integrity_and_log_errors(sig_file_list, binary, hwpacks): """ Wrapper around verify_file_integrity that prints error messages to stderr @@ -163,6 +165,7 @@ return True, verified_files + def install_package_providing(command): """Install a package which provides the given command. @@ -196,6 +199,7 @@ except cmd_runner.SubcommandNonZeroReturnValue: return False + def ensure_command(command): """Ensure the given command is available. @@ -204,6 +208,7 @@ if not has_command(command): install_package_providing(command) + def find_command(name, prefer_dir=None): """Finds a linaro-image-tools command. @@ -218,7 +223,7 @@ # default to searching in current directory when running from a bzr # checkout - dirs = [os.getcwd(),] + dirs = [os.getcwd(), ] if os.path.isabs(__file__): dirs = os.environ["PATH"].split(os.pathsep) # empty dir in PATH means current directory @@ -253,7 +258,8 @@ try: os.makedirs(loc) except OSError: - pass # Directory exists. + # Directory exists. + pass path = os.path.join(loc, args.device) else: @@ -277,6 +283,7 @@ def __str__(self): return repr(self.value) + def additional_option_checks(args): if args.directory is not None: # If args.device is a path to a device (/dev/) then this is an error @@ -294,4 +301,3 @@ if not os.path.isfile(hwpack): raise InvalidHwpackFile( "--hwpack argument (%s) is not a regular file" % hwpack) -