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

Port to python3 #13

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions activity.py
Expand Up @@ -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 _

Expand Down Expand Up @@ -42,10 +42,10 @@
from sugar3 import profile
from sugar3.datastore import datastore

import telepathy
from dbus.gi_service import TelepathyGLib
import dbus
from dbus.service import signal
Abhay-dot marked this conversation as resolved.
Show resolved Hide resolved
from dbus.gobject_service import ExportedGObject
from dbus.gi_service import ExportedGObject
from sugar3.presence import presenceservice
from sugar3.graphics.objectchooser import ObjectChooser

Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down
3 changes: 1 addition & 2 deletions textchannelwrapper.py
Expand Up @@ -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, \
Expand All @@ -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):
'''
Expand Down
10 changes: 5 additions & 5 deletions utils.py
Expand Up @@ -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
Expand Down Expand Up @@ -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:]
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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 ''

Expand Down