-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editing the game doesn't work, activity gets stuck #29
Comments
Some of the errors may not be relevant to the problem. This one may be explained away;
It may occur if the system is momentarily not connected to a network, as can happen if the network cable, wireless network, or virtual network is interrupted. This in turn may occur due to suspend and resume during a lid close, carry, lid open sequence. As I've reproduced it independently of Memorize, I've moved it to sugarlabs/sugar-toolkit-gtk3#450. |
Investigating I've found that some of the dictionary values used to store the card's data have Boolean values instead of String. Skipping those values entirely somewhat fixes saving in the Datastore, I'll try converting them to String and check. |
Changing the Boolean False values to empty strings before writing to an .XML file for key in self.pairs:
pair_props = {}
if self.pairs[key].props.aimg is not None:
pair_props["aimg"] = self.pairs[key].props.aimg
if self.pairs[key].props.asnd is not None:
pair_props["asnd"] = self.pairs[key].props.asnd
if self.pairs[key].props.achar is not None:
pair_props["achar"] = self.pairs[key].props.achar
if self.pairs[key].props.bimg is not None:
pair_props["bimg"] = self.pairs[key].props.bimg
if self.pairs[key].props.bsnd is not None:
pair_props["bsnd"] = self.pairs[key].props.bsnd
if self.pairs[key].props.bchar is not None:
pair_props["bchar"] = self.pairs[key].props.bchar
if self.pairs[key].props.aspeak is not None:
pair_props["aspeak"] = self.pairs[key].props.aspeak
if self.pairs[key].props.bspeak is not None:
pair_props["bspeak"] = self.pairs[key].props.bspeak
SubElement(root, 'pair', pair_props) to arr = ["aimg", "asnd", "achar", "bimg", "bsnd", "bchar", "aspeak", "bspeak"]
for key in self.pairs:
pair_props = {}
for e in arr:
if self.pairs[key].get_property(e) is not None:
if self.pairs[key].get_property(e) is False:
pair_props[e] = ""
else:
pair_props[e] = self.pairs[key].get_property(e)
SubElement(root, 'pair', pair_props) This fixes the error and allows instances of the activity with modified cards to be saved to the Journal. |
@quozl if this is fine, I'll make a PR with the changes? |
I guess so, but not sure. I'd like to see it described in a pull request with a clear commit message. |
Caused due to presence of Boolean arguments (False) while writing to `game.xml`. If `speak` is not set, it defaults to `False` in set_speak() in `card.py`. The fix changes `False` to an empty String while writing to `game.xml`. Traceback: ``` 1594050507.412289 ERROR root: Error saving activity object to datastore Traceback (most recent call last): File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1076, in _escape_attrib if "&" in text: TypeError: argument of type 'bool' is not iterable During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/sugar3/activity/activity.py", line 1277, in _prepare_close self.save() File "/usr/lib/python3/dist-packages/sugar3/activity/activity.py", line 978, in save self.write_file(file_path) File "/usr/share/sugar/activities/Memorize.activity/activity.py", line 409, in write_file self.game.model.write() File "/usr/share/sugar/activities/Memorize.activity/model.py", line 357, in write xml_file.write(tostring(root)) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1133, in tostring ElementTree(element).write(stream, encoding, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 772, in write serialize(write, self._root, qnames, namespaces, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 937, in _serialize_xml _serialize_xml(write, e, qnames, None, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 930, in _serialize_xml v = _escape_attrib(v) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1099, in _escape_attrib _raise_serialization_error(text) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1053, in _raise_serialization_error raise TypeError( TypeError: cannot serialize False (type bool) ``` Fixes sugarlabs#29
Caused due to presence of Boolean arguments (False) while writing to `game.xml`. If `speak` is not set, it defaults to `False` in set_speak() in `card.py`. The fix changes `False` to an empty String while writing to `game.xml`. Traceback: ``` 1594050507.412289 ERROR root: Error saving activity object to datastore Traceback (most recent call last): File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1076, in _escape_attrib if "&" in text: TypeError: argument of type 'bool' is not iterable During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/sugar3/activity/activity.py", line 1277, in _prepare_close self.save() File "/usr/lib/python3/dist-packages/sugar3/activity/activity.py", line 978, in save self.write_file(file_path) File "/usr/share/sugar/activities/Memorize.activity/activity.py", line 409, in write_file self.game.model.write() File "/usr/share/sugar/activities/Memorize.activity/model.py", line 357, in write xml_file.write(tostring(root)) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1133, in tostring ElementTree(element).write(stream, encoding, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 772, in write serialize(write, self._root, qnames, namespaces, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 937, in _serialize_xml _serialize_xml(write, e, qnames, None, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 930, in _serialize_xml v = _escape_attrib(v) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1099, in _escape_attrib _raise_serialization_error(text) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1053, in _raise_serialization_error raise TypeError( TypeError: cannot serialize False (type bool) ``` Fixes sugarlabs#29
Caused due to presence of Boolean arguments (False) while writing to `game.xml`. If `speak` is not set, it defaults to `False` in set_speak() in `card.py`. The fix changes `False` to an empty String while writing to `game.xml`. Traceback: ``` 1594050507.412289 ERROR root: Error saving activity object to datastore Traceback (most recent call last): File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1076, in _escape_attrib if "&" in text: TypeError: argument of type 'bool' is not iterable During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/sugar3/activity/activity.py", line 1277, in _prepare_close self.save() File "/usr/lib/python3/dist-packages/sugar3/activity/activity.py", line 978, in save self.write_file(file_path) File "/usr/share/sugar/activities/Memorize.activity/activity.py", line 409, in write_file self.game.model.write() File "/usr/share/sugar/activities/Memorize.activity/model.py", line 357, in write xml_file.write(tostring(root)) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1133, in tostring ElementTree(element).write(stream, encoding, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 772, in write serialize(write, self._root, qnames, namespaces, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 937, in _serialize_xml _serialize_xml(write, e, qnames, None, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 930, in _serialize_xml v = _escape_attrib(v) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1099, in _escape_attrib _raise_serialization_error(text) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1053, in _raise_serialization_error raise TypeError( TypeError: cannot serialize False (type bool) ``` Fixes sugarlabs#29
Caused due to presence of Boolean arguments (False) while writing to `game.xml`. If `speak` is not set, it defaults to `False` in get_speak() in `card.py`. The fix changes `False` to an empty String while writing to `game.xml`. Traceback: ``` 1594050507.412289 ERROR root: Error saving activity object to datastore Traceback (most recent call last): File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1076, in _escape_attrib if "&" in text: TypeError: argument of type 'bool' is not iterable During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/sugar3/activity/activity.py", line 1277, in _prepare_close self.save() File "/usr/lib/python3/dist-packages/sugar3/activity/activity.py", line 978, in save self.write_file(file_path) File "/usr/share/sugar/activities/Memorize.activity/activity.py", line 409, in write_file self.game.model.write() File "/usr/share/sugar/activities/Memorize.activity/model.py", line 357, in write xml_file.write(tostring(root)) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1133, in tostring ElementTree(element).write(stream, encoding, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 772, in write serialize(write, self._root, qnames, namespaces, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 937, in _serialize_xml _serialize_xml(write, e, qnames, None, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 930, in _serialize_xml v = _escape_attrib(v) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1099, in _escape_attrib _raise_serialization_error(text) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1053, in _raise_serialization_error raise TypeError( TypeError: cannot serialize False (type bool) ``` Fixes sugarlabs#29
Caused due to presence of Boolean arguments (False) while writing to `game.xml`. If `speak` is not set, it defaults to `False` in get_speak() in `card.py`. The fix changes `False` to an empty String while writing to `game.xml`. Reproduce: Click 'Edit Game' -> Make changes eg.Toggle between grouped and matched tiles -> Click 'Play Game' Traceback: ``` 1594050507.412289 ERROR root: Error saving activity object to datastore Traceback (most recent call last): File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1076, in _escape_attrib if "&" in text: TypeError: argument of type 'bool' is not iterable During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/sugar3/activity/activity.py", line 1277, in _prepare_close self.save() File "/usr/lib/python3/dist-packages/sugar3/activity/activity.py", line 978, in save self.write_file(file_path) File "/usr/share/sugar/activities/Memorize.activity/activity.py", line 409, in write_file self.game.model.write() File "/usr/share/sugar/activities/Memorize.activity/model.py", line 357, in write xml_file.write(tostring(root)) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1133, in tostring ElementTree(element).write(stream, encoding, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 772, in write serialize(write, self._root, qnames, namespaces, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 937, in _serialize_xml _serialize_xml(write, e, qnames, None, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 930, in _serialize_xml v = _escape_attrib(v) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1099, in _escape_attrib _raise_serialization_error(text) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1053, in _raise_serialization_error raise TypeError( TypeError: cannot serialize False (type bool) ``` Fixes sugarlabs#29
Caused due to presence of Boolean arguments (False) while writing to `game.xml`. If `speak` is not set, it defaults to `False` in get_speak() in `card.py`. The fix changes `False` to an empty String while writing to `game.xml`. Reproduce: Click 'Edit Game' -> Make changes eg.Toggle between grouped and matched tiles -> Click 'Play Game' Traceback: ``` 1594050507.412289 ERROR root: Error saving activity object to datastore Traceback (most recent call last): File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1076, in _escape_attrib if "&" in text: TypeError: argument of type 'bool' is not iterable During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/sugar3/activity/activity.py", line 1277, in _prepare_close self.save() File "/usr/lib/python3/dist-packages/sugar3/activity/activity.py", line 978, in save self.write_file(file_path) File "/usr/share/sugar/activities/Memorize.activity/activity.py", line 409, in write_file self.game.model.write() File "/usr/share/sugar/activities/Memorize.activity/model.py", line 357, in write xml_file.write(tostring(root)) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1133, in tostring ElementTree(element).write(stream, encoding, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 772, in write serialize(write, self._root, qnames, namespaces, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 937, in _serialize_xml _serialize_xml(write, e, qnames, None, File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 930, in _serialize_xml v = _escape_attrib(v) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1099, in _escape_attrib _raise_serialization_error(text) File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1053, in _raise_serialization_error raise TypeError( TypeError: cannot serialize False (type bool) ``` Fixes #29
Tested on:
Sugar 0.117-3, Debian Bullseye
Sugar 0.117, Sugar Live Build
Reproduce:
Click 'Edit Game' ->
Click 'Match Identical Tiles'
and/orClick 'Mixed Tiles Game'
and/or3.Edit the cards and Click update
-> Click 'Play Game'Sometimes, Sugar freezes completely, cannot recover without rebooting. Most times, closing the activity fixes it.
Traceback:
The text was updated successfully, but these errors were encountered: