I am creating an experiment with the PsychoPy Builder.
I have visual and auditory stimuli, the task is to learn associations between them.
When the participant presses the right key, the answer "Correct" appears. However, when the participant presses the wrong key, I would like to not only display "Wrong." But also: "The correct answer is ..." and then show the picture or the sound of the correct association.
I have created a routine that is called "Feedback". It contains the Code component, the Text component and the Picture component (or the sound component).
In the condition file (.xlsx), the picture (sound) that should be displayed is called "corrective_FB".
In the Code Component in "Begin Experiment", I have
message=''
In the Code Component I have written the following code in the "Begin Routine":
if Antwort_manuell.corr:#stored on last run routine
message="Richtig!"
else:
message="Ups, das war falsch. Die richtige Antwort wäre:"
Form_stimulus2.setImage(corrective_FB)
I guess, I am not doing the "display image" command correctly. How is the correct command? And how is it for an auditory stimulus?
When I run the experiment, it seems to work when I press the correct keypress (however, the picture is shown then, too and it should only be the text....), but when I press the wrong key, the experiment stops.
When I force it to end, I get the follwing message:
Running: C:\Dateien\Forschung\Experimente\Legasthenie_Crossmodal\Experiment\Visual_manual\Vis_Man_lastrun.py
Traceback (most recent call last)
File "C:\Dateien\Forschung\Experimente\Legasthenie_Crossmodal\Experiment\Visual_manual\Vis_Man_lastrun.py", line 406, in
Feedbacktext.setText(message)
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.82.01-py2.7.egg\psychopy\visual\text.py", line 240, in setText
setAttribute(self, 'text', text, log)
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.82.01-py2.7.egg\psychopy\tools\attributetools.py", line 100, in setAttribute
setattr(self, attrib, value) # set attribute, calling attributeSetter if it exists
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.82.01-py2.7.egg\psychopy\tools\attributetools.py", line 20, in __set__
newValue = self.func(obj, value)
File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.82.01-py2.7.egg\psychopy\visual\text.py", line 231, in text
self.dict['text'] = unicode(text)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 43: ordinal not in range(128)
Exception UnicodeDecodeError:
Thank you all for your help. I finally got it work. I indeed had to mark the message as a unicode string.
And I had to define more explicitly how the stimulus will be shown for correct and wrong answers.
I don't know, if I did it the most intelligent way, but it works. I am thankful for suggestions how it can be done more "beautifully", but this is how my code looks like now:
if Antwort_manuell.corr:#stored on last run routine
message="Richtig!"
Form_stimulus2.size = 0
else:
message=u"Ups, das war falsch. Die richtige Antwort wäre:"
Form_stimulus2.setImage(corrective_FB)
Form_stimulus2.size = 5
And for the sound the code is:
if key_tester.corr:#stored on last run routine
message="Richtig!"
sound_1.volume = 0
else:
message=u"Ups, das war falsch. Die richtige Antwort wäre:"
sound_1.setSound(corrective_FB)
sound_1.volume = 1
Related
I am very new to robot framework, working it at pycharm.
I just want to input some text at current field. but none of these works.
I have tried
Press Keycode a
Press Keys text_field q
input text ${mylocator} ${string-abc}
If I am using the correct library?
*** Settings ***
Library AppiumLibrary run_on_failure=AppiumLibrary.CapturePageScreenshot
Library Selenium2Library run_on_failure=AppiumLibrary.CapturePageScreenshot
*** Variables ***
${MsgEditor} //*[#class='android.widget.RelativeLayout' and #resource-id='com.test.abc.work.cac:id/editor']
*** Test Cases ***
Add item
Press Keys text_field q <--error browser not open
\\or
appiumlibrary.Input Text ${MsgEditor} update <== error Message: Cannot set the element to 'update'. Did you interact with the correct element?
updated that Press Keys still failed. error:
KEYWORD Selenium2Library . Press Keys text_field, q
Documentation:
Simulates the user pressing key(s) to an element or on the active browser.
Start / End / Elapsed: 20201218 10:05:20.575 / 20201218 10:05:21.339 / 00:00:00.764
00:00:00.755KEYWORD AppiumLibrary . Capture Page Screenshot
10:05:20.575 TRACE Arguments: [ 'text_field' | 'q' ]
10:05:20.581 INFO Sending key(s) ('q',) to text_field element.
10:05:21.339 FAIL No browser is open.
10:05:21.339 DEBUG Traceback (most recent call last):
File "c:\users\tester\pycharmprojects\androidtest\venv\lib\site-packages\SeleniumLibrary\__init__.py", line 471, in run_keyword
return DynamicCore.run_keyword(self, name, args, kwargs)
File "c:\users\tester\pycharmprojects\androidtest\venv\lib\site-packages\robotlibcore.py", line 103, in run_keyword
return self.keywords[name](*args, **(kwargs or {}))
File "c:\users\tester\pycharmprojects\androidtest\venv\lib\site-packages\SeleniumLibrary\keywords\element.py", line 895, in press_keys
element = self.find_element(locator)
File "c:\users\tester\pycharmprojects\androidtest\venv\lib\site-packages\SeleniumLibrary\base\context.py", line 74, in find_element
return self.element_finder.find(locator, tag, True, required, parent)
File "c:\users\tester\pycharmprojects\androidtest\venv\lib\site-packages\SeleniumLibrary\locators\elementfinder.py", line 74, in find
parent=parent or self.driver)
File "c:\users\tester\pycharmprojects\androidtest\venv\lib\site-packages\SeleniumLibrary\base\context.py", line 32, in driver
return self.ctx.driver
File "c:\users\tester\pycharmprojects\androidtest\venv\lib\site-packages\SeleniumLibrary\__init__.py", line 547, in driver
raise NoOpenBrowser('No browser is open.')
InputText failed. I have this same InputText at other field and works. I tried tap over different field with that locator and it works.
is the app has issue on that element? but i can press on keyboard manually after tap to the field.
I recommend reading the official documentation first: http://serhatbolsu.github.io/robotframework-appiumlibrary/AppiumLibrary.html and the user guide as well: https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html
Press Keys is not a keyword from AppiumLibrary. It's a keyword from SeleniumLibrary (https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Press%20Keys), but you're not importing it to your project. And even if you imported it, this keyword takes two arguments (locator and keys), so you need to use it correctly.
*** Test Cases ***
Press Keys a
In addition to what I've said, there's no test case name, this is incorrect and won't work, it will in fact give you the following error:
Test case name cannot be empty.
You have correctly used Input Test keyword from AppiumLibrary. However, you might need to validate that your locator is correct. We can't say that since you didn't include that information in your question.
I have used another method. Adb shell input text to fire the text
I have a text file that contains some basic passwords and some variants of those basic passwords. They are typed out together like this:
qwerty, qwerty1
password, password1
default, default 1
123, 12345, 123456
I am trying to take these values and split them, storing them in a tuple and then print out the values as 'Password' and then any variants, but I am getting a syntax error on the print BIF? (I am aware this will not print out the password '123456', I am just trying to solve the syntax error first.)
for each_line in passwords:
(passwd, passwd_variant) = each_line.split(',',1)
print(f'Password: {passwd}, Variant {passwd_variant}')
SyntaxError: invalid syntax
normally if I was writing a script, in the editor I would put print on a new line, however a new line in IDLE simply executes the code above it. is there a shortcut or something to do a carriage return and write the print statement on a new line and if so, is that the cause of the syntax error and why?
Cheers
EDIT: I would like my output to be this
Finally discovered that you need to hit Enter after the for in statement, this will then take you to a new line inside for in statement. Was up all night trying to work it out, maybe my fresh brain helped this morning.
I am using the functory module and I am facing a very bizarre issue with the code.
My code is working fine and I have been able to parallelized a play on my game but when I try to play once again (launch another time a parallelized function) it raises a really weird error.
Here you can find the error :
Fatal error: exception Unix.Unix_error(43, "write", "")
Raised by primitive operation at file "unix.ml", line 252, characters 7-34
Called from file "protocol.ml", line 45, characters 10-32
Re-raised at file "network.ml", line 536, characters 10-11
Called from file "network.ml", line 565, characters 47-80
Called from file "list.ml", line 73, characters 12-15
Called from file "network.ml", line 731, characters 4-27
Called from file "map_fold.ml", line 98, characters 4-242
Called from file "game_ia.ml", line 111, characters 10-54
Called from file "gameplay.ml", line 34, characters 12-48
Called from file "gameplay.ml", line 57, characters 22-37
Called from file "gameplay.ml", line 85, characters 5-22
So I've decided to search in the following folders to see what primitive operation has been raised :
(unix.ml) external rename : string -> string -> unit = "unix_rename"
(network.ml) Some jid when w.state <> Disconnected -> send w (Protocol.Master.Kill jid)
So for some reason, it seems that my worker disconnects by itself. I was wondering if any of you already had this issue and what to do in order to solve it ?
You can find my game here. The main files involved are game_ia.ml (best_move_parallelized) and gameplay.ml (at the very bottom).
Thank you in advance for your help.
The error you get is (type the following in the toploop)¹:
# (Obj.magic 43: Unix.error);;
- : Unix.error = Unix.EPROTOTYPE
which means: Protocol wrong type for socket. So you have to examine how you initialize your socket.
¹ You can also count the exceptions in unix.mli, knowing that the first one, E2BIG, is 0. Emacs C-u 43 ↓ helps.
In QT-creator I am getting the following error:
ASSERT failure in QVector::operator[]: "index out of range", file c:\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtCore/qvector.h, line 359
My problem is that it does not specify which QVector is out of range... Even when I run in debug mode I cannot find the location of the error. Is there a way to easily find the error? The code is quite huge and the error only pops up every once in a while so it would be a lot of work to check every qVector I use separately.
Assuming you are using Qt Creator, there is a "Stack" window which shows the function calls which led to the point where your program stopped:
In that window, double click the first file which you know is your own file, in that screenshot it is main.cpp in line 5. The file will open and a yellow arrow will be shown. The line which caused the assertion is the line above that yellow arrow (That arrow actually points to the next statement which would have been executed)
I am using / fixing collective.logbook to save errors on the site. Currently logbook fails on my site on some exceptions:
File "/srv/plone/xxx/src/collective.logbook/collective/logbook/events.py", line 101, in hand
transaction.commit()
File "/srv/plone/buildout-cache/eggs/transaction-1.1.1-py2.6.egg/transaction/_manager.py", line 8
return self.get().commit()
File "/srv/plone/buildout-cache/eggs/transaction-1.1.1-py2.6.egg/transaction/_transaction.py", li
self._commitResources()
File "/srv/plone/buildout-cache/eggs/transaction-1.1.1-py2.6.egg/transaction/_transaction.py", li
rm.commit(self)
File "/srv/plone/buildout-cache/eggs/ZODB3-3.10.5-py2.6-linux-x86_64.egg/ZODB/Connection.py", lin
self._commit(transaction)
File "/srv/plone/buildout-cache/eggs/ZODB3-3.10.5-py2.6-linux-x86_64.egg/ZODB/Connection.py", lin
self._store_objects(ObjectWriter(obj), transaction)
File "/srv/plone/buildout-cache/eggs/ZODB3-3.10.5-py2.6-linux-x86_64.egg/ZODB/Connection.py", lin
p = writer.serialize(obj) # This calls __getstate__ of obj
File "/srv/plone/buildout-cache/eggs/ZODB3-3.10.5-py2.6-linux-x86_64.egg/ZODB/serialize.py", line
return self._dump(meta, obj.__getstate__())
File "/srv/plone/buildout-cache/eggs/ZODB3-3.10.5-py2.6-linux-x86_64.egg/ZODB/serialize.py", line
self._p.dump(state)
TypeError: Can't pickle objects in acquisition wrappers.
This is obviously because logbook tries to write a record of the error which refers to an acquired object. I assume that the solution is to clean the error from these kind of objects.
However, how can I figure out what is the bad object, how it ends up to the transaction manager and what are the Python object references causing this issue? Or anything which could help me to debug this issue?
If you can reproduce this reliably, you can put in a print statement or pdb.set_trace() in the ZODB connection _register method (in ZODB/connection.py inside the ZODB egg):
def _register(self, obj=None):
# ... skipped lines ...
if obj is not None:
self._registered_objects.append(obj)
# Insert print statement here.
Now whenever any object has been marked as changed or is added to the connection as a new object, it'll be printed to the console. That should help you with the debugging process. Good luck!