aboutsummaryrefslogtreecommitdiff
path: root/linaro_image_tools/media_create
diff options
context:
space:
mode:
authorFathi Boudra <fathi.boudra@linaro.org>2016-02-10 13:14:46 +0200
committerFathi Boudra <fathi.boudra@linaro.org>2016-02-10 13:14:46 +0200
commit92e421047525ce677d573de91bb4dda1a0249193 (patch)
tree053312c818fe94640cd10177698b2efc4e48dffb /linaro_image_tools/media_create
parentd50d5c048f21df906261fa9ccd79055101c38375 (diff)
downloadlinaro-image-tools-92e421047525ce677d573de91bb4dda1a0249193.tar.gz
Fix qemu-arm-static version parsing
Closes https://bugs.linaro.org/show_bug.cgi?id=2020 qemu_version is referenced before assignment. Parse -version output and include a fallback in case it fails. In addition, fix also the output formatting as we need the raw formatter to display \n as expected. Change-Id: I3248696194f0ca4077ff9ac3d9e86e5088d577d6 Signed-off-by: Fathi Boudra <fathi.boudra@linaro.org>
Diffstat (limited to 'linaro_image_tools/media_create')
-rw-r--r--linaro_image_tools/media_create/__init__.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/linaro_image_tools/media_create/__init__.py b/linaro_image_tools/media_create/__init__.py
index 43ab610..4c8efa2 100644
--- a/linaro_image_tools/media_create/__init__.py
+++ b/linaro_image_tools/media_create/__init__.py
@@ -55,20 +55,16 @@ class Live256MegsAction(argparse.Action):
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()
+ # qemu-arm-static has -version option
+ proc = cmd_runner.run([qemu_path, "-version"],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ (qemu_version, stderrdata) = proc.communicate()
+ if (proc.returncode or stderrdata):
+ qemu_version = "qemu-arm version unknown (%s)" % stderrdata
else:
qemu_version = "Cannot find %s." % qemu_path
- return "%s\n: %s" % (__version__, qemu_version)
+ return "%s\n* %s" % (__version__, qemu_version)
def add_common_options(parser):
@@ -83,7 +79,8 @@ def add_common_options(parser):
def get_args_parser():
"""Get the ArgumentParser for the arguments given on the command line."""
- parser = argparse.ArgumentParser(version='%(prog)s ' + get_version())
+ parser = argparse.ArgumentParser(version='%(prog)s ' + get_version(),
+ formatter_class=argparse.RawTextHelpFormatter)
group = parser.add_mutually_exclusive_group()
group.add_argument(
'--mmc', dest='device', default="sd.img",
@@ -189,7 +186,8 @@ def get_args_parser():
def get_android_args_parser():
"""Get the ArgumentParser for the arguments given on the command line."""
- parser = argparse.ArgumentParser(version='%(prog)s ' + get_version())
+ parser = argparse.ArgumentParser(version='%(prog)s ' + get_version(),
+ formatter_class=argparse.RawTextHelpFormatter)
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
'--mmc', dest='device', help='The storage device to use.')