From patchwork Wed Feb 13 11:30:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Milo Casagrande X-Patchwork-Id: 14778 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 61CCC23FD3 for ; Wed, 13 Feb 2013 11:30:31 +0000 (UTC) Received: from mail-vb0-f42.google.com (mail-vb0-f42.google.com [209.85.212.42]) by fiordland.canonical.com (Postfix) with ESMTP id E7187A1901A for ; Wed, 13 Feb 2013 11:30:30 +0000 (UTC) Received: by mail-vb0-f42.google.com with SMTP id ff1so698317vbb.29 for ; Wed, 13 Feb 2013 03:30:30 -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=AyQtX4RayKSiLLSCld8loFPEo4L+Z5oLpcUxicSSI+k=; b=Go5c7fXDFlqvnEDrGamz9W/T+kA4gVrXneZyTAf527lkTIcg/Qy71pHtrTeYxB7JUa DzXGAceGXkgy3FBDDCnBl7asw84xAkuGU3m5soSj8bJ1VFjKNSRQOYD9Fp6DybCOAgjV O4hBSP0Euh+Fo1Hr8mEDpGx4xRGTVIPT77sBcU0ukj2oQMjky9+n7SPfwTMavo5n0EPG E7qAIMmubihcxp1urK+6xMtDcBrinJprRwKFCdFsbHPpZJUHmar1HD14y9ipuVCmAibt RLaiPlxBgdrdtgs6dDnAVh9/6iDr2P+KWPOjLo7wQx632+ivUaVkSnAaDct8rxq5vzWb jJUQ== X-Received: by 10.52.98.5 with SMTP id ee5mr24493329vdb.102.1360755030279; Wed, 13 Feb 2013 03:30:30 -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.221.4.5 with SMTP id oa5csp189461vcb; Wed, 13 Feb 2013 03:30:21 -0800 (PST) X-Received: by 10.180.77.68 with SMTP id q4mr9333911wiw.10.1360755021377; Wed, 13 Feb 2013 03:30:21 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id hp9si8646982wib.111.2013.02.13.03.30.20 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 13 Feb 2013 03:30:21 -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 1U5aXc-0001oA-QG for ; Wed, 13 Feb 2013 11:30:20 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id B48A4E0421 for ; Wed, 13 Feb 2013 11:30:20 +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: 604 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 604: Fixed default bootloader warning shown even if bootloader is specified. Message-Id: <20130213113020.15145.7536.launchpad@ackee.canonical.com> Date: Wed, 13 Feb 2013 11:30:20 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="16491"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 38bed7057151be23145e545feb598ce8eb51e3f7 X-Gm-Message-State: ALoCoQl1dMsuCTIPfGG1ozQ7HyY6ZQUMQQsIMPMnMUgn/Q/RMVtxyX7a8rXZOWdInY+6mm4MzBZf Merge authors: Milo Casagrande (milo) Related merge proposals: https://code.launchpad.net/~milo/linaro-image-tools/bug1073973/+merge/143142 proposed by: Milo Casagrande (milo) review: Approve - Stevan Radaković (stevanr) ------------------------------------------------------------ revno: 604 [merge] committer: Milo Casagrande branch nick: trunk timestamp: Wed 2013-02-13 12:29:56 +0100 message: Fixed default bootloader warning shown even if bootloader is specified. modified: linaro_image_tools/hwpack/builder.py linaro_image_tools/hwpack/config.py linaro_image_tools/hwpack/handler.py linaro_image_tools/hwpack/tests/test_config_v3.py linaro_image_tools/hwpack/tests/test_script.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/hwpack/builder.py' --- linaro_image_tools/hwpack/builder.py 2012-10-18 13:09:21 +0000 +++ linaro_image_tools/hwpack/builder.py 2013-01-10 13:17:57 +0000 @@ -185,16 +185,16 @@ """Call function for each board + bootloader combination in metadata""" if self.config.bootloaders is not None: for bootloader in self.config.bootloaders: - self.config.set_board(None) - self.config.set_bootloader(bootloader) + self.config.board = None + self.config.bootloader = bootloader function() if self.config.boards is not None: for board in self.config.boards: if self.config.bootloaders is not None: for bootloader in self.config.bootloaders: - self.config.set_board(board) - self.config.set_bootloader(bootloader) + self.config.board = board + self.config.bootloader = bootloader function() def extract_files(self): === modified file 'linaro_image_tools/hwpack/config.py' --- linaro_image_tools/hwpack/config.py 2013-01-03 10:40:12 +0000 +++ linaro_image_tools/hwpack/config.py 2013-01-14 16:26:56 +0000 @@ -160,7 +160,8 @@ # self.allow_unset_bootloader allows for both modes of operation. self.logger = logging.getLogger('linaro_image_tools') self.allow_unset_bootloader = allow_unset_bootloader - self.bootloader = None + self.board = board + self._bootloader = bootloader obfuscated_e = None obfuscated_yaml_e = "" @@ -183,10 +184,6 @@ else: # If YAML parsed OK, we don't have an error. obfuscated_e = None - if board: - self.set_board(board) - if bootloader: - self.set_bootloader(bootloader) if obfuscated_e: # If INI parsing from ConfigParser or YAML parsing failed, @@ -198,12 +195,12 @@ obfuscated_yaml_e) raise ConfigParser.Error(msg) - def set_bootloader(self, bootloader): - """Set bootloader used to look up configuration in bootloader section. + def _get_bootloader(self): + """Returns the bootloader associated with this config. If bootloader is None / empty and there is only one bootloader - available, use that. - """ + available, use that.""" + bootloader = self._bootloader if not bootloader: # Auto-detect bootloader. If there is a single bootloader specified # then use it, else, error. @@ -227,12 +224,17 @@ 'found. Will try to use \'%s\'. ' 'instead.' % (DEFAULT_BOOTLOADER, bootloader)) - - self.bootloader = bootloader - - def set_board(self, board): - """Set board used to look up per-board configuration""" - self.board = board + # bootloader is None: since we are here, set it so we do not + # have to go through all the config retrieval again. + self._bootloader = bootloader + return bootloader + + def _set_bootloader(self, value): + """Set bootloader used to look up configuration in bootloader section. + """ + self._bootloader = value + + bootloader = property(_get_bootloader, _set_bootloader) def get_bootloader_list(self): if isinstance(self.bootloaders, dict): @@ -272,7 +274,7 @@ # Check config for all bootloaders if one isn't specified. if not self.bootloader and self._is_v3: for bootloader in self.get_bootloader_list(): - self.set_bootloader(bootloader) + self.bootloader = bootloader self.validate_bootloader_fields() else: self.validate_bootloader_fields() === modified file 'linaro_image_tools/hwpack/handler.py' --- linaro_image_tools/hwpack/handler.py 2012-12-07 09:37:42 +0000 +++ linaro_image_tools/hwpack/handler.py 2013-01-10 13:17:57 +0000 @@ -105,8 +105,8 @@ # Probably V2 hardware pack without [hwpack] on the first line lines = ["[hwpack]\n"] + lines self.config = Config(StringIO("".join(lines))) - self.config.set_board(self.board) - self.config.set_bootloader(self.bootloader) + self.config.board = self.board + self.config.bootloader = self.bootloader return self.config def get_field(self, field, return_keys=False): === modified file 'linaro_image_tools/hwpack/tests/test_config_v3.py' --- linaro_image_tools/hwpack/tests/test_config_v3.py 2013-01-03 10:40:12 +0000 +++ linaro_image_tools/hwpack/tests/test_config_v3.py 2013-01-10 13:17:57 +0000 @@ -245,7 +245,7 @@ "bootloaders:\n" " u_boot:\n" " spl_package: ~~\n") - config.set_board("panda") + config.board = "panda" self.assertValidationError( "Invalid value in spl_package in the metadata: ~~", config._validate_spl_package) @@ -257,7 +257,7 @@ " bootloaders:\n" " u_boot:\n" " spl_file: ~~\n") - config.set_board("panda") + config.board = "panda" self.assertValidationError("Invalid path: ~~", config._validate_spl_file) @@ -297,8 +297,8 @@ " u_boot:\n" " in_boot_part: Yes\n") - config.set_bootloader("u_boot") - config.set_board("panda") + config.bootloader = "u_boot" + config.board = "panda" config._validate_bootloader_file_in_boot_part() self.assertEqual(config.bootloader_file_in_boot_part, "yes") @@ -315,8 +315,8 @@ " u_boot:\n" " in_boot_part: Yes\n") - config.set_bootloader("u_boot") - config.set_board("panda") + config.bootloader = "u_boot" + config.board = "panda" config._validate_bootloader_file_in_boot_part() self.assertEqual(config.bootloader_file_in_boot_part, "yes") @@ -330,11 +330,11 @@ " anotherboot:\n" " in_boot_part: Yes\n") - config.set_bootloader("u_boot") + config.bootloader = "u_boot" config._validate_bootloader_file_in_boot_part() self.assertEqual(config.bootloader_file_in_boot_part, "no") - config.set_bootloader("anotherboot") + config.bootloader = "anotherboot" config._validate_bootloader_file_in_boot_part() self.assertEqual(config.bootloader_file_in_boot_part, "yes") === modified file 'linaro_image_tools/hwpack/tests/test_script.py' --- linaro_image_tools/hwpack/tests/test_script.py 2012-08-29 15:01:41 +0000 +++ linaro_image_tools/hwpack/tests/test_script.py 2013-01-10 13:17:57 +0000 @@ -168,7 +168,7 @@ # We now need a real config object to test against the configuration # in the hardware pack we have created. config = Config(StringIO(config_v3)) - config.set_bootloader("u_boot") + config.bootloader = "u_boot" metadata = Metadata.from_config(config, "1.0", "armel") self.assertThat( "hwpack_ahwpack_1.0_armel.tar.gz",