Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--shell/ConsoleWindow.py17
-rwxr-xr-xshell/Shell.py16
-rw-r--r--shell/session/Session.py5
-rw-r--r--sugar/logger.py25
4 files changed, 37 insertions, 26 deletions
diff --git a/shell/ConsoleWindow.py b/shell/ConsoleWindow.py
index 3cbd792..be2e4a5 100644
--- a/shell/ConsoleWindow.py
+++ b/shell/ConsoleWindow.py
@@ -1,6 +1,8 @@
import logging
import gtk
+import dbus
+import dbus.service
class Console(gtk.ScrolledWindow):
def __init__(self):
@@ -36,7 +38,16 @@ class Console(gtk.ScrolledWindow):
buf.insert_with_tags(it, msg, self._debug_tag)
else:
buf.insert(it, msg)
-
+
+class ConsoleDbusService(dbus.service.Object):
+ def __init__(self, console, bus_name):
+ dbus.service.Object.__init__(self, bus_name, '/org/laptop/Sugar/Console')
+ self._console = console
+
+ @dbus.service.method('org.laptop.Sugar.Console')
+ def log(self, level, module_id, message):
+ self._console.log(level, module_id, message)
+
class ConsoleWindow(gtk.Window):
def __init__(self):
gtk.Window.__init__(self)
@@ -69,6 +80,10 @@ class ConsoleWindow(gtk.Window):
self._consoles = {}
+ session_bus = dbus.SessionBus()
+ bus_name = dbus.service.BusName('org.laptop.Sugar.Console', bus=session_bus)
+ ConsoleDbusService(self, bus_name)
+
def _add_console(self, page_id):
console = Console()
page = self._nb.append_page(console, gtk.Label(page_id))
diff --git a/shell/Shell.py b/shell/Shell.py
index db21135..614e1d1 100755
--- a/shell/Shell.py
+++ b/shell/Shell.py
@@ -7,11 +7,9 @@ import gtk
import gobject
import wnck
-from sugar.LogWriter import LogWriter
from ActivityRegistry import ActivityRegistry
from HomeWindow import HomeWindow
from sugar import env
-from ConsoleWindow import ConsoleWindow
from Owner import ShellOwner
from sugar.presence.PresenceService import PresenceService
from ActivityHost import ActivityHost
@@ -39,10 +37,6 @@ class ShellDbusService(dbus.service.Object):
def show_console(self):
gobject.idle_add(self.__show_console_idle)
- @dbus.service.method('com.redhat.Sugar.Shell')
- def log(self, level, module_id, message):
- self._shell.log(level, module_id, message)
-
class Shell(gobject.GObject):
__gsignals__ = {
'activity-closed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([str]))
@@ -60,10 +54,6 @@ class Shell(gobject.GObject):
bus_name = dbus.service.BusName('com.redhat.Sugar.Shell', bus=session_bus)
ShellDbusService(self, bus_name)
- self._console = ConsoleWindow()
-
- sugar.logger.start('Shell', self)
-
self._owner = ShellOwner()
self._owner.announce()
@@ -76,6 +66,9 @@ class Shell(gobject.GObject):
self._screen.connect('window-opened', self.__window_opened_cb)
self._screen.connect('window-closed', self.__window_closed_cb)
+ def set_console(self, console):
+ self._console = console
+
def __window_opened_cb(self, screen, window):
if window.get_window_type() == wnck.WINDOW_NORMAL:
self._hosts[window.get_xid()] = ActivityHost(self, window)
@@ -155,9 +148,6 @@ class Shell(gobject.GObject):
else:
logging.error('No such activity in the directory')
return None
-
- def log(self, level, module_id, message):
- self._console.log(level, module_id, message)
def get_registry(self):
return self._registry
diff --git a/shell/session/Session.py b/shell/session/Session.py
index aac6576..578fe72 100644
--- a/shell/session/Session.py
+++ b/shell/session/Session.py
@@ -9,6 +9,7 @@ import dbus.dbus_bindings
from sugar.presence import PresenceService
from Shell import Shell
+from ConsoleWindow import ConsoleWindow
from session.Process import Process
import sugar.env
@@ -69,6 +70,9 @@ class Session:
process = DbusProcess()
process.start()
+ console = ConsoleWindow()
+ sugar.logger.start('Shell', console)
+
process = MatchboxProcess()
process.start()
@@ -76,6 +80,7 @@ class Session:
process.start()
shell = Shell(self._registry)
+ shell.set_console(console)
shell.start()
try:
diff --git a/sugar/logger.py b/sugar/logger.py
index d6e5daa..fd5bf31 100644
--- a/sugar/logger.py
+++ b/sugar/logger.py
@@ -6,20 +6,20 @@ from cStringIO import StringIO
import dbus
import gobject
-__sugar_shell = None
+__console = None
__console_id = None
class Handler(logging.Handler):
- def __init__(self, shell, console_id):
+ def __init__(self, console, console_id):
logging.Handler.__init__(self)
self._console_id = console_id
- self._shell = shell
+ self._console = console
self._records = []
def _log(self):
for record in self._records:
- self._shell.log(record.levelno, self._console_id, record.msg)
+ self._console.log(record.levelno, self._console_id, record.msg)
self._records = []
return False
@@ -32,22 +32,23 @@ def __exception_handler(typ, exc, tb):
trace = StringIO()
traceback.print_exception(typ, exc, tb, None, trace)
- __sugar_shell.log(logging.ERROR, __console_id, trace.getvalue())
+ __console.log(logging.ERROR, __console_id, trace.getvalue())
-def start(console_id, shell = None):
+def start(console_id, console = None):
root_logger = logging.getLogger('')
root_logger.setLevel(logging.DEBUG)
- if shell == None:
+ if console == None:
bus = dbus.SessionBus()
- proxy_obj = bus.get_object('com.redhat.Sugar.Shell', '/com/redhat/Sugar/Shell')
- shell = dbus.Interface(proxy_obj, 'com.redhat.Sugar.Shell')
+ proxy_obj = bus.get_object('org.laptop.Sugar.Console',
+ '/org/laptop/Sugar/Console')
+ console = dbus.Interface(proxy_obj, 'org.laptop.Sugar.Console')
- root_logger.addHandler(Handler(shell, console_id))
+ root_logger.addHandler(Handler(console, console_id))
- global __sugar_shell
+ global __console
global __console_id
- __sugar_shell = shell
+ __console = console
__console_id = console_id
sys.excepthook = __exception_handler