From c36143c03ff94556f7bf6313cf394cbc7525cc88 Mon Sep 17 00:00:00 2001
From: Mitchel Humpherys <mitchelh@codeaurora.org>
Date: Fri, 4 Apr 2014 13:55:33 -0700
Subject: [PATCH] lrdp-v2: create output directory if it doesn't exist

Currently we error out and ask the user to create the output directory
if it doesn't exist. As a convenience, just create the directory for
them.

Change-Id: I0e9caa8294d644621bd166a06e2a70c8ca5715fc
---
 linux-ramdump-parser-v2/ramparse.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/linux-ramdump-parser-v2/ramparse.py b/linux-ramdump-parser-v2/ramparse.py
index 2708ac7..a2181ab 100755
--- a/linux-ramdump-parser-v2/ramparse.py
+++ b/linux-ramdump-parser-v2/ramparse.py
@@ -91,8 +91,12 @@ if __name__ == '__main__':
 
     if options.outdir:
         if not os.path.exists(options.outdir):
-            print ('!!! Out directory does not exist. Create it first.')
-            sys.exit(1)
+            print ('!!! Out directory does not exist. Creating...')
+            try:
+                os.makedirs(options.outdir)
+            except:
+                print ("Failed to create %s. You probably don't have permissions there. Bailing." % options.outdir)
+                sys.exit(1)
     else:
         options.outdir = '.'
 
-- 
GitLab