changeset 2567:096bdb64d116

Python scripts: allow 'python [path to python folder]/generate_report.py ...'; fix bug in timeline visualisation.
author Brecht De Man <b.deman@qmul.ac.uk>
date Mon, 19 Sep 2016 21:02:36 +0200
parents 172c76d9414b
children 4903cda56c2a
files python/generate_report.py python/timeline_view_movement.py
diffstat 2 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/python/generate_report.py	Thu Sep 08 16:20:18 2016 +0100
+++ b/python/generate_report.py	Mon Sep 19 21:02:36 2016 +0200
@@ -116,9 +116,10 @@
 
 # generate images for later use
 if render_figures:
-    subprocess.call("python timeline_view_movement.py '"+folder_name+"'", shell=True)
-    subprocess.call("python score_parser.py '"+folder_name+"'", shell=True)
-    subprocess.call("python score_plot.py '"+folder_name+"ratings/'", shell=True)
+    script_path = os.path.dirname(os.path.realpath(__file__)) # where is generate_report.py?
+    subprocess.call("python " +script_path+"/timeline_view_movement.py '"+folder_name+"'", shell=True)
+    subprocess.call("python " +script_path+"/score_parser.py '"+folder_name+"'", shell=True)
+    subprocess.call("python " +script_path+"/score_plot.py '"+folder_name+"ratings/'", shell=True)
 
 # make array of text and array of dates
 body_array = []
--- a/python/timeline_view_movement.py	Thu Sep 08 16:20:18 2016 +0100
+++ b/python/timeline_view_movement.py	Mon Sep 19 21:02:36 2016 +0200
@@ -124,9 +124,10 @@
                     stop_times_global  = []
                     listen_events = audioelement.findall("./metric/metricresult/[@name='elementListenTracker']/event")
                     for event in listen_events:
-                        # get testtime: start and stop
-                        start_times_global.append(float(event.find('testtime').get('start')))#-time_offset)
-                        stop_times_global.append(float(event.find('testtime').get('stop')))#-time_offset)
+                        if event.find('testtime') is not None:
+                            # get testtime: start and stop
+                            start_times_global.append(float(event.find('testtime').get('start')))#-time_offset)
+                            stop_times_global.append(float(event.find('testtime').get('stop')))#-time_offset)
                     
                     # display fragment name at start
                     plt.text(0,initial_position+0.02,audio_id,color=colormap[increment%len(colormap)]) #,rotation=45