From c307a73e289cb8cd8a75609a02c9f42b364f0ff8 Mon Sep 17 00:00:00 2001
From: Tim G <bitbucket@darkgate.net>
Date: Tue, 1 Apr 2014 22:36:19 +1000
Subject: [PATCH] Check for errors from adb, may not work on all systems.

---
 lib/ansible/module_utils/facts.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py
index b97260d77b..5a6153fade 100644
--- a/lib/ansible/module_utils/facts.py
+++ b/lib/ansible/module_utils/facts.py
@@ -1257,8 +1257,9 @@ class HPUX(Hardware):
                 #adb output. Unfortunatley /dev/kmem doesn't have world-read, so this only works as root.
                 if os.access("/dev/kmem", os.R_OK):
                     rc, out, err = module.run_command("echo 'phys_mem_pages/D' | adb -k /stand/vmunix /dev/kmem | tail -1 | awk '{print $2}'", use_unsafe_shell=True)
-                    data = out
-                    self.facts['memtotal_mb'] = int(data) / 256
+                    if not err:
+                      data = out
+                      self.facts['memtotal_mb'] = int(data) / 256
         else:
             rc, out, err = module.run_command("/usr/contrib/bin/machinfo | grep Memory", use_unsafe_shell=True)
             data = re.search('Memory[\ :=]*([0-9]*).*MB.*',out).groups()[0].strip()