From a0de072394bfcb1e436b9dbd2bf21a890175dc9f Mon Sep 17 00:00:00 2001 From: Austin Taylor Date: Sun, 25 Feb 2018 21:15:50 -0500 Subject: [PATCH] Automatically create filepath and directory if it does not exist --- vulnwhisp/vulnwhisp.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vulnwhisp/vulnwhisp.py b/vulnwhisp/vulnwhisp.py index 885e0bb..5055c3a 100755 --- a/vulnwhisp/vulnwhisp.py +++ b/vulnwhisp/vulnwhisp.py @@ -64,6 +64,14 @@ class vulnWhispererBase(object): self.database = \ os.path.abspath(os.path.join(os.path.dirname(__file__), 'database', db_name)) + if not os.path.exists(self.db_path): + os.makedirs(self.db_path) + self.vprint('{info} Creating directory {dir}'.format(info=bcolors.INFO, dir=self.db_path)) + + if not os.path.exists(self.database): + with open(self.database, 'w'): + self.vprint('{info} Creating file {dir}'.format(info=bcolors.INFO, dir=self.database)) + pass try: self.conn = sqlite3.connect(self.database)