import expyriment as e
import cv2
from asl_english_trials import PictureNaming
from asl_english_trials.VideoInput import VideoInput

if __name__ == '__main__':
    exp = e.design.Experiment(name="Protocol 3: Picture Naming")

    for block in PictureNaming.blocks:
        exp.add_block(block)

    e.control.initialize(exp)
    exp.data_variable_names = ['picture name', 'video filename', 'type', 'reaction time']

    for block in exp.blocks:
        for trial in block.trials:
            trial.preload_stimuli()

    device = cv2.VideoCapture(0)
    device.release()

    e.control.start(exp)
    e.control.stop_audiosystem()

    for block in exp.blocks:
        for trial in block.trials:
             trial.present_callback(trial, exp, device)

    e.control.end(system_exit=True)

@@ -153,16 +153,29 @@
 ain__':%0A
+    try:%0A    
     exp 
@@ -232,16 +232,20 @@
 ming%22)%0A%0A
+    
     for 
@@ -279,24 +279,28 @@
 ks:%0A        
+    
 exp.add_bloc
@@ -309,24 +309,28 @@
 block)%0A%0A    
+ 
+   
 e.control.in
@@ -339,24 +339,28 @@
 ialize(exp)%0A
+    
     exp.data
@@ -438,16 +438,20 @@
 time'%5D%0A%0A
+    
     for 
@@ -471,32 +471,36 @@
 blocks:%0A        
+    
 for trial in blo
@@ -514,32 +514,36 @@
 ls:%0A            
+    
 trial.preload_st
@@ -551,24 +551,28 @@
 muli()%0A%0A    
+  
+  
 device = cv2
@@ -588,16 +588,20 @@
 ture(0)%0A
+    
     devi
@@ -610,24 +610,28 @@
 .release()%0A%0A
+    
     e.contro
@@ -643,24 +643,28 @@
 rt(exp)%0A    
+ 
+   
 e.control.st
@@ -681,24 +681,28 @@
 stem()%0A%0A    
+  
+  
 for block in
@@ -714,32 +714,36 @@
 blocks:%0A        
+   
+ 
 for trial in blo
@@ -745,32 +745,36 @@
 n block.trials:%0A
+    
              tri
@@ -813,17 +813,33 @@
 device)%0A
-%0A
+    finally:%0A    
     e.co

make sure the experiment dies on errors