diff --git a/pylint.sh b/pylint.sh
new file mode 100755
index 00000000..99e9dada
--- /dev/null
+++ b/pylint.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# Errors that we may fix in the future
+#
+# C0301 Line length
+# W0603 Using the global statement
+# W0201 Attribute defined outside __init__
+# R0201 Method could be a function
+TODO="C0301,W0603,W0201,R0201"
+
+# Errors we don't like
+#
+# W0613 Unused argument (glib signals)
+# W0511 - FIXME/TODO/XXX
+DISABLE="W0613,W0511"
+
+MSGS="$TODO,$DISABLE"
+ARG="sugar"
+
+pylint \
+ --disable-all \
+ --include-ids=y \
+ --enable-variables=y \
+ --enable-exceptions=y \
+ --enable-miscellaneous=y \
+ --enable-format=y \
+ --enable-classes=y \
+ --disable-msg=$MSGS \
+ --reports=n \
+ --enable-metrics=n \
+ --indent-string=" " \
+ --ignore="SVGdraw.py" \
+ $ARG
diff --git a/sugar/browser/browser.py b/sugar/browser/browser.py
index 22007442..32a0ca1c 100755
--- a/sugar/browser/browser.py
+++ b/sugar/browser/browser.py
@@ -78,7 +78,7 @@ class AddressEntry(gtk.HBox):
return self.folded
def set_folded(self, folded):
- self.folded = not self.folded
+ self.folded = folded
self._update_folded_state()
def __button_clicked_cb(self, button):
@@ -253,7 +253,6 @@ class WebActivity(activity.Activity):
def activity_on_disconnected_from_shell(self):
gtk.main_quit()
- gc.collect()
class BrowserShell(dbus.service.Object):
instance = None
@@ -298,11 +297,7 @@ class BrowserShell(dbus.service.Object):
def main():
BrowserShell.get_instance().open_web_activity()
-
- try:
- gtk.main()
- except KeyboardInterrupt:
- pass
+ gtk.main()
-if __name__=="__main__":
- main()
+if __name__ == "__main__":
+ main()
diff --git a/sugar/chat/BuddyList.py b/sugar/chat/BuddyList.py
deleted file mode 100644
index d35fa847..00000000
--- a/sugar/chat/BuddyList.py
+++ /dev/null
@@ -1,121 +0,0 @@
-# -*- tab-width: 4; indent-tabs-mode: t -*-
-
-import presence
-import avahi
-
-ACTION_BUDDY_ADDED = "added"
-ACTION_BUDDY_REMOVED = "removed"
-
-
-class Buddy(object):
- def __init__(self, nick, realname, servicename, host, address, port, key=None):
- self._nick = nick
- self._realname = realname
- self._servicename = servicename
- self._key = key
- self._host = host
- self._address = str(address)
- self._port = int(port)
- self._chat = None
-
- def set_chat(self, chat):
- self._chat = chat
-
- def chat(self):
- return self._chat
-
- def nick(self):
- return self._nick
-
- def realname(self):
- return self._realname
-
- def servicename(self):
- return self._servicename
-
- def host(self):
- return self._host
-
- def address(self):
- return self._address
-
- def port(self):
- return self._port
-
- def key(self):
- return self._key
-
-class BuddyList(object):
- """ Manage a list of buddies """
-
- def __init__(self, servicename):
- self._listeners = []
- self._buddies = {}
- self._servicename = servicename
- self._pdiscovery = presence.PresenceDiscovery()
- self._pdiscovery.add_service_listener(self._on_service_change)
-
- def start(self):
- self._pdiscovery.start()
-
- def add_buddy_listener(self, listener):
- self._listeners.append(listener)
-
- def _add_buddy(self, host, address, port, servicename, data):
- # Ignore ourselves
- if servicename == self._servicename:
- return
-
- if len(data) > 0 and 'name' in data.keys():
- buddy = self._find_buddy_by_service_name(servicename)
- if not buddy:
- buddy = Buddy(data['name'], data['realname'], servicename, host, address, port)
- self._buddies[data['name']] = buddy
- self._notify_listeners(ACTION_BUDDY_ADDED, buddy)
-
- def _remove_buddy(self, buddy):
- nick = buddy.nick()
- self._notify_listeners(ACTION_BUDDY_REMOVED, buddy)
- del self._buddies[nick]
-
- def _find_buddy_by_service_name(self, servicename):
- for buddy in self._buddies.values():
- if buddy.servicename() == servicename:
- return buddy
- return None
-
- def find_buddy_by_address(self, address):
- for buddy_name in self._buddies.keys():
- buddy = self._buddies[buddy_name]
- if buddy.address() == address:
- return buddy
- return None
-
- def _notify_listeners(self, action, buddy):
- for listener in self._listeners:
- listener(action, buddy)
-
- def _on_service_change(self, action, interface, protocol, name, stype, domain, flags):
- if stype != presence.OLPC_CHAT_SERVICE:
- return
- if action == presence.ACTION_SERVICE_NEW:
- self._pdiscovery.resolve_service(interface, protocol, name, stype, domain, self._on_service_resolved)
- elif action == presence.ACTION_SERVICE_REMOVED:
- buddy = self._find_buddy_by_service_name(name)
- if buddy:
- self._remove_buddy(buddy)
-
- def _pair_to_dict(self, l):
- res = {}
- for el in l:
- tmp = el.split('=', 1)
- if len(tmp) > 1:
- res[tmp[0]] = tmp[1]
- else:
- res[tmp[0]] = ''
- return res
-
- def _on_service_resolved(self, interface, protocol, name, stype, domain, host, aprotocol, address, port, txt, flags):
- data = self._pair_to_dict(avahi.txt_array_to_string_array(txt))
- self._add_buddy(host, address, port, name, data)
-
diff --git a/sugar/chat/chat.py b/sugar/chat/chat.py
index 8be22314..fef2c838 100755
--- a/sugar/chat/chat.py
+++ b/sugar/chat/chat.py
@@ -10,9 +10,11 @@ pygtk.require('2.0')
import gtk, gobject
from sugar.shell import activity
-from sugar.p2p.Group import *
-from sugar.p2p.StreamReader import *
-from sugar.p2p.StreamWriter import *
+from sugar.p2p.Group import Group
+from sugar.p2p.Group import LocalGroup
+from sugar.p2p.Service import Service
+from sugar.p2p.StreamReader import StreamReader
+from sugar.p2p.StreamWriter import StreamWriter
import sugar.env
import richtext
@@ -71,14 +73,14 @@ class Chat(activity.Activity):
self._hbox = gtk.HBox(False, 12)
self._hbox.set_border_width(12)
- [chat_vbox, buffer] = self._create_chat()
+ [chat_vbox, buf] = self._create_chat()
self._hbox.pack_start(chat_vbox)
chat_vbox.show()
vbox.pack_start(self._hbox)
self._hbox.show()
- toolbar = self._create_toolbar(buffer)
+ toolbar = self._create_toolbar(buf)
vbox.pack_start(toolbar, False)
toolbar.show()
@@ -130,37 +132,37 @@ class Chat(activity.Activity):
button.set_menu(menu)
def activity_on_close_from_user(self):
- print "act %d: in activity_on_close_from_user"%self.activity_get_id()
+ print "act %d: in activity_on_close_from_user" % self.activity_get_id()
self.activity_shutdown()
def activity_on_lost_focus(self):
- print "act %d: in activity_on_lost_focus"%self.activity_get_id()
+ print "act %d: in activity_on_lost_focus" % self.activity_get_id()
def activity_on_got_focus(self):
- print "act %d: in activity_on_got_focus"%self.activity_get_id()
- self._controller.notify_activate(self)
+ print "act %d: in activity_on_got_focus" % self.activity_get_id()
+ # FIXME self._controller.notify_activate(self)
def recv_message(self, buddy, msg):
self._insert_rich_message(buddy.get_nick_name(), msg)
self._controller.notify_new_message(self, buddy)
def _insert_rich_message(self, nick, msg):
- buffer = self._chat_view.get_buffer()
- aniter = buffer.get_end_iter()
- buffer.insert(aniter, nick + ": ")
+ buf = self._chat_view.get_buffer()
+ aniter = buf.get_end_iter()
+ buf.insert(aniter, nick + ": ")
serializer = richtext.RichTextSerializer()
- serializer.deserialize(msg, buffer)
+ serializer.deserialize(msg, buf)
- aniter = buffer.get_end_iter()
- buffer.insert(aniter, "\n")
+ aniter = buf.get_end_iter()
+ buf.insert(aniter, "\n")
def _local_message(self, success, text):
if not success:
message = "Error: %s\n" % text
- buffer = self._chat_view.get_buffer()
- aniter = buffer.get_end_iter()
- buffer.insert(aniter, message)
+ buf = self._chat_view.get_buffer()
+ aniter = buf.get_end_iter()
+ buf.insert(aniter, message)
else:
owner = self._controller.get_group().get_owner()
self._insert_rich_message(owner.get_nick_name(), text)
@@ -325,11 +327,11 @@ class GroupChat(Chat):
if buddy.get_nick_name() == self._group.get_owner().get_nick_name():
# Do not show ourself in the buddy list
pass
- elif action == BUDDY_JOIN:
+ elif action == Group.BUDDY_JOIN:
aniter = self._buddy_list_model.append(None)
self._buddy_list_model.set(aniter, self._MODEL_COL_NICK, buddy.get_nick_name(),
self._MODEL_COL_ICON, None, self._MODEL_COL_BUDDY, buddy)
- elif action == BUDDY_LEAVE:
+ elif action == Group.BUDDY_LEAVE:
aniter = self._get_iter_for_buddy(buddy)
if aniter:
self._buddy_list_model.remove(aniter)
@@ -346,7 +348,7 @@ class GroupChat(Chat):
aniter = self._get_iter_for_buddy(buddy)
self._buddy_list_model.set(aniter, self._MODEL_COL_ICON, self._pixbuf_new_message)
- def notify_activate(self, chat):
+ def notify_activate(self, chat, buddy):
aniter = self._get_iter_for_buddy(buddy)
self._buddy_list_model.set(aniter, self._MODEL_COL_ICON, self._pixbuf_active_chat)
@@ -396,10 +398,7 @@ class ChatShell(dbus.service.Object):
def main():
ChatShell.get_instance().open_group_chat()
- try:
- gtk.main()
- except KeyboardInterrupt:
- pass
+ gtk.main()
if __name__ == "__main__":
main()
diff --git a/sugar/chat/richtext.py b/sugar/chat/richtext.py
index 0ac70b16..aa335d8d 100644
--- a/sugar/chat/richtext.py
+++ b/sugar/chat/richtext.py
@@ -45,7 +45,7 @@ class RichTextView(gtk.TextView):
def __motion_notify_cb(self, widget, event):
if event.is_hint:
- [x, y, state] = event.window.get_pointer();
+ event.window.get_pointer();
it = self.__get_event_iter(event)
if it:
@@ -134,9 +134,9 @@ class RichTextBuffer(gtk.TextBuffer):
def __insert_text_cb(self, widget, pos, text, length):
for tag in self.active_tags:
- pos_end = pos.copy()
- pos_end.backward_chars(length)
- self.apply_tag_by_name(tag, pos, pos_end)
+ pos_end = pos.copy()
+ pos_end.backward_chars(length)
+ self.apply_tag_by_name(tag, pos, pos_end)
class RichTextToolbar(gtk.Toolbar):
def __init__(self, buf):
@@ -205,6 +205,7 @@ class RichTextToolbar(gtk.Toolbar):
class RichTextHandler(xml.sax.handler.ContentHandler):
def __init__(self, serializer, buf):
+ xml.sax.handler.ContentHandler.__init__(self)
self.buf = buf
self.serializer = serializer
self.tags = []
@@ -286,7 +287,7 @@ class RichTextSerializer:
def serialize(self, buf):
self.buf = buf
- xml = ""
+ res = ""
next_it = buf.get_start_iter()
while not next_it.is_end():
@@ -299,27 +300,27 @@ class RichTextSerializer:
for tag in it.get_toggled_tags(False):
while 1:
open_tag = self._open_tags.pop()
- xml += self.serialize_tag_end(tag)
+ res += self.serialize_tag_end(tag)
if open_tag == tag:
break
tags_to_reopen.append(open_tag)
for tag in tags_to_reopen:
self._open_tags.append(tag)
- xml += self.serialize_tag_start(tag, it)
+ res += self.serialize_tag_start(tag, it)
for tag in it.get_toggled_tags(True):
self._open_tags.append(tag)
- xml += self.serialize_tag_start(tag, it)
+ res += self.serialize_tag_start(tag, it)
- xml += buf.get_text(it, next_it, False)
+ res += buf.get_text(it, next_it, False)
if next_it.is_end():
self._open_tags.reverse()
for tag in self._open_tags:
- xml += self.serialize_tag_end(tag)
+ res += self.serialize_tag_end(tag)
- xml += ""
+ res += ""
return xml
@@ -330,11 +331,11 @@ class RichTextSerializer:
parser.feed(xml_string)
parser.close()
-def test_quit(window, rich_buf):
- print RichTextSerializer().serialize(rich_buf)
+def test_quit(w, rb):
+ print RichTextSerializer().serialize(rb)
gtk.main_quit()
-def link_clicked(view, address):
+def link_clicked(v, address):
print "Link clicked " + address
if __name__ == "__main__":
@@ -350,15 +351,15 @@ if __name__ == "__main__":
rich_buf = view.get_buffer()
- xml_string = ""
+ test_xml = ""
- xml_string += "Testone\n"
- xml_string += "Test two"
- xml_string += "Test three"
- xml_string += "Test link"
- xml_string += ""
+ test_xml += "Testone\n"
+ test_xml += "Test two"
+ test_xml += "Test three"
+ test_xml += "Test link"
+ test_xml += ""
- RichTextSerializer().deserialize(xml_string, rich_buf)
+ RichTextSerializer().deserialize(test_xml, rich_buf)
toolbar = RichTextToolbar(rich_buf)
vbox.pack_start(toolbar, False)
diff --git a/sugar/env.py b/sugar/env.py
index e30daa2d..3b812d32 100644
--- a/sugar/env.py
+++ b/sugar/env.py
@@ -1,9 +1,7 @@
-import os
-
try:
- from sugar.__uninstalled__ import *
+ from sugar.__uninstalled__ import internal_get_data_file
except ImportError:
- from sugar.__installed__ import *
+ from sugar.__installed__ import internal_get_data_file
def get_data_file(filename):
return internal_get_data_file(filename)
diff --git a/sugar/p2p/Buddy.py b/sugar/p2p/Buddy.py
index 19d7c0ef..8263a8e3 100644
--- a/sugar/p2p/Buddy.py
+++ b/sugar/p2p/Buddy.py
@@ -1,7 +1,7 @@
import pwd
import os
-from Service import *
+from Service import Service
PRESENCE_SERVICE_TYPE = "_olpc_presence._tcp"
PRESENCE_SERVICE_PORT = 6000
diff --git a/sugar/p2p/Group.py b/sugar/p2p/Group.py
index 1c9797a8..50aed46b 100644
--- a/sugar/p2p/Group.py
+++ b/sugar/p2p/Group.py
@@ -1,17 +1,17 @@
-import avahi
-
-import presence
-from Buddy import *
-from Service import *
+from Buddy import Buddy
+from Buddy import Owner
+from Buddy import PRESENCE_SERVICE_TYPE
+from Service import Service
import Model
-
-SERVICE_ADDED = "service_added"
-SERVICE_REMOVED = "service_removed"
-
-BUDDY_JOIN = "buddy_join"
-BUDDY_LEAVE = "buddy_leave"
+import presence
class Group:
+ SERVICE_ADDED = "service_added"
+ SERVICE_REMOVED = "service_removed"
+
+ BUDDY_JOIN = "buddy_join"
+ BUDDY_LEAVE = "buddy_leave"
+
def __init__(self):
self._service_listeners = []
self._presence_listeners = []
@@ -20,7 +20,7 @@ class Group:
def get_store(self):
return self._store
- def join(self, buddy):
+ def join(self):
pass
def add_service_listener(self, listener):
@@ -31,19 +31,19 @@ class Group:
def _notify_service_added(self, service):
for listener in self._service_listeners:
- listener(SERVICE_ADDED, buddy)
+ listener(Group.SERVICE_ADDED, service)
- def _notify_service_removed(self, service):
+ def _notify_service_removed(self, service_id):
for listener in self._service_listeners:
- listener(SERVICE_REMOVED,buddy)
+ listener(Group.SERVICE_REMOVED, service_id)
def _notify_buddy_join(self, buddy):
for listener in self._presence_listeners:
- listener(BUDDY_JOIN, buddy)
+ listener(Group.BUDDY_JOIN, buddy)
def _notify_buddy_leave(self, buddy):
for listener in self._presence_listeners:
- listener(BUDDY_LEAVE, buddy)
+ listener(Group.BUDDY_LEAVE, buddy)
class LocalGroup(Group):
def __init__(self):
@@ -64,9 +64,9 @@ class LocalGroup(Group):
self._services[sid] = service
self._notify_service_added(service)
- def remove_service(self, sid):
- self._notify_service_removed(service)
- del self._services[sid]
+ def remove_service(self, service_id):
+ self._notify_service_removed(service_id)
+ del self._services[service_id]
def join(self):
self._owner = Owner(self)
@@ -103,8 +103,8 @@ class LocalGroup(Group):
def _on_service_resolved(self, interface, protocol, name, stype, domain,
host, aprotocol, address, port, txt, flags):
- service = Service(name, stype, address, port)
- if stype == PRESENCE_SERVICE_TYPE:
- self._add_buddy(Buddy(service, name))
- elif stype.startswith("_olpc"):
- self.add_service(service)
+ service = Service(name, stype, address, port)
+ if stype == PRESENCE_SERVICE_TYPE:
+ self._add_buddy(Buddy(service, name))
+ elif stype.startswith("_olpc"):
+ self.add_service(service)
diff --git a/sugar/p2p/Makefile.am b/sugar/p2p/Makefile.am
index be343601..334e7b6a 100644
--- a/sugar/p2p/Makefile.am
+++ b/sugar/p2p/Makefile.am
@@ -3,6 +3,7 @@ sugar_PYTHON = \
__init__.py \
Buddy.py \
Group.py \
+ Model.py \
Service.py \
StreamReader.py \
StreamWriter.py \
diff --git a/sugar/p2p/Model.py b/sugar/p2p/Model.py
index 795b7cc0..0148c742 100644
--- a/sugar/p2p/Model.py
+++ b/sugar/p2p/Model.py
@@ -1,6 +1,7 @@
MODEL_SERVICE_TYPE = "_olpc_model._tcp"
MODEL_SERVICE_PORT = 6300
+import socket
import xmlrpclib
from sugar.p2p.Service import Service
@@ -59,7 +60,7 @@ class LocalModel:
p2p_server = network.GlibXMLRPCServer(("", port))
p2p_server.register_instance(ModelRequestHandler(self))
started = True
- except:
+ except(socket.error):
port = port + 1
tries = tries - 1
service.set_port(port)
diff --git a/sugar/p2p/StreamReader.py b/sugar/p2p/StreamReader.py
index c108547b..d3dbf83e 100644
--- a/sugar/p2p/StreamReader.py
+++ b/sugar/p2p/StreamReader.py
@@ -1,3 +1,5 @@
+import socket
+
import network
class StreamReaderRequestHandler(object):
@@ -5,7 +7,6 @@ class StreamReaderRequestHandler(object):
self._reader = reader
def message(self, nick_name, message):
- address = network.get_authinfo()
self._reader.recv(nick_name, message)
return True
@@ -37,7 +38,7 @@ class StreamReader:
p2p_server = network.GlibXMLRPCServer(("", port))
p2p_server.register_instance(StreamReaderRequestHandler(self))
started = True
- except:
+ except(socket.error):
port = port + 1
tries = tries - 1
self._service.set_port(port)
diff --git a/sugar/p2p/StreamWriter.py b/sugar/p2p/StreamWriter.py
index f30801ea..6007a934 100644
--- a/sugar/p2p/StreamWriter.py
+++ b/sugar/p2p/StreamWriter.py
@@ -31,7 +31,7 @@ class StreamWriter:
nick_name = self._group.get_owner().get_nick_name()
self._uclient.message(nick_name, data)
return True
- except (socket.error, xmlrpclib.Fault, xmlrpclib.ProtocolError), e:
+ except (socket.error, xmlrpclib.Fault, xmlrpclib.ProtocolError):
traceback.print_exc()
return False
diff --git a/sugar/p2p/network.py b/sugar/p2p/network.py
index c88ede6c..4c054fea 100644
--- a/sugar/p2p/network.py
+++ b/sugar/p2p/network.py
@@ -1,10 +1,6 @@
-# -*- tab-width: 4; indent-tabs-mode: t -*-
-
import socket
import threading
import traceback
-import select
-import time
import xmlrpclib
import sys
@@ -133,10 +129,6 @@ class GroupServer(object):
# Set some options to make it multicast-friendly
self._listen_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- try:
- self._listen_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
- except:
- pass
self._listen_sock.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_TTL, 20)
self._listen_sock.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_LOOP, 1)
diff --git a/sugar/p2p/presence.py b/sugar/p2p/presence.py
index e16fc928..4c5c086f 100644
--- a/sugar/p2p/presence.py
+++ b/sugar/p2p/presence.py
@@ -65,7 +65,7 @@ class PresenceDiscovery(object):
self._service_type_browsers[(interface, protocol, domain)] = b
- def new_domain(self,interface, protocol, domain, flags):
+ def new_domain(self, interface, protocol, domain, flags):
if domain != "local":
return
self.browse_domain(interface, protocol, domain)
@@ -84,7 +84,7 @@ class PresenceAnnounce(object):
self._hostname = "%s:%s" % (self.server.GetHostName(), rs_port)
rs_name = self._hostname
- info = ["%s=%s" % (k,v) for k,v in kwargs.items()]
+ info = ["%s=%s" % (k, v) for k, v in kwargs.items()]
g.AddService(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, 0, rs_name, rs_service,
"", "", # domain, host (let the system figure it out)
dbus.UInt16(rs_port), info,)
diff --git a/sugar/shell/activity.py b/sugar/shell/activity.py
index 6f1f3fc1..4678a9c0 100644
--- a/sugar/shell/activity.py
+++ b/sugar/shell/activity.py
@@ -1,15 +1,11 @@
# -*- tab-width: 4; indent-tabs-mode: t -*-
-import string
-
-import gc
import dbus
import dbus.service
import dbus.glib
-import gobject
import pygtk
pygtk.require('2.0')
-import gtk,sys
+import gtk
class Activity(dbus.service.Object):
@@ -36,21 +32,21 @@ class Activity(dbus.service.Object):
"com.redhat.Sugar.Shell.ActivityContainer")
self.__activity_id = self.__activity_container.add_activity("")
- self.__object_path = "/com/redhat/Sugar/Shell/Activities/%d"%self.__activity_id
+ self.__object_path = "/com/redhat/Sugar/Shell/Activities/%d" % self.__activity_id
- print "object_path = %s"%self.__object_path
+ print "object_path = %s" % self.__object_path
self.__activity_object = dbus.Interface(self.__bus.get_object("com.redhat.Sugar.Shell", self.__object_path), \
"com.redhat.Sugar.Shell.ActivityHost")
self.__window_id = self.__activity_object.get_host_xembed_id()
- print "XEMBED window_id = %d"%self.__window_id
+ print "XEMBED window_id = %d" % self.__window_id
self.__plug = gtk.Plug(self.__window_id)
# Now let the Activity register a peer service so the Shell can poke it
- self.__peer_service_name = "com.redhat.Sugar.Activity%d"%self.__activity_id
- self.__peer_object_name = "/com/redhat/Sugar/Activity/%d"%self.__activity_id
+ self.__peer_service_name = "com.redhat.Sugar.Activity%d" % self.__activity_id
+ self.__peer_object_name = "/com/redhat/Sugar/Activity/%d" % self.__activity_id
self.__service = dbus.service.BusName(self.__peer_service_name, bus=self.__bus)
dbus.service.Object.__init__(self, self.__service, self.__peer_object_name)
@@ -86,7 +82,7 @@ class Activity(dbus.service.Object):
pixarray = []
pixstr = pixbuf.get_pixels();
for c in pixstr:
- pixarray.append(c)
+ pixarray.append(c)
self.__activity_object.set_tab_icon(pixarray, \
pixbuf.get_colorspace(), \
pixbuf.get_has_alpha(), \
@@ -163,16 +159,16 @@ class Activity(dbus.service.Object):
# pure virtual methods
def activity_on_connected_to_shell(self):
- print "act %d: you need to override activity_on_connected_to_shell"%self.activity_get_id()
+ print "act %d: you need to override activity_on_connected_to_shell" % self.activity_get_id()
def activity_on_disconnected_from_shell(self):
- print "act %d: you need to override activity_on_disconnected_from_shell"%self.activity_get_id()
-
+ print "act %d: you need to override activity_on_disconnected_from_shell" % self.activity_get_id()
+
def activity_on_close_from_user(self):
- print "act %d: you need to override activity_on_close_from_user"%self.activity_get_id()
+ print "act %d: you need to override activity_on_close_from_user" % self.activity_get_id()
def activity_on_lost_focus(self):
- print "act %d: you need to override activity_on_lost_focus"%self.activity_get_id()
+ print "act %d: you need to override activity_on_lost_focus" % self.activity_get_id()
def activity_on_got_focus(self):
- print "act %d: you need to override activity_on_got_focus"%self.activity_get_id()
+ print "act %d: you need to override activity_on_got_focus" % self.activity_get_id()
diff --git a/sugar/shell/shell.py b/sugar/shell/shell.py
index d5423079..0dd3ea95 100755
--- a/sugar/shell/shell.py
+++ b/sugar/shell/shell.py
@@ -1,12 +1,9 @@
#!/usr/bin/python
# -*- tab-width: 4; indent-tabs-mode: t -*-
-import string
-
import dbus
import dbus.service
import dbus.glib
-import gobject
import pygtk
pygtk.require('2.0')
import gtk
@@ -27,7 +24,7 @@ class ActivityHost(dbus.service.Object):
self.activity_id = activity_counter
activity_counter += 1
- self.dbus_object_name = "/com/redhat/Sugar/Shell/Activities/%d"%self.activity_id
+ self.dbus_object_name = "/com/redhat/Sugar/Shell/Activities/%d" % self.activity_id
#print "object name = %s"%self.dbus_object_name
dbus.service.Object.__init__(self, activity_container.service, self.dbus_object_name)
@@ -143,7 +140,7 @@ class ActivityHost(dbus.service.Object):
#print " data = ", data
pixstr = ""
for c in data:
- pixstr += chr(c)
+ pixstr += chr(c)
pixbuf = gtk.gdk.pixbuf_new_from_data(pixstr, colorspace, has_alpha, bits_per_sample, width, height, rowstride)
#print pixbuf
@@ -225,10 +222,11 @@ class ActivityContainer(dbus.service.Object):
self.window.add(self.notebook)
self.window.connect("destroy", lambda w: gtk.main_quit())
- self.window.show()
self.current_activity = None
+ def show(self):
+ self.window.show()
def __focus_reply_cb(self):
pass
@@ -283,10 +281,10 @@ class ActivityContainer(dbus.service.Object):
return activity.get_host_activity_id()
def __print_activities(self):
- print "__print_activities: %d activities registered"%len(self.activities)
+ print "__print_activities: %d activities registered" % len(self.activities)
i = 0
for owner, activity in self.activities:
- print " %d: owner=%s activity_object_name=%s"%(i, owner, activity.dbus_object_name)
+ print " %d: owner=%s activity_object_name=%s" % (i, owner, activity.dbus_object_name)
i += 1
@@ -295,11 +293,9 @@ def main():
service = dbus.service.BusName("com.redhat.Sugar.Shell", bus=session_bus)
activityContainer = ActivityContainer(service, session_bus)
+ activityContainer.show()
- try:
- gtk.main()
- except KeyboardInterrupt:
- pass
+ gtk.main()
-if __name__=="__main__":
- main()
+if __name__ == "__main__":
+ main()