Mercurial > hg > webaudioevaluationtool
comparison python/timeline_view_movement.py @ 2274:2b5990868aa7
timeline_view.py and timeline_view_movement.py compatible with Python 2.7 and 3.x: print ... --> print(...)
author | Brecht De Man <b.deman@qmul.ac.uk> |
---|---|
date | Wed, 20 Apr 2016 19:12:16 +0200 |
parents | 556b79c72eee |
children | 3004c6a5665c |
comparison
equal
deleted
inserted
replaced
2273:ad2e070c92e5 | 2274:2b5990868aa7 |
---|---|
13 "Use: python timeline_view_movement.py [XML_files_location]" | 13 "Use: python timeline_view_movement.py [XML_files_location]" |
14 | 14 |
15 # XML results files location | 15 # XML results files location |
16 if len(sys.argv) == 1: | 16 if len(sys.argv) == 1: |
17 folder_name = "../saves" # Looks in 'saves/' folder from 'scripts/' folder | 17 folder_name = "../saves" # Looks in 'saves/' folder from 'scripts/' folder |
18 print "Use: python timeline_view_movement.py [XML_files_location]" | 18 print("Use: python timeline_view_movement.py [XML_files_location]") |
19 print "Using default path: " + folder_name | 19 print("Using default path: " + folder_name) |
20 elif len(sys.argv) == 2: | 20 elif len(sys.argv) == 2: |
21 folder_name = sys.argv[1] # First command line argument is folder | 21 folder_name = sys.argv[1] # First command line argument is folder |
22 | 22 |
23 # check if folder_name exists | 23 # check if folder_name exists |
24 if not os.path.exists(folder_name): | 24 if not os.path.exists(folder_name): |
25 #the file is not there | 25 #the file is not there |
26 print "Folder '"+folder_name+"' does not exist." | 26 print("Folder '"+folder_name+"' does not exist.") |
27 sys.exit() # terminate script execution | 27 sys.exit() # terminate script execution |
28 elif not os.access(os.path.dirname(folder_name), os.W_OK): | 28 elif not os.access(os.path.dirname(folder_name), os.W_OK): |
29 #the file does exist but write privileges are not given | 29 #the file does exist but write privileges are not given |
30 print "No write privileges in folder '"+folder_name+"'." | 30 print("No write privileges in folder '"+folder_name+"'.") |
31 | 31 |
32 | 32 |
33 # CONFIGURATION | 33 # CONFIGURATION |
34 | 34 |
35 # Folder where to store timelines | 35 # Folder where to store timelines |
70 for page in root.findall("./page"): # iterate over pages | 70 for page in root.findall("./page"): # iterate over pages |
71 page_name = page.get('ref') # get page name | 71 page_name = page.get('ref') # get page name |
72 plot_empty = True # check if any data is plotted | 72 plot_empty = True # check if any data is plotted |
73 | 73 |
74 if page_name is None: # ignore 'empty' audio_holders | 74 if page_name is None: # ignore 'empty' audio_holders |
75 print "Skipping empty page name from "+subject_id+"." | 75 print("Skipping empty page name from "+subject_id+".") |
76 break | 76 break |
77 | 77 |
78 # subtract total page length from subsequent page event times | 78 # subtract total page length from subsequent page event times |
79 page_time_temp = page.find("./metric/metricresult/[@id='testTime']") | 79 page_time_temp = page.find("./metric/metricresult/[@id='testTime']") |
80 if page_time_temp is not None: | 80 if page_time_temp is not None: |
81 page_time = float(page_time_temp.text) | 81 page_time = float(page_time_temp.text) |
82 else: | 82 else: |
83 print "Skipping page without total time specified from "+subject_id+"." | 83 print("Skipping page without total time specified from "+subject_id+".") |
84 break | 84 break |
85 | 85 |
86 # get audioelements | 86 # get audioelements |
87 audioelements = page.findall("./audioelement") | 87 audioelements = page.findall("./audioelement") |
88 | 88 |
109 audio_id = str(audioelement.get('ref')) | 109 audio_id = str(audioelement.get('ref')) |
110 | 110 |
111 # break if no initial position or move events registered | 111 # break if no initial position or move events registered |
112 initial_position_temp = audioelement.find("./metric/metricResult/[@name='elementInitialPosition']") | 112 initial_position_temp = audioelement.find("./metric/metricResult/[@name='elementInitialPosition']") |
113 if initial_position_temp is None: | 113 if initial_position_temp is None: |
114 print "Skipping "+page_name+" from "+subject_id+": does not have initial positions specified." | 114 print("Skipping "+page_name+" from "+subject_id+": does not have initial positions specified.") |
115 break | 115 break |
116 | 116 |
117 # get move events, initial and eventual position | 117 # get move events, initial and eventual position |
118 initial_position = float(initial_position_temp.text) | 118 initial_position = float(initial_position_temp.text) |
119 move_events = audioelement.findall("./metric/metricResult/[@name='elementTrackerFull']/movement") | 119 move_events = audioelement.findall("./metric/metricResult/[@name='elementTrackerFull']/movement") |