From c73ced9a4db287cad50cd6ed244a874147722242 Mon Sep 17 00:00:00 2001 From: abhay malik Date: Sun, 19 Jan 2020 21:55:36 +0800 Subject: [PATCH 1/7] Port to python3 --- activity.py | 2 +- activity/activity.info | 2 +- reflectwindow.py | 2 +- utils.py | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/activity.py b/activity.py index 79c8455..e5c6780 100644 --- a/activity.py +++ b/activity.py @@ -13,7 +13,7 @@ import os import shutil import time -from ConfigParser import ConfigParser +from configparser import ConfigParser import json from gettext import gettext as _ diff --git a/activity/activity.info b/activity/activity.info index eae5519..0d1b7d2 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -1,6 +1,6 @@ [Activity] name = Reflect -exec = sugar-activity activity.ReflectActivity +exec = sugar-activity3 activity.ReflectActivity bundle_id = org.sugarlabs.Reflect icon = reflect activity_version = 1.0 diff --git a/reflectwindow.py b/reflectwindow.py index 4650de6..480c072 100644 --- a/reflectwindow.py +++ b/reflectwindow.py @@ -713,7 +713,7 @@ def _choose_activity(self): bundle_icons = utils.get_bundle_icons() x = 0 y = 1 - for bundle_id in bundle_icons.keys(): + for bundle_id in list(bundle_icons.keys()): icon_path = bundle_icons[bundle_id] if icon_path is None: continue diff --git a/utils.py b/utils.py index a52649a..9487398 100644 --- a/utils.py +++ b/utils.py @@ -17,14 +17,14 @@ import stat import statvfs import glob -import urllib +import urllib.request, urllib.parse, urllib.error from random import uniform import tempfile import cairo import email.utils import re import time -from ConfigParser import ConfigParser +from configparser import ConfigParser from gi.repository import Vte from gi.repository import Gio @@ -360,7 +360,7 @@ def check_volume_suffix(volume_file): return TRAINING_DATA % volume_file[-13:] elif volume_file.endswith('.bin'): # See SEP-33 new_volume_file = volume_file[:-4] + TRAINING_SUFFIX - print new_volume_file + print(new_volume_file) os.rename(volume_file, new_volume_file) _logger.debug('return %s' % (TRAINING_DATA % new_volume_file[-13:])) return TRAINING_DATA % new_volume_file[-13:] @@ -534,7 +534,7 @@ def is_landscape(): def get_safe_text(text): - return urllib.pathname2url(text.encode('ascii', 'xmlcharrefreplace')) + return urllib.request.pathname2url(text.encode('ascii', 'xmlcharrefreplace')) def get_battery_level(): @@ -1095,7 +1095,7 @@ def uitree_dump(): try: return json.loads(dbus.Interface(proxy, _DBUS_SERVICE).Dump()) except Exception as e: - print ('ERROR calling Dump: %s' % e) + print(('ERROR calling Dump: %s' % e)) # _logger.error('ERROR calling Dump: %s' % e) return '' From 410ab55cf11f84e389e7decb5d3d5d6cca7e493e Mon Sep 17 00:00:00 2001 From: Abhay-dot <55094435+Abhay-dot@users.noreply.github.com> Date: Mon, 20 Jan 2020 06:57:10 +0800 Subject: [PATCH 2/7] Update utils.py --- utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.py b/utils.py index 9487398..94798fa 100644 --- a/utils.py +++ b/utils.py @@ -1095,7 +1095,7 @@ def uitree_dump(): try: return json.loads(dbus.Interface(proxy, _DBUS_SERVICE).Dump()) except Exception as e: - print(('ERROR calling Dump: %s' % e)) + print('ERROR calling Dump: %s' % e) # _logger.error('ERROR calling Dump: %s' % e) return '' From 1ecf775c86422a7d9ec5ae248580ec72e43f6da6 Mon Sep 17 00:00:00 2001 From: abhay malik Date: Tue, 21 Jan 2020 23:36:03 +0800 Subject: [PATCH 3/7] Updated Telepathy --- activity.py | 2 +- textchannelwrapper.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/activity.py b/activity.py index e5c6780..3a04b9e 100644 --- a/activity.py +++ b/activity.py @@ -42,7 +42,7 @@ from sugar3 import profile from sugar3.datastore import datastore -import telepathy +from gi.repository import TelepathyGLib import dbus from dbus.service import signal from dbus.gobject_service import ExportedGObject diff --git a/textchannelwrapper.py b/textchannelwrapper.py index a4c3fec..05ca567 100644 --- a/textchannelwrapper.py +++ b/textchannelwrapper.py @@ -68,7 +68,6 @@ def __message_cb(self, collab, buddy, message): CHANNEL_TYPE_TEXT, \ CHANNEL_TYPE_FILE_TRANSFER, \ CONN_INTERFACE_ALIASING, \ - CHANNEL, \ CLIENT from telepathy.constants import \ CHANNEL_GROUP_FLAG_CHANNEL_SPECIFIC_HANDLES, \ @@ -89,7 +88,7 @@ def __message_cb(self, collab, buddy, message): ACTION_INIT_REQUEST = '!!ACTION_INIT_REQUEST' ACTION_INIT_RESPONSE = '!!ACTION_INIT_RESPONSE' ACTIVITY_FT_MIME = 'x-sugar/from-activity' - +CHANNEL = TelepathyGLib.IFACE_CHANNEL class CollabWrapper(GObject.GObject): ''' From c3d9c043eef45f5c58ee2304336dea7f3491c768 Mon Sep 17 00:00:00 2001 From: Abhay-dot <55094435+Abhay-dot@users.noreply.github.com> Date: Fri, 24 Jan 2020 00:47:57 +0800 Subject: [PATCH 4/7] Update activity.py --- activity.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/activity.py b/activity.py index 3a04b9e..1ffec36 100644 --- a/activity.py +++ b/activity.py @@ -734,11 +734,11 @@ def _shared_cb(self, activity): self.tubes_chan = self.shared_activity.telepathy_tubes_chan self.text_chan = self.shared_activity.telepathy_text_chan - self.tubes_chan[telepathy.CHANNEL_TYPE_TUBES].connect_to_signal( + self.tubes_chan[TelepathyGLib.IFACE_CHANNEL_TYPE_TUBES].connect_to_signal( 'NewTube', self._new_tube_cb) _logger.debug('This is my activity: making a tube...') - self.tubes_chan[telepathy.CHANNEL_TYPE_TUBES].OfferDBusTube( + self.tubes_chan[TelepathyGLib.IFACE_CHANNEL_TYPE_TUBES].OfferDBusTube( SERVICE, {}) self.sharing = True @@ -762,11 +762,11 @@ def _joined_cb(self, activity): self.tubes_chan = self.shared_activity.telepathy_tubes_chan self.text_chan = self.shared_activity.telepathy_text_chan - self.tubes_chan[telepathy.CHANNEL_TYPE_TUBES].connect_to_signal( + self.tubes_chan[TelepathyGLib.IFACE_CHANNEL_TYPE_TUBES].connect_to_signal( 'NewTube', self._new_tube_cb) _logger.debug('I am joining an activity: waiting for a tube...') - self.tubes_chan[telepathy.CHANNEL_TYPE_TUBES].ListTubes( + self.tubes_chan[TelepathyGLib.IFACE_CHANNEL_TYPE_TUBES].ListTubes( reply_handler=self._list_tubes_reply_cb, error_handler=self._list_tubes_error_cb) @@ -790,7 +790,7 @@ def _new_tube_cb(self, id, initiator, type, service, params, state): if (type == telepathy.TUBE_TYPE_DBUS and service == SERVICE): if state == telepathy.TUBE_STATE_LOCAL_PENDING: self.tubes_chan[ - telepathy.CHANNEL_TYPE_TUBES].AcceptDBusTube(id) + TelepathyGLib.IFACE_CHANNEL_TYPE_TUBES].AcceptDBusTube(id) self.collab = CollabWrapper(self) self.collab.message.connect(self.event_received_cb) From 5c16c595b6502c4d3e5528ea9b0e36d5558eda39 Mon Sep 17 00:00:00 2001 From: Abhay-dot <55094435+Abhay-dot@users.noreply.github.com> Date: Fri, 24 Jan 2020 12:07:50 +0800 Subject: [PATCH 5/7] Update activity.py --- activity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activity.py b/activity.py index 1ffec36..740f9f7 100644 --- a/activity.py +++ b/activity.py @@ -42,7 +42,7 @@ from sugar3 import profile from sugar3.datastore import datastore -from gi.repository import TelepathyGLib +from dbus.gi_service import TelepathyGLib import dbus from dbus.service import signal from dbus.gobject_service import ExportedGObject From a53445d7f6f3adf5f7f606ecce0ab1468b5b561e Mon Sep 17 00:00:00 2001 From: Abhay-dot <55094435+Abhay-dot@users.noreply.github.com> Date: Fri, 24 Jan 2020 12:12:51 +0800 Subject: [PATCH 6/7] Update reflectwindow.py --- reflectwindow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reflectwindow.py b/reflectwindow.py index 480c072..4650de6 100644 --- a/reflectwindow.py +++ b/reflectwindow.py @@ -713,7 +713,7 @@ def _choose_activity(self): bundle_icons = utils.get_bundle_icons() x = 0 y = 1 - for bundle_id in list(bundle_icons.keys()): + for bundle_id in bundle_icons.keys(): icon_path = bundle_icons[bundle_id] if icon_path is None: continue From c4c6802a6663056d29f2094779fc6f838ebb9d86 Mon Sep 17 00:00:00 2001 From: Abhay-dot <55094435+Abhay-dot@users.noreply.github.com> Date: Fri, 24 Jan 2020 14:47:51 +0800 Subject: [PATCH 7/7] Update activity.py --- activity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activity.py b/activity.py index 740f9f7..584a492 100644 --- a/activity.py +++ b/activity.py @@ -45,7 +45,7 @@ from dbus.gi_service import TelepathyGLib import dbus from dbus.service import signal -from dbus.gobject_service import ExportedGObject +from dbus.gi_service import ExportedGObject from sugar3.presence import presenceservice from sugar3.graphics.objectchooser import ObjectChooser