Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Getting extensions to print debug messages

jpgjpg
edited November 2014 in OpenSesame

Hello, love the new changes in 2.9.0!

I'm giving writing extensions a go, and I was following the extensions guide and example extension, but I can't seem to get the example to correctly execute the debug.msg()

I'm running OpenSesame in debug mode, and through the console I can from libopensesame import debug and it functions as expected.

But when I try to activate the example extension, nothing happens when any of the conditions are met (on activation, run experiment, new item etc)

Any ideas what I'm doing wrong?

Comments

  • edited 6:16AM

    Good to hear that you're trying out the extension framework!

    But when I try to activate the example extension, nothing happens when any of the conditions are met (on activation, run experiment, new item etc)

    Well, the example extension doesn't perform any overt task, it only prints some debugging output, which you should see in the console. Things like: example.py(38).activate: Example extension activated. Also, during startup, OpenSesame lists all extensions and the events that they support like so:

    _base_extension.py(49).__init__: creating example
    _base_extension.py(439).supported_events: extension example supports event_close
    _base_extension.py(439).supported_events: extension example supports event_end_experiment
    _base_extension.py(439).supported_events: extension example supports event_new_item
    _base_extension.py(439).supported_events: extension example supports event_open_experiment
    _base_extension.py(439).supported_events: extension example supports event_purge_unused_items
    _base_extension.py(439).supported_events: extension example supports event_regenerate
    _base_extension.py(439).supported_events: extension example supports event_rename_item
    _base_extension.py(439).supported_events: extension example supports event_run_experiment
    _base_extension.py(439).supported_events: extension example supports event_save_experiment
    _base_extension.py(439).supported_events: extension example supports event_startup
    

    If you don't see any output of this type, and don't get any 'Extension misbehaved' error messages either, then OpenSesame probably hasn't loaded the extension at all. Is it in the correct folder? Have you enabled the extension in the extension manager?

    Cheers!
    Sebastiaan

  • jpgjpg
    edited 6:16AM

    Hi Sebastiaan,

    Well, the example extension doesn't perform any overt task, it only prints some debugging output, which you should see in the console. Things like: example.py(38).activate: Example extension activated.

    This is what I'm having a problem with; there isn't any debug output

    If you don't see any output of this type, and don't get any 'Extension misbehaved' error messages either, then OpenSesame probably hasn't loaded the extension at all. Is it in the correct folder? Have you enabled the extension in the extension manager?

    On startup (with the --debug flag) it doesn't give me the above output, just the standard message:

    Python 2.7.6 Type "help()", "copyright()", "credits()" or "license()" for more information. Type "modules()" for details about installed modules and version information. Use the "print([msg])" statement in inline_script items to print to this debug window.

    When the experiment is run it gives the usual debug output:

    qtopensesame.py(916).run_experiment: using <class 'libqtopensesame.runners.multiprocess_runner.multiprocess_runner'> runner qtopensesame.py(857).get_ready: experiment.py(200).__init__: reusing existing pool folder experiment.py(202).__init__: pool folder is 'c:\users\jgoodl~1\appdata\local\temp\tmp3kyaeb.opensesame_pool' experiment.py(586).open: opening from unicode string experiment.py(302).from_string: building experiment item_store.py(71).new: creating sequence item_store.py(85).new: loading core item 'sequence' from 'libopensesame' item_store.py(71).new: creating notepad item.py(307).from_string: item_store.py(71).new: creating sketchpad item_store.py(85).new: loading core item 'sketchpad' from 'libopensesame' _base_element.py(55).__init__: textline experiment.py(200).__init__: reusing existing pool folder experiment.py(202).__init__: pool folder is 'c:\users\jgoodl~1\appdata\local\temp\tmp3kyaeb.opensesame_pool' experiment.py(586).open: opening from unicode string experiment.py(302).from_string: building experiment item_store.py(71).new: creating sequence item_store.py(85).new: loading core item 'sequence' from 'libopensesame' item_store.py(71).new: creating notepad item.py(307).from_string: item_store.py(71).new: creating sketchpad item_store.py(85).new: loading core item 'sketchpad' from 'libopensesame' _base_element.py(55).__init__: textline Starting experiment as ExperimentProcess-1 canvas.py(64).init_display: morphing into xpyriment Expyriment 0.7.0 (Revision 7a6b73d; Python 2.7.6) File: opensesame.exe (6a8b7f) Warning: OpenGL does not support window mode. OpenGL will be deactivated! sampler.py(58).init_sound: morphing into legacy openexp.sampler._legacy.init_sound(): sampling freq = 48000, buffer size = 1024 openexp.sampler._legacy.init_sound(): mixer already initialized, closing experiment.init_log(): using 'C:/E-PRIME\quickrun.csv' as logfile (utf-8) experiment.run(): experiment started at Wed Nov 05 10:54:55 2014 keyboard.py(41).keyboard: morphing into legacy keyboard.py(41).keyboard: morphing into legacy canvas.py(47).canvas: morphing into xpyriment html.py(146).render: OpenSesame 2.9.0 <i>Hesitant Heisenberg</i> html.py(146).render: OpenSesame html.py(146).render: 2.9.0 html.py(146).render: html.py(146).render: Hesitant html.py(146).render: Heisenberg sampler.py(74).close_sound: morphing into legacy canvas.py(80).close_display: morphing into xpyriment The escape key was pressed.

    The extension is installed and enabled and it comes up in the menu:

  • edited 6:16AM

    Right, I see. You're looking for the debug output in the wrong place. It won't appear in the debug window, but is printed to the standard output. In Windows, you won't see this unless you start OpenSesame from the command line, or through a bash-terminal emulator.

    When you start an experiment, OpenSesame temporarily reroutes the standard output to the debug window. This is helpful to debug your experiment. But the debug output generated by the GUI, while no experiment is running, is just printed to the standard output. That's why you don't see anything in the debug window. Does that clear things up?

  • jpgjpg
    edited 6:16AM

    Ah, that makes sense, thank you.

    I did try launching it with --debug from cmd and console2, though there is still no output whatsoever there. Is there a convenient way to do this in Windows?

    When using the WinPython portable version (2.8.3) it does give a debug output to the cmd terminal correctly.

    I'm sure I'm missing something obvious here!

  • edited 6:16AM

    Windows isn't very terminal-friendly, and to be honest I'm not too familiar with the Windows command prompt. (I use Linux almost exclusively.) What you could is install git, which will also install a bash emulator. From this emulator you can start OpenSesame in debug mode and see all the output. See also this blog post, which I wrote a while back:

  • jpgjpg
    edited 6:16AM

    Wonderful, I'll have a play with Git, been meaning to for a while. Failing that I'll reboot in Linux. Thanks for your help :)

Sign In or Register to comment.