From 7b181bfbcb8093a5c76e4b16ec1863c27d5624e1 Mon Sep 17 00:00:00 2001
From: Mitchel Humpherys <mitchelh@codeaurora.org>
Date: Fri, 4 Apr 2014 12:07:49 -0700
Subject: [PATCH] lrdp-v2: better error message for bad local_settings.py

When local_settings.py is missing variables we just error out when
trying to access those attributes. Improve the error message by
mentioning local_settings.py and pointing the user to README.txt.

Change-Id: Iaa2a1ab96ca889d75972bbfa1d4e127a8bf5bec1
---
 linux-ramdump-parser-v2/ramparse.py | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/linux-ramdump-parser-v2/ramparse.py b/linux-ramdump-parser-v2/ramparse.py
index 98b77ce..81adf2c 100755
--- a/linux-ramdump-parser-v2/ramparse.py
+++ b/linux-ramdump-parser-v2/ramparse.py
@@ -13,6 +13,7 @@
 
 import sys
 import os
+import re
 from optparse import OptionParser
 
 import parser_util
@@ -156,12 +157,19 @@ if __name__ == '__main__':
 
     try:
         import local_settings
-        if options.arm64:
-            gdb_path = gdb_path or local_settings.gdb64_path
-            nm_path = nm_path or local_settings.nm64_path
-        else:
-            gdb_path = gdb_path or local_settings.gdb_path
-            nm_path = nm_path or local_settings.nm_path
+        try:
+            if options.arm64:
+                gdb_path = gdb_path or local_settings.gdb64_path
+                nm_path = nm_path or local_settings.nm64_path
+            else:
+                gdb_path = gdb_path or local_settings.gdb_path
+                nm_path = nm_path or local_settings.nm_path
+        except AttributeError as e:
+            print_out_str("local_settings.py looks bogus. Please see README.txt")
+            missing_attr = re.sub(".*has no attribute '(.*)'", '\\1', e.message)
+            print_out_str("Specifically, looks like you're missing `%s'\n" % missing_attr)
+            print_out_str("Full message: %s" % e.message)
+            sys.exit(1)
     except ImportError:
         cross_compile = os.environ.get('CROSS_COMPILE')
         if cross_compile is not None:
-- 
GitLab