From patchwork Wed Jan 9 09:49:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milo Casagrande X-Patchwork-Id: 13943 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 4D61523E02 for ; Wed, 9 Jan 2013 09:49:17 +0000 (UTC) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by fiordland.canonical.com (Postfix) with ESMTP id C379BA1889E for ; Wed, 9 Jan 2013 09:49:16 +0000 (UTC) Received: by mail-vc0-f171.google.com with SMTP id n11so1328154vch.16 for ; Wed, 09 Jan 2013 01:49: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=+2lraHmqRl5+V4QlvoJ35/46ygRqvPRQ6uNJAi1mGiA=; b=lSStUyw9ZlMzTvbHvOgz7sF/MRMp52cGox01qCQ/UNJLsjo2jy81isIrXBSJkPahto AJdQKP+fYAywKGxJT5SkOWmnDPJ9EkolJWtyVG4nLilM8+juy6K4pFrdhuoWUAGbLhW6 /4rekkjq2f+fraxVXtWmdM0QyV6jTBkVSooYtpmbcSER1Z98IoxueRhk4EdNsRk7YgD7 U2FJRXjCpUCkLZAzvwJRrgvqX9veNB9Ami3vQcVaULk5DxhTxL+8l9zUaAnjnDco1xTH 6YRbOJLnwL8KZFAsgVpqOpTPWKfW114q62IeprTOLyaWqjUMlIu2FCw1Qi+XGKd7YjBR qN6A== X-Received: by 10.58.247.132 with SMTP id ye4mr91887664vec.9.1357724956290; Wed, 09 Jan 2013 01:49:16 -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 st5csp5328veb; Wed, 9 Jan 2013 01:49:15 -0800 (PST) X-Received: by 10.180.84.131 with SMTP id z3mr2135529wiy.25.1357724954720; Wed, 09 Jan 2013 01:49:14 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id gd7si4694374wjb.35.2013.01.09.01.49.14 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 09 Jan 2013 01:49: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 1TssHa-0005Cb-3q for ; Wed, 09 Jan 2013 09:49:14 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 0CAEFE03F3 for ; Wed, 9 Jan 2013 09:49:14 +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: 599 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 599: Fixed regression: missing check on None string. Message-Id: <20130109094914.20121.27599.launchpad@ackee.canonical.com> Date: Wed, 09 Jan 2013 09:49:14 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="16412"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: b938667163c5f445be85b608842cf4fb4c8ea361 X-Gm-Message-State: ALoCoQlT66PU+7y20Dq2sp8DxnRGeHqDRmq93cS/go8GgEIbqcPrXZPCjtDqm0ywqit+Sh0+RdxG Merge authors: Milo Casagrande (milo) Related merge proposals: https://code.launchpad.net/~milo/linaro-image-tools/regression-fix/+merge/142460 proposed by: Milo Casagrande (milo) review: Approve - Fathi Boudra (fboudra) ------------------------------------------------------------ revno: 599 [merge] committer: Milo Casagrande branch nick: trunk timestamp: Wed 2013-01-09 10:48:18 +0100 message: Fixed regression: missing check on None string. modified: linaro_image_tools/media_create/boards.py linaro_image_tools/media_create/tests/test_media_create.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/media_create/boards.py' --- linaro_image_tools/media_create/boards.py 2013-01-07 12:40:41 +0000 +++ linaro_image_tools/media_create/boards.py 2013-01-09 09:22:50 +0000 @@ -212,10 +212,13 @@ # XXX: can be removed when killing v1 hwpack. def _get_live_serial_options(self): - return_value = self._live_serial_options - if self._check_placeholder_presence(return_value, r'%s'): - return_value = self._live_serial_options % self.serial_tty - return return_value + live_serial = self._live_serial_options + if live_serial: + if isinstance(live_serial, list): + live_serial = ' '.join(live_serial) + if self._check_placeholder_presence(live_serial, r'%s'): + live_serial = live_serial % self.serial_tty + return live_serial def _set_live_serial_options(self, value): self._live_serial_options = value @@ -225,16 +228,19 @@ # XXX: can be removed when killing v1 hwpack. def _get_extra_serial_options(self): - return_value = self._extra_serial_options - if self._check_placeholder_presence(return_value, r'%s'): - return_value = return_value % self.serial_tty - return return_value + extra_serial = self._extra_serial_options + if extra_serial: + if isinstance(extra_serial, list): + extra_serial = ' '.join(extra_serial) + if self._check_placeholder_presence(extra_serial, r'%s'): + extra_serial = extra_serial % self.serial_tty + return extra_serial def _set_extra_serial_options(self, value): self._extra_serial_options = value extra_serial_options = property(_get_extra_serial_options, - _set_extra_serial_options) + _set_extra_serial_options) def get_metadata_field(self, field_name): """ Return the metadata value for field_name if it can be found. @@ -539,9 +545,11 @@ In general subclasses should not have to override this. """ boot_args_options = 'rootwait ro' + serial_options = '' if self.extra_boot_args_options: boot_args_options += ' %s' % self.extra_boot_args_options - serial_options = self.extra_serial_options + if self.extra_serial_options: + serial_options = self.extra_serial_options for console in consoles: serial_options += ' console=%s' % console @@ -553,14 +561,13 @@ if is_lowmem: lowmem_opt = 'only-ubiquity' - replacements = dict( - serial_options=serial_options, - lowmem_opt=lowmem_opt, boot_snippet=boot_snippet, - boot_args_options=boot_args_options) - return ( - "%(serial_options)s %(lowmem_opt)s " - "%(boot_snippet)s %(boot_args_options)s" - % replacements) + replacements = dict(serial_options=serial_options.strip(), + lowmem_opt=lowmem_opt, + boot_snippet=boot_snippet, + boot_args_options=boot_args_options) + boot_args = ("%(serial_options)s %(lowmem_opt)s %(boot_snippet)s" + " %(boot_args_options)s" % replacements).strip() + return boot_args def _get_boot_env(self, is_live, is_lowmem, consoles, rootfs_id, i_img_data, d_img_data): @@ -859,7 +866,7 @@ """Checks if the passed string contains the particular placeholder.""" # Very simple way of achieving that. presence = False - if placeholder in string: + if string and placeholder in string: presence = True return presence === modified file 'linaro_image_tools/media_create/tests/test_media_create.py' --- linaro_image_tools/media_create/tests/test_media_create.py 2012-12-27 14:58:24 +0000 +++ linaro_image_tools/media_create/tests/test_media_create.py 2013-01-09 09:22:50 +0000 @@ -2123,7 +2123,7 @@ is_live=False, is_lowmem=False, consoles=['ttyXXX'], rootfs_id="UUID=deadbeef", i_img_data=None, d_img_data=None) expected = ( - ' console=ttyXXX root=UUID=deadbeef rootwait ro %s' % boot_args) + 'console=ttyXXX root=UUID=deadbeef rootwait ro %s' % boot_args) self.assertEqual(expected, boot_commands['bootargs']) def test_passing_None_to_add_boot_args(self):