def prepare(self): """<DOC> Execute the prepare script. The code that you enter in the 'prepare' tab of an inline_script item in the GUI is used as a body for this function. </DOC>""" item.item.prepare(self) # Convenience variables exp = self.experiment win = self.experiment.window # Compile prepare script try: self.cprepare = compile(self._prepare, "<string>", "exec") except Exception as e: raise exceptions.inline_error(self.name, "prepare", e) # Compile run script try: self.crun = compile(self._run, "<string>", "exec") except Exception as e: raise exceptions.inline_error(self.name, "run", e) # Run prepare script try: exec(self.cprepare) except Exception as e: raise exceptions.inline_error(self.name, "prepare", e) # Report success return True
def prepare(self): """<DOC> Execute the prepare script. The code that you enter in the 'prepare' tab of an inline_script item in the GUI is used as a body for this function. </DOC>""" item.item.prepare(self) # Convenience variables exp = self.experiment win = self.experiment.window try: self.cprepare = compile(self._prepare, "<string>", "exec") except Exception as e: raise exceptions.inline_error(self.name, "prepare", e) try: self.crun = compile(self._run, "<string>", "exec") except Exception as e: raise exceptions.inline_error(self.name, "run", e) try: exec(self.cprepare) except Exception as e: raise exceptions.inline_error(self.name, "prepare", e) return True
def prepare(self): """<DOC> Execute the prepare script. The code that you enter in the 'prepare' tab of an inline_script item in the GUI is used as a body for this function. </DOC>""" item.item.prepare(self) try: self.cprepare = compile(self._prepare, "<string>", "exec") except Exception as e: raise exceptions.inline_error(self.name, "prepare", e) try: self.crun = compile(self._run, "<string>", "exec") except Exception as e: raise exceptions.inline_error(self.name, "run", e) try: exec(self.cprepare) except Exception as e: raise exceptions.inline_error(self.name, "prepare", e) return True
def prepare(self): """<DOC> Executes the prepare script. The code that you enter in the 'prepare' # tab of an inline_script item in the GUI is used as a body for this # function. </DOC>""" global _globals, _locals item.item.prepare(self) # Convenience variables need to be registered as globals if 'exp' not in _globals: _globals['exp'] = self.experiment _globals['win'] = self.experiment.window # Compile prepare script try: self.cprepare = compile(self._prepare, "<string>", "exec") except Exception as e: raise exceptions.inline_error(self.name, "prepare", e) # Compile run script try: self.crun = compile(self._run, "<string>", "exec") except Exception as e: raise exceptions.inline_error(self.name, "run", e) # Run prepare script try: exec(self.cprepare, _globals, _locals) except Exception as e: raise exceptions.inline_error(self.name, "prepare", e) # Report success return True
def prepare(self): """<DOC> Executes the prepare script. The code that you enter in the 'prepare' # tab of an inline_script item in the GUI is used as a body for this # function. </DOC>""" global _globals, _locals item.item.prepare(self) if self.experiment.transparent_variables == u'yes': self.start_transparency() # Convenience variables need to be registered as globals. By specifying # a __name__, the script will function as a module, so that e.g. import # statements do not suffer from locality. if u'exp' not in _globals: _globals[u'exp'] = self.experiment _globals[u'win'] = self.experiment.window _globals[u'__name__'] = u'myname' # 'self' must always be registered, otherwise we get confusions between # the various inline_script items. _globals[u'self'] = self # Prepend source encoding (PEP 0263) and encode scripts. This is # necessary, because the exec statement doesn't take kindly to Unicode. _prepare = (u'#-*- coding:%s -*-\n' % self.encoding + self._prepare) \ .encode(self.encoding) _run = (u'#-*- coding:%s -*-\n' % self.encoding + self._run) \ .encode(self.encoding) # Compile prepare script try: self.cprepare = compile(_prepare, u'<string>', u'exec') except Exception as e: raise exceptions.inline_error(self.name, u'prepare', e) # Compile run script try: self.crun = compile(_run, u'<string>', u'exec') except Exception as e: raise exceptions.inline_error(self.name, u'run', e) # Run prepare script try: exec(self.cprepare, _globals) except Exception as e: raise exceptions.inline_error(self.name, u'prepare', e) if self.experiment.transparent_variables == u'yes': self.end_transparency()
def prepare(self): """<DOC> Executes the prepare script. The code that you enter in the 'prepare' # tab of an inline_script item in the GUI is used as a body for this # function. </DOC>""" global _globals, _locals item.item.prepare(self) if self.experiment.transparent_variables == u"yes": self.start_transparency() # Convenience variables need to be registered as globals. By specifying # a __name__, the script will function as a module, so that e.g. import # statements do not suffer from locality. if u"exp" not in _globals: _globals[u"exp"] = self.experiment _globals[u"win"] = self.experiment.window _globals[u"__name__"] = u"myname" # 'self' must always be registered, otherwise we get confusions between # the various inline_script items. _globals[u"self"] = self # Prepend source encoding (PEP 0263) and encode scripts. This is # necessary, because the exec statement doesn't take kindly to Unicode. _prepare = (u"#-*- coding:%s -*-\n" % self.encoding + self._prepare).encode(self.encoding) _run = (u"#-*- coding:%s -*-\n" % self.encoding + self._run).encode(self.encoding) # Compile prepare script try: self.cprepare = compile(_prepare, u"<string>", u"exec") except Exception as e: raise exceptions.inline_error(self.name, u"prepare", e) # Compile run script try: self.crun = compile(_run, u"<string>", u"exec") except Exception as e: raise exceptions.inline_error(self.name, u"run", e) # Run prepare script try: exec(self.cprepare, _globals) except Exception as e: raise exceptions.inline_error(self.name, u"prepare", e) if self.experiment.transparent_variables == u"yes": self.end_transparency()
def run(self): """ Execute the run script """ try: exec(self.crun) except Exception as e: raise exceptions.inline_error(self.name, "run", e) return True
def prepare(self): """ Execute the prepare script """ item.item.prepare(self) try: self.cprepare = compile(self._prepare, "<string>", "exec") except Exception as e: raise exceptions.inline_error(self.name, "prepare", e) try: self.crun = compile(self._run, "<string>", "exec") except Exception as e: raise exceptions.inline_error(self.name, "run", e) try: exec(self.cprepare) except Exception as e: raise exceptions.inline_error(self.name, "prepare", e) return True
def run(self): """<DOC> Execute the run script. The code that you enter in the 'run' tab of an inline_script item in the GUI is used as a body for this function. </DOC>""" try: exec(self.crun) except Exception as e: raise exceptions.inline_error(self.name, "run", e) return True
def run(self): """<DOC> Execute the run script. The code that you enter in the 'run' tab of an inline_script item in the GUI is used as a body for this function. </DOC>""" # Convenience variables exp = self.experiment win = self.experiment.window try: exec(self.crun) except Exception as e: raise exceptions.inline_error(self.name, "run", e) return True
def run(self): """<DOC> Executes the run script. The code that you enter in the 'run' tab of # an inline_script item in the GUI is used as a body for this function. </DOC>""" global _globals, _locals if self.experiment.transparent_variables == u'yes': self.start_transparency() try: exec(self.crun, _globals) except Exception as e: raise exceptions.inline_error(self.name, u'run', e) if self.experiment.transparent_variables == u'yes': self.end_transparency()
def run(self): """<DOC> Executes the run script. The code that you enter in the 'run' tab of # an inline_script item in the GUI is used as a body for this function. </DOC>""" global _globals, _locals if self.experiment.transparent_variables == u"yes": self.start_transparency() try: exec(self.crun, _globals) except Exception as e: raise exceptions.inline_error(self.name, u"run", e) if self.experiment.transparent_variables == u"yes": self.end_transparency()