Howdy, Stranger!

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

Supported by

[open] Changing the logfile generic name

edited December 2014 in OpenSesame

Dear OpenSesame developers,

We are running (with success!) experiments on Android tablets and, for the sake of simplicity, I am looking for a way to create in the code the generic name of the logfile (for example: 'exp1' instead of 'subject-' or 'defaultlog'), so that the researchers who are running the experiment just need to input the subject number.
I am aware of the experiment.init function but I am lacking examples...

What should I write, and where?

Is there also a way to suppress the location prompt?

Thank you very much in advance!
Best,

C.

Comments

  • edited 6:19AM

    Hi C,

    I don't know much about the Android version, but the generic name for the logfile is defined in this, (line 99) file. If you find it on your system, I guess you can try replacing subject with whatever you prefer.

    Good luck,

    Eduard

    Buy Me A Coffee

  • edited 6:19AM

    Hello Eduard,

    Thank you for your fast answer and for your solution.
    I was thinking of a way to do so in the OpenSesame experiment (through an inline object, for instance), not in the Python code, as I don't seem to have access to it in Android...
    Sorry for the misunderstanding!
    Please, let me know if you have a solution!

    Best,

    Coralie

  • edited 6:19AM

    aah, too bad, I was afraid so. I don't really know how to solve this elegantly, sorry. Another work around might be to close the log file in the very end of the experiment, open it again and save it as another file. To do so, standard python function should be enough.

    Well, maybe @Sebastiaan knows a better solution?

    Eduard

    Buy Me A Coffee

  • edited 6:19AM

    Thank you for your solution, Eduard.
    Sebastiaan, let us know if you have another solution!

    Coralie

  • edited 6:19AM

    Another work around might be to close the log file in the very end of the experiment, open it again and save it as another file. To do so, standard python function should be enough. Well, maybe @Sebastiaan knows a better solution?

    It might be slightly easier to close and re-open the logfile as the first thing in the experiment. Something like this should do the trick:

    import codecs
    exp._log.close()
    exp._log = codecs.open('my_new_logfile.csv', 'w', encoding='utf-8')
    

    Note that codecs.open() allows for transparent writing of unicode data, but is otherwise the same as plain open().

    Is there also a way to suppress the location prompt?

    Not easily. The only way to bypass (or change) the menu is by creating your own .apk package, using the setup-android.py included with the OpenSesame source code. But that would take a bit of hacking.

Sign In or Register to comment.