-
Notifications
You must be signed in to change notification settings - Fork 85
Detects Python 2 Activities_ fixes /sugar #991 #487
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,8 @@ | |
| import os | ||
| import subprocess | ||
|
|
||
|
|
||
|
|
||
| _SHELL_SERVICE = 'org.laptop.Shell' | ||
| _SHELL_PATH = '/org/laptop/Shell' | ||
| _SHELL_IFACE = 'org.laptop.Shell' | ||
|
|
@@ -217,25 +219,59 @@ def _create_activity(self): | |
| self._service_name, self._handle.activity_id, | ||
| reply_handler=self._no_reply_handler, | ||
| error_handler=self._notify_launch_error_handler) | ||
|
|
||
| environ = get_environment(self._bundle) | ||
| (log_path, log_file) = open_log_file(self._bundle) | ||
| command = get_command(self._bundle, self._handle.activity_id, | ||
| self._handle.object_id, self._handle.uri, | ||
| self._handle.invited) | ||
|
|
||
| dev_null = open('/dev/null', 'r') | ||
| child = subprocess.Popen([str(s) for s in command], | ||
| env=environ, | ||
| cwd=str(self._bundle.get_path()), | ||
| close_fds=True, | ||
| stdin=dev_null.fileno(), | ||
| stdout=log_file.fileno(), | ||
| stderr=log_file.fileno()) | ||
|
|
||
| GLib.child_watch_add(child.pid, | ||
| _child_watch_cb, | ||
| (log_file, self._handle.activity_id)) | ||
| try: | ||
| dev_null = open('/dev/null', 'r') | ||
| child = subprocess.Popen([str(s) for s in command], | ||
| env=environ, | ||
| cwd=str(self._bundle.get_path()), | ||
| close_fds=True, | ||
| stdin=dev_null.fileno(), | ||
| stdout=log_file.fileno(), | ||
| stderr=log_file.fileno()) | ||
|
|
||
| GLib.child_watch_add(child.pid, | ||
| _child_watch_cb, | ||
| (log_file, self._handle.activity_id)) | ||
|
|
||
| except FileNotFoundError as e: | ||
| if 'sugar-activity' in str(e): | ||
| log_file.write('Activity written for Python 2, needs to be ported to Python 3\n') | ||
| log_file.close() | ||
|
|
||
| from jarabe.model import shell | ||
| shell_model = shell.get_model() | ||
|
|
||
| if not hasattr(shell_model, '_python2_activity_check'): | ||
| shell_model._python2_activity_check = set() | ||
| shell_model._python2_activity_check.add(self._handle.activity_id) | ||
|
|
||
| bus = dbus.SessionBus() | ||
| bus_object = bus.get_object(_SHELL_SERVICE, _SHELL_PATH) | ||
| shell = dbus.Interface(bus_object, _SHELL_IFACE) | ||
|
|
||
| shell.NotifyLaunchFailure( | ||
| self._handle.activity_id, | ||
| reply_handler=self._no_reply_handler, | ||
| error_handler=self._notify_launch_failure_error_handler) | ||
|
|
||
| except Exception as e: | ||
| logging.error('Activity launch failed with error: %s', str(e)) | ||
|
|
||
| bus = dbus.SessionBus() | ||
| bus_object = bus.get_object(_SHELL_SERVICE, _SHELL_PATH) | ||
| shell = dbus.Interface(bus_object, _SHELL_IFACE) | ||
|
|
||
| shell.NotifyLaunchFailure( | ||
| self._handle.activity_id, | ||
| reply_handler=self._no_reply_handler, | ||
| error_handler=self._notify_launch_failure_error_handler) | ||
|
|
||
| def _no_reply_handler(self, *args): | ||
| pass | ||
|
|
@@ -345,4 +381,4 @@ def error_handler_cb(error): | |
| # main window, see http://bugs.sugarlabs.org/ticket/1447#comment:19 | ||
| shell.NotifyLaunchFailure(activity_id, | ||
| reply_handler=reply_handler_cb, | ||
| error_handler=error_handler_cb) | ||
| error_handler=error_handler_cb) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the No new line at EOF, you can do so with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also see if you can figure out how it happened; we don't want unnecessary changes, it consumes reviewing time, and makes |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An unnecessary change.