From 47cc58b1e648a586252046eb79339357cd38f939 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Sun, 10 Sep 2006 02:35:53 +0200 Subject: [PATCH] Make part of the session public so that it can used by tests --- configure.ac | 2 +- shell/Makefile.am | 5 ++-- shell/{session => }/Session.py | 40 +++++----------------------- shell/session/Makefile.am | 6 ----- shell/sugar | 4 +-- sugar/Makefile.am | 5 ++-- sugar/session/DbusProcess.py | 20 ++++++++++++++ {shell => sugar}/session/Emulator.py | 2 +- sugar/session/Makefile.am | 7 +++++ sugar/session/MatchboxProcess.py | 17 ++++++++++++ {shell => sugar}/session/Process.py | 0 {shell => sugar}/session/__init__.py | 0 12 files changed, 59 insertions(+), 49 deletions(-) rename shell/{session => }/Session.py (59%) delete mode 100644 shell/session/Makefile.am create mode 100644 sugar/session/DbusProcess.py rename {shell => sugar}/session/Emulator.py (97%) create mode 100644 sugar/session/Makefile.am create mode 100644 sugar/session/MatchboxProcess.py rename {shell => sugar}/session/Process.py (100%) rename {shell => sugar}/session/__init__.py (100%) diff --git a/configure.ac b/configure.ac index d729ac3a..6d5c7c96 100644 --- a/configure.ac +++ b/configure.ac @@ -50,7 +50,6 @@ shell/conf/Makefile shell/data/Makefile shell/home/Makefile shell/frame/Makefile -shell/session/Makefile shell/PresenceService/Makefile sugar/Makefile sugar/__installed__.py @@ -62,6 +61,7 @@ sugar/chat/sketchpad/Makefile sugar/p2p/Makefile sugar/p2p/model/Makefile sugar/presence/Makefile +sugar/session/Makefile po/Makefile.in tools/Makefile tools/sugar-setup-activity diff --git a/shell/Makefile.am b/shell/Makefile.am index 3370e2d1..f9a62682 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = conf data session frame home PresenceService +SUBDIRS = conf data frame home PresenceService bin_SCRIPTS = \ sugar \ @@ -17,6 +17,7 @@ sugar_PYTHON = \ Friends.py \ Invites.py \ Owner.py \ - Shell.py + Shell.py \ + Session.py EXTRA_DIST = $(bin_SCRIPTS) diff --git a/shell/session/Session.py b/shell/Session.py similarity index 59% rename from shell/session/Session.py rename to shell/Session.py index 31c24430..07337d68 100644 --- a/shell/session/Session.py +++ b/shell/Session.py @@ -1,46 +1,18 @@ import os import gtk -import gobject -import time -import re from Shell import Shell from ConsoleWindow import ConsoleWindow -from session.Process import Process -from FirstTimeDialog import FirstTimeDialog from sugar import env from sugar import logger + +from sugar.session.Process import Process +from sugar.session.DbusProcess import DbusProcess +from sugar.session.MatchboxProcess import MatchboxProcess + +from FirstTimeDialog import FirstTimeDialog import conf -class DbusProcess(Process): - def __init__(self): - config = env.get_dbus_config() - cmd = "dbus-daemon --print-address --config-file %s" % config - Process.__init__(self, cmd) - - def get_name(self): - return 'Dbus' - - def start(self): - Process.start(self, True) - dbus_file = os.fdopen(self._stdout) - addr = dbus_file.readline().strip() - dbus_file.close() - os.environ["DBUS_SESSION_BUS_ADDRESS"] = addr - -class MatchboxProcess(Process): - def __init__(self): - kbd_config = os.path.join(env.get_data_dir(), 'kbdconfig') - options = '-kbdconfig %s ' % kbd_config - - options += '-theme olpc ' - - command = 'matchbox-window-manager %s ' % options - Process.__init__(self, command) - - def get_name(self): - return 'Matchbox' - class DBusMonitorProcess(Process): def __init__(self): Process.__init__(self, "dbus-monitor --session") diff --git a/shell/session/Makefile.am b/shell/session/Makefile.am deleted file mode 100644 index c95c6cb3..00000000 --- a/shell/session/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -sugardir = $(pkgdatadir)/shell/session -sugar_PYTHON = \ - __init__.py \ - Emulator.py \ - Process.py \ - Session.py diff --git a/shell/sugar b/shell/sugar index 17553d69..5cc4a49e 100755 --- a/shell/sugar +++ b/shell/sugar @@ -19,14 +19,14 @@ from sugar import env env.setup_system() -from session.Emulator import Emulator +from sugar.session.Emulator import Emulator if os.environ.has_key('SUGAR_EMULATOR') and \ os.environ['SUGAR_EMULATOR'] == 'yes': emulator = Emulator() emulator.start() -from session.Session import Session +from Session import Session session = Session() session.start() diff --git a/sugar/Makefile.am b/sugar/Makefile.am index d339fbaf..71f60528 100644 --- a/sugar/Makefile.am +++ b/sugar/Makefile.am @@ -1,14 +1,13 @@ -SUBDIRS = activity canvas chat p2p presence +SUBDIRS = activity canvas chat p2p presence session sugardir = $(pythondir)/sugar sugar_PYTHON = \ __init__.py \ __installed__.py \ - bots.py \ env.py \ logger.py \ setup.py \ - TracebackUtils.py \ + TracebackUtils.py \ util.py EXTRA_DIST = __uninstalled__.py diff --git a/sugar/session/DbusProcess.py b/sugar/session/DbusProcess.py new file mode 100644 index 00000000..2f194593 --- /dev/null +++ b/sugar/session/DbusProcess.py @@ -0,0 +1,20 @@ +import os + +from sugar.session.Process import Process +from sugar import env + +class DbusProcess(Process): + def __init__(self): + config = env.get_dbus_config() + cmd = "dbus-daemon --print-address --config-file %s" % config + Process.__init__(self, cmd) + + def get_name(self): + return 'Dbus' + + def start(self): + Process.start(self, True) + dbus_file = os.fdopen(self._stdout) + addr = dbus_file.readline().strip() + dbus_file.close() + os.environ["DBUS_SESSION_BUS_ADDRESS"] = addr diff --git a/shell/session/Emulator.py b/sugar/session/Emulator.py similarity index 97% rename from shell/session/Emulator.py rename to sugar/session/Emulator.py index e15d152b..54510250 100644 --- a/shell/session/Emulator.py +++ b/sugar/session/Emulator.py @@ -2,7 +2,7 @@ import os import socket import sys -from session.Process import Process +from sugar.session.Process import Process import sugar.env def get_display_number(): diff --git a/sugar/session/Makefile.am b/sugar/session/Makefile.am new file mode 100644 index 00000000..326f2abe --- /dev/null +++ b/sugar/session/Makefile.am @@ -0,0 +1,7 @@ +sugardir = $(pythondir)/sugar/session +sugar_PYTHON = \ + __init__.py \ + DbusProcess.py \ + Emulator.py \ + MatchboxProcess.py \ + Process.py diff --git a/sugar/session/MatchboxProcess.py b/sugar/session/MatchboxProcess.py new file mode 100644 index 00000000..b63a4b77 --- /dev/null +++ b/sugar/session/MatchboxProcess.py @@ -0,0 +1,17 @@ +import os + +from sugar.session.Process import Process +from sugar import env + +class MatchboxProcess(Process): + def __init__(self): + kbd_config = os.path.join(env.get_data_dir(), 'kbdconfig') + options = '-kbdconfig %s ' % kbd_config + + options += '-theme olpc ' + + command = 'matchbox-window-manager %s ' % options + Process.__init__(self, command) + + def get_name(self): + return 'Matchbox' diff --git a/shell/session/Process.py b/sugar/session/Process.py similarity index 100% rename from shell/session/Process.py rename to sugar/session/Process.py diff --git a/shell/session/__init__.py b/sugar/session/__init__.py similarity index 100% rename from shell/session/__init__.py rename to sugar/session/__init__.py