diff scripts/score_parser.py @ 1066:a2a245542ae6

Scripts: test if folder name (default or provided via command line) exists
author Brecht De Man <BrechtDeMan@users.noreply.github.com>
date Tue, 11 Aug 2015 10:15:17 +0200
parents 99cb3436759e
children 2ea78697aadf
line wrap: on
line diff
--- a/scripts/score_parser.py	Mon Aug 10 18:45:45 2015 +0200
+++ b/scripts/score_parser.py	Tue Aug 11 10:15:17 2015 +0200
@@ -20,6 +20,18 @@
 elif len(sys.argv) == 2:
     folder_name = sys.argv[1]   # First command line argument is folder
 
+# check if folder_name exists
+if not os.path.exists(folder_name):
+    #the file is not there
+    print "Folder '"+folder_name+"' does not exist."
+    sys.exit() # terminate script execution
+elif not os.access(os.path.dirname(folder_name), os.W_OK):
+    #the file does exist but write privileges are not given
+    print "No write privileges in folder '"+folder_name+"'."
+
+    
+# CODE
+
 # get every XML file in folder
 for file in os.listdir(folder_name):
     if file.endswith(".xml"):