From 0b0988eeef7da3b10c85be8a2870170a7c444ab1 Mon Sep 17 00:00:00 2001 From: Franco Gagliardi Date: Sat, 14 Nov 2015 22:32:17 -0300 Subject: [PATCH] Check if 'hosts' file exists We need to check that the file exists before trying to update it, and if it doesn't we try to create an empty 'hosts' file. --- updateHostsFile.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/updateHostsFile.py b/updateHostsFile.py index ea5a5130f..ce64d9004 100755 --- a/updateHostsFile.py +++ b/updateHostsFile.py @@ -102,6 +102,15 @@ def main(): # Prompt the User def promptForUpdate(): + + # Create hosts file if it doesn't exists + if not os.path.isfile(os.path.join(BASEDIR_PATH, 'hosts')): + try: + file = open(os.path.join(BASEDIR_PATH, 'hosts'), 'w+').close() + except: + printFailure("ERROR: No 'hosts' file in the folder, try creating one manually") + sys.exit() + response = query_yes_no("Do you want to update all data sources?") if (response == "yes"): updateAllSources()