The Wayback Machine - https://web.archive.org/web/20201029012124/https://github.com/sugarlabs/dimensions/pull/16
Skip to content
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

Python3 port #16

Open
wants to merge 25 commits into
base: master
from
Open

Python3 port #16

wants to merge 25 commits into from

Conversation

@chimosky
Copy link
Member

@chimosky chimosky commented Feb 12, 2020

Made some changes.

TODO

  • Fix source_remove warning.
  • Fix collaboration - i think it was broken before this PR -

@tchx84 If the port to collabwrapper can be omitted, then this shoul finish quickly

@srevinsaju I think you meant collaboration as collabwrapper isn't used in the activity.

@tchx84 @walterbender

pidddgy and others added 4 commits Jan 5, 2020
* run 2to3
* Use property decorator

Signed-off-by: Ibiam Chihurumnaya <ibiamchihurumnaya@gmail.com>
Signed-off-by: Ibiam Chihurumnaya <ibiamchihurumnaya@gmail.com>
Signed-off-by: Ibiam Chihurumnaya <ibiamchihurumnaya@gmail.com>
@chimosky chimosky mentioned this pull request Feb 12, 2020
Dimensions.py Outdated Show resolved Hide resolved
cairoplot/cairoplot.py Outdated Show resolved Hide resolved
cairoplot/cairoplot.py Outdated Show resolved Hide resolved
cairoplot/series.py Outdated Show resolved Hide resolved
cairoplot/tests.py Outdated Show resolved Hide resolved
sprites.py Outdated Show resolved Hide resolved
chimosky and others added 5 commits Feb 15, 2020
Remove duplicate condition

Signed-off-by: Ibiam Chihurumnaya <ibiamchihurumnaya@gmail.com>
Signed-off-by: Ibiam Chihurumnaya <ibiamchihurumnaya@gmail.com>
In 4f5a9e6 ("add a mechanism for see chart of high score") cairoplot was
copied into the source tree and changed to improve appearance.

In fdff3f9 ("Update cairoplot") these changes were lost.

Re-apply the changes.
In fb29cc9 ("use thicker line for plot") changes were made to improve
appearance.

In fdff3f9 ("Update cairoplot") these changes were lost.

Re-apply the changes.
As the source code for CairoPlot is maintained elsewhere, let's minimise
the change between them and us.  This will ease maintenance of our
changes and let us apply any future patches from upstream.
@quozl
Copy link
Contributor

@quozl quozl commented Feb 16, 2020

Thanks. Reviewed. Some patches added. Briefly tested. Waiting for you to proceed with or update your TODO in opening comment.

@quozl
Copy link
Contributor

@quozl quozl commented Feb 16, 2020

@ayushnawal, please test and review, thanks.

cairoplot/seriestests.py Outdated Show resolved Hide resolved
@chimosky
Copy link
Member Author

@chimosky chimosky commented Feb 17, 2020

Tested, reviewed.

I agree with caa381a, thanks.

Upstream doesn't have this syntax.

Reported-by: Ibiam Chihurumnaya <ibiamchihurumnaya@gmail.com>
Copy link

@ayushnawal ayushnawal left a comment

Thanks. Reviewed.

@chimosky Got this in logs while testing:

Traceback (most recent call last):
File "/home/ayush/activities/dimensions/Dimensions.py", line 465, in _robot_selection_cb
state=self._robot_palette.SECONDARY)
AttributeError: 'Palette' object has no attribute 'SECONDARY'

Maybe not because of your changes 😅

Reviewed TO DO in the first comment too.

Fixed source_remove warnings in #17

@quozl, please review

@quozl
Copy link
Contributor

@quozl quozl commented Feb 17, 2020

Regarding the AttributeError;

Same broken code pattern also still used in Fototoon, GetBooks, Memorize, Speak, and Chess.

Reported-by: ayush nawal <ayushnawal457@gmail.com>
@ayushnawal
Copy link

@ayushnawal ayushnawal commented Feb 17, 2020

@quozl Thanks, will review and test it again.

Please see #17 also 😁

Co-authored-by: James Cameron <quozl@laptop.org>  # rebase on python3-port
@quozl
Copy link
Contributor

@quozl quozl commented Feb 17, 2020

Regarding #17 the commit 4da7b31 can't be easily cherry-picked because it is based on much older commit;

$ git fetch origin pull/17/head
$ git cherry-pick 4da7b31473813098e21cc2497d5613ebf53d60b1
error: could not apply 4da7b31... Fix source_remove warnings
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
$ git diff

In turn this is because this pull-request has changed from GObject to GLib for those calls.

$ git diff
@@@ -610,8 -610,9 +625,14 @@@
          self.total_time = 0
          self._edit_card = None
          self._dead_key = None
++<<<<<<< HEAD
 +        if hasattr(self, 'timeout_id') and self.timeout_id:
 +            GLib.source_remove(self.timeout_id)
++=======
+         if hasattr(self, 'timeout_id') and self.timeout_id is not None:
+             GObject.source_remove(self.timeout_id)
+             self.timeout_id = None 
++>>>>>>> 4da7b31... Fix source_remove warnings
  
          # Fill the grid with custom cards.
          self.grid.restore(self.deck, CUSTOM_CARD_INDICIES)

When you want to contribute to an existing pull-request like this, please base your branch on the latest commit in the pull-request.

This conflict means the two pull-requests are also in conflict, so when we merge this one you'll have to rebase yours.

So I rebased as 315b67c.

@quozl
Copy link
Contributor

@quozl quozl commented Feb 17, 2020

Our new focus on the use of timeouts made me review them in general. I suggest others review too.

  • there's no need to check with hasattr if the variable is always defined,
  • the __init__ function is the best place to define variables that will always be present,

Also I noticed the improper use of the set_cursor method; current versions of GTK do not flush the cursor change to the display automatically, so the busy cursor won't be seen; we added busy to the Activity class to fix this.

@ayushnawal
Copy link

@ayushnawal ayushnawal commented Feb 17, 2020

When you want to contribute to an existing pull-request like this, please base your branch on the latest commit in the pull-request.

Got it sir, will rebase from next time. your experience helps me learn 😁

Reviewed and Tested the PR again after the last 2 commits, no warnings or error.

@chimosky
Copy link
Member Author

@chimosky chimosky commented Feb 18, 2020

  • there's no need to check with hasattr if the variable is always defined,

I agree, thought of removing them but I decided to focus on other things.

  • the init function is the best place to define variables that will always be present,

Agreed.

Tested 315b67c and it doesn't fix source_remove warnings, tracing the calls show that source_remove for some reason is called before any timeout_add calls.

quozl added 4 commits Feb 18, 2020
* move timeout source IDs to __init__,

* remove hasattr calls.
* use an underscore prefix,

* shorten the name to remove timeout, as they are actually source IDs
  for timeouts,
After changing the variable names, code was excessively wrapped.
Several opportunities existed for timeout IDs not to be cleared despite
the timeout having been removed from the list of sources by implied
"return False".

Proposed as a fix for source_remove warnings.

Reported-by: Chihurumnaya Ibiam <ibiamchihurumnaya@gmail.com>
@quozl
Copy link
Contributor

@quozl quozl commented Feb 18, 2020

Thanks for testing. I took a close look, and there were certainly ways in which the timeout source IDs were not cleared despite the source having been automatically removed. 5cea479.

@quozl
Copy link
Contributor

@quozl quozl commented Feb 18, 2020

Tested. Added a few more commits based on observations.

@chimosky
Copy link
Member Author

@chimosky chimosky commented Feb 18, 2020

Tested 7291292, source_remove warnings are gone.
In master, clicking on a card in the card box returns it back to a different position but that doesn't happen anymore and logs show nothing.

On code review of aggregate change, it was seen that the source ID
assigned on line 1437 is immediately destroyed by the assignment on line
1443.

Effect unknown.
@quozl
Copy link
Contributor

@quozl quozl commented Feb 18, 2020

In master, clicking on a card in the card box returns it back to a different position but that doesn't happen anymore and logs show nothing.

Thanks for testing. I don't know quite what you mean; can you explain how to reproduce? Or can you do a git bisect to find which commit made this change?

I did review the aggregate change again and spotted a mistake, fixed in 2948f82. I don't know if it relates to what you saw.

@chimosky
Copy link
Member Author

@chimosky chimosky commented Feb 19, 2020

Thanks for testing. I don't know quite what you mean; can you explain how to reproduce?

  • Open activity, select any category to play.
  • Select cards and they'll glide to card box below.
  • At c9ba20e, clicking on the first two cards in the card boxes below returns them back to the other
    cards.

I think the error was introduced at 06f0162 as this behaviour is no longer noticed there.

@quozl
Copy link
Contributor

@quozl quozl commented Feb 19, 2020

Thanks.

I've reviewed 06f0162 again. The CairoPlot changes can be ignored as the problem is unrelated to the plotting. None of the other changes seem likely to affect the decision-making of the program.

I've tested 2948f82 and reproduced a behaviour almost the same as what you report; the left-most card in the boxes can be returned, but not the centre card. The right-most card can never be returned because the win or loss sequence blocks it.

Also, I'm not sure if the method of selecting the cards is significant; I've only just discovered they can be dragged.

@chimosky
Copy link
Member Author

@chimosky chimosky commented Feb 19, 2020

I've tested 2948f82 and reproduced a behaviour almost the same as what you report; the left-most card in the boxes can be returned, but not the centre card. The right-most card can never be returned because the win or loss sequence blocks it.

Yeah, edited my comment accordingly.

Also, I'm not sure if the method of selecting the cards is significant; I've only just discovered they can be dragged.

No the method of selecting the cards isn't significant - just discovered they can be dragged too -, just clicking on them in the card boxes are.
The earlier source_remove - the ones fixed at 5cea479 - warnings were reported as a result of these clicks.

@quozl
Copy link
Contributor

@quozl quozl commented Feb 19, 2020

A git bisect shows f1dfbdd is rearrangement of the match box to be underneath the grid.

A git bisect shows 06f0162 causes the card grid to be misaligned; instead of in rows and columns, the cards are in diagonals.

  • fix the grid misalignment.
Signed-off-by: Ibiam Chihurumnaya <ibiamchihurumnaya@gmail.com>
@chimosky
Copy link
Member Author

@chimosky chimosky commented Apr 8, 2020

@quozl kindly review.

  • fix grid misalignment.
@srevinsaju
Copy link
Member

@srevinsaju srevinsaju commented Apr 9, 2020

#19. There was a excess print() statement, which I demoted to logger. Please review and merge

@quozl
Copy link
Contributor

@quozl quozl commented Apr 9, 2020

@chimosky: Thanks. Tested. Fixed XML parse error. Please continue.

On Ubuntu 20.04 with librsvg 2.48.0 the activity hangs and logs contain;

Traceback (most recent call last):
  File "/usr/share/sugar/activities/Dimensions.activity/game.py", line 514, in _prepare_new_game
    self.deck.create(self._sprites, self.card_type,
  File "/usr/share/sugar/activities/Dimensions.activity/deck.py", line 85, in create
    i = self._make(sprites, card_type, numbers_type, i,
  File "/usr/share/sugar/activities/Dimensions.activity/deck.py", line 138, in _make
    self.cards[i].create(
  File "/usr/share/sugar/activities/Dimensions.activity/card.py", line 45, in create
    self.spr = Sprite(sprites, 0, 0, svg_str_to_pixbuf(string, True))
  File "/usr/share/sugar/activities/Dimensions.activity/card.py", line 69, in svg_str_to_pixbuf
    pl.close()
gi.repository.GLib.Error: rsvg-error-quark: XML parse error: error code=201 (3) in (null):25:2: Namespace prefix xlink for href on image is not defined

librsvg 2.47.0 introduced stricter namespaces in the XML parser,
https://gitlab.gnome.org/GNOME/librsvg/-/blob/master/NEWS#L67

so add namespace declarations.
@chimosky chimosky force-pushed the python3-port branch from c7ce933 to b089ce9 Apr 9, 2020
Remove use of ChatTube and use collabwrapper for collaboration,
game state is shared but each instance is playing as one player
and card type differs when activity is shared.

Signed-off-by: Ibiam Chihurumnaya <ibiamchihurumnaya@gmail.com>
@chimosky
Copy link
Member Author

@chimosky chimosky commented May 23, 2020

TODO

  • Fix source_remove warning.
  • Fix collaboration - i think it was broken before this PR
  • Fix turn in activity, at the moment game state is shared but both instances share the same player.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants
You can’t perform that action at this time.