Check if 'hosts' file exists
authorFranco Gagliardi <redacted>
Sun, 15 Nov 2015 01:32:17 +0000 (22:32 -0300)
committerFranco Gagliardi <redacted>
Sun, 15 Nov 2015 01:32:17 +0000 (22:32 -0300)
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

index ea5a5130f2b48d34e2ef375259ded3d96034b59a..ce64d9004f5258b6b22df52fbc99eb74f9596167 100755 (executable)
@@ -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()
git clone https://git.99rst.org/PROJECT