Skip to content

Detect python2 activities#1048

Open
mohithshuka wants to merge 4 commits intosugarlabs:masterfrom
mohithshuka:detect-python2-activities
Open

Detect python2 activities#1048
mohithshuka wants to merge 4 commits intosugarlabs:masterfrom
mohithshuka:detect-python2-activities

Conversation

@mohithshuka
Copy link
Copy Markdown

Description

This PR implements detection and warning for Python 2 activities attempting to run on Python 3 Sugar systems.

Problem

Fixes #991 - Sugar on Python 3 platforms does not detect Python 2 activities. These activities install successfully but fail to start with no error messages in logs, creating a confusing user experience.

Solution

  • Added _is_python2_activity() helper function to identify Python 2 activities by checking the exec command in their activity.info file
  • Modified the launch() function in src/jarabe/journal/misc.py to check for Python 2 activities before attempting to launch
  • Display a clear, user-friendly alert dialog explaining the incompatibility
  • Log appropriate error messages for troubleshooting
  • Prevent silent failures by blocking launch attempts

Technical Details

Python 2 activities are identified by their command field:

  • Python 2: exec = sugar-activity (without '3' suffix)
  • Python 3: exec = sugar-activity3 or exec = sugar-activity-web

The detection happens in the launch() function which is called from multiple places including:

  • src/jarabe/journal/bundlelauncher.py
  • src/jarabe/desktop/favoritesview.py
  • src/jarabe/journal/journalactivity.py

Changes Made

File modified: src/jarabe/journal/misc.py

  • Added _is_python2_activity() helper function (lines 51-70)
  • Added Python 2 detection in launch() function (lines 284-302)

Testing

To test this fix:

  1. Attempt to launch a Python 2 activity (one with exec = sugar-activity in activity.info)
  2. Verify that a clear error dialog appears with the message "Python 2 Activity Not Supported"
  3. Check that the error is logged: "Cannot launch Python 2 activity: [name]"
  4. Confirm Python 3 activities still launch normally

Benefits

  • Users get clear feedback instead of silent failures
  • Error messages are logged for troubleshooting
  • Helps users understand why certain activities don't work
  • Encourages migration to Python 3 activities

…closes

When running Sugar from a terminal and the window is closed, the
terminal sends a SIGHUP signal. This change adds a signal handler
for both SIGHUP and SIGTERM that calls Gtk.main_quit() to ensure
Sugar exits cleanly.

The handler is registered after desktop startup begins and before
entering the GTK main loop.
- Add _is_python2_activity() helper function to detect Python 2 activities
- Check activity command in launch() function before attempting to start
- Display user-friendly alert dialog explaining incompatibility
- Log error message when Python 2 activity launch is attempted
- Prevent silent failures by blocking launch of incompatible activities

Python 2 activities are identified by their use of 'sugar-activity'
command (without '3' suffix), as opposed to Python 3 activities which
use 'sugar-activity3' or 'sugar-activity-web'.

Fixes sugarlabs#991
Copy link
Copy Markdown
Member

@chimosky chimosky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed, not tested.

@mohithshuka mohithshuka reopened this Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detect Python 2 activities

2 participants