From patchwork Thu Oct 20 07:01:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattias Backman X-Patchwork-Id: 4745 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 5306623FBD for ; Thu, 20 Oct 2011 07:01:12 +0000 (UTC) Received: from mail-wy0-f180.google.com (mail-wy0-f180.google.com [74.125.82.180]) by fiordland.canonical.com (Postfix) with ESMTP id 4991EA180EA for ; Thu, 20 Oct 2011 07:01:12 +0000 (UTC) Received: by wyg24 with SMTP id 24so3487531wyg.11 for ; Thu, 20 Oct 2011 00:01:12 -0700 (PDT) Received: by 10.223.77.69 with SMTP id f5mr16519419fak.3.1319094072053; Thu, 20 Oct 2011 00:01:12 -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.152.1.71 with SMTP id 7cs110919lak; Thu, 20 Oct 2011 00:01:11 -0700 (PDT) Received: by 10.216.24.41 with SMTP id w41mr5358856wew.69.1319094070963; Thu, 20 Oct 2011 00:01:10 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id w2si158770wec.123.2011.10.20.00.01.10 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 20 Oct 2011 00:01:10 -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 1RGmco-0006qs-L8 for ; Thu, 20 Oct 2011 07:01:10 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 95E73F5FCE for ; Thu, 20 Oct 2011 07:01:10 +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: 451 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 451: Display qemu version in l-m-c and l-a-m-c --version output. Message-Id: <20111020070110.31412.28935.launchpad@ackee.canonical.com> Date: Thu, 20 Oct 2011 07:01:10 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14165"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 1d08c658b70e504c85d61675d1a8dedadf6f6c35 Merge authors: Mattias Backman (mabac) Related merge proposals: https://code.launchpad.net/~mabac/linaro-image-tools/qemu-version/+merge/79821 proposed by: Mattias Backman (mabac) ------------------------------------------------------------ revno: 451 [merge] committer: Mattias Backman branch nick: linaro-image-tools timestamp: Thu 2011-10-20 08:58:39 +0200 message: Display qemu version in l-m-c and l-a-m-c --version output. modified: linaro_image_tools/media_create/__init__.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/__init__.py' --- linaro_image_tools/media_create/__init__.py 2011-10-12 13:44:12 +0000 +++ linaro_image_tools/media_create/__init__.py 2011-10-19 14:18:52 +0000 @@ -18,7 +18,10 @@ # along with Linaro Image Tools. If not, see . import argparse +import subprocess +import os +from linaro_image_tools import cmd_runner from linaro_image_tools.media_create.boards import board_configs from linaro_image_tools.media_create.android_boards import android_board_configs from linaro_image_tools.__version__ import __version__ @@ -46,9 +49,26 @@ setattr(namespace, 'is_live', True) +def get_version(): + qemu_path = '/usr/bin/qemu-arm-static' + p = cmd_runner.run(["head", "-n", "1"], + stdin=subprocess.PIPE, stdout=subprocess.PIPE) + if os.path.exists(qemu_path): + try: + # qemu-arm-static has no --version option so it fails, + # but still prints its version plus usage + cmd_runner.run(["/usr/bin/qemu-arm-static", "--version"], + stdout=p.stdin).communicate() + p.communicate() + except: + qemu_version = p.stdout.read() + else: + qemu_version = "Cannot find %s." % qemu_path + return "%s\n: %s" % (__version__, qemu_version) + def get_args_parser(): """Get the ArgumentParser for the arguments given on the command line.""" - parser = argparse.ArgumentParser(version='%(prog)s ' + __version__) + parser = argparse.ArgumentParser(version='%(prog)s ' + get_version()) group = parser.add_mutually_exclusive_group(required=True) group.add_argument( '--mmc', dest='device', help='The storage device to use.') @@ -129,7 +149,7 @@ def get_android_args_parser(): """Get the ArgumentParser for the arguments given on the command line.""" - parser = argparse.ArgumentParser(version='%(prog)s ' + __version__) + parser = argparse.ArgumentParser(version='%(prog)s ' + get_version()) group = parser.add_mutually_exclusive_group(required=True) group.add_argument( '--mmc', dest='device', help='The storage device to use.')