data.parseMsg() data.displayData() arduino.sendMsg = True data.logData() if data.index > 0: if getattr(posit, Vars.positional)(): data.trials += 1 if getattr(behave, Vars.behavioral1)(): if getattr(behave, Vars.behavioral2)(): if getattr(behave, Vars.behavioral3)(): data.successes += 1 if prob.probability(): data.rewards += 1 arduino.openValve(Vars.valveOpenMillis) if data.endExperiment(): raise KeyboardInterrupt except OSError: print "Why is there an OSError? Possibly because you reset the arduino?" time.sleep(2) except IOError: print "Plug the arduino back in" time.sleep(2)