Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-09-10 00:35:53 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-09-10 00:35:53 (GMT)
commit47cc58b1e648a586252046eb79339357cd38f939 (patch)
tree90ab614b2dc05472686b4dbe593d580735a4e16f /shell
parentf4f70d22f1d29d24b7234e9a6fb3203deec5adfa (diff)
Make part of the session public so that it can used by tests
Diffstat (limited to 'shell')
-rw-r--r--shell/Makefile.am5
-rw-r--r--shell/Session.py (renamed from shell/session/Session.py)38
-rw-r--r--shell/session/Emulator.py70
-rw-r--r--shell/session/Makefile.am6
-rw-r--r--shell/session/Process.py19
-rw-r--r--shell/session/__init__.py0
-rwxr-xr-xshell/sugar4
7 files changed, 10 insertions, 132 deletions
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 3370e2d..f9a6268 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
index 31c2443..07337d6 100644
--- a/shell/session/Session.py
+++ b/shell/Session.py
@@ -1,45 +1,17 @@
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
-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 '
+from sugar.session.Process import Process
+from sugar.session.DbusProcess import DbusProcess
+from sugar.session.MatchboxProcess import MatchboxProcess
- command = 'matchbox-window-manager %s ' % options
- Process.__init__(self, command)
-
- def get_name(self):
- return 'Matchbox'
+from FirstTimeDialog import FirstTimeDialog
+import conf
class DBusMonitorProcess(Process):
def __init__(self):
diff --git a/shell/session/Emulator.py b/shell/session/Emulator.py
deleted file mode 100644
index e15d152..0000000
--- a/shell/session/Emulator.py
+++ /dev/null
@@ -1,70 +0,0 @@
-import os
-import socket
-import sys
-
-from session.Process import Process
-import sugar.env
-
-def get_display_number():
- """Find a free display number trying to connect to 6000+ ports"""
- retries = 20
- display_number = 1
- display_is_free = False
-
- while not display_is_free and retries > 0:
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- try:
- s.connect(('127.0.0.1', 6000 + display_number))
- s.close()
-
- display_number += 1
- retries -= 1
- except:
- display_is_free = True
-
- if display_is_free:
- return display_number
- else:
- logging.error('Cannot find a free display.')
- sys.exit(0)
-
-class XephyrProcess(Process):
- def __init__(self):
- self._display = get_display_number()
- cmd = 'Xephyr :%d -ac -screen 800x600' % (self._display)
- Process.__init__(self, cmd)
-
- def get_name(self):
- return 'Xephyr'
-
- def start(self):
- Process.start(self)
- os.environ['DISPLAY'] = ":%d" % (self._display)
-
-class XnestProcess(Process):
- def __init__(self):
- self._display = get_display_number()
- cmd = 'Xnest :%d -ac -geometry 800x600' % (self._display)
- Process.__init__(self, cmd)
-
- def get_name(self):
- return 'Xnest'
-
- def start(self):
- Process.start(self)
- os.environ['DISPLAY'] = ":%d" % (self._display)
-
-class Emulator:
- """The OLPC emulator"""
- def start(self):
- try:
- process = XephyrProcess()
- process.start()
- except:
- try:
- process = XnestProcess()
- process.start()
- except:
- print 'Cannot run the emulator. You need to install \
- Xephyr or Xnest.'
- sys.exit(0)
diff --git a/shell/session/Makefile.am b/shell/session/Makefile.am
deleted file mode 100644
index c95c6cb..0000000
--- 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/session/Process.py b/shell/session/Process.py
deleted file mode 100644
index 09d93a7..0000000
--- a/shell/session/Process.py
+++ /dev/null
@@ -1,19 +0,0 @@
-import logging
-
-import gobject
-
-class Process:
- """Object representing one of the session processes"""
-
- def __init__(self, command):
- self._command = command
-
- def get_name(self):
- return self._command
-
- def start(self, standard_output=False):
- args = self._command.split()
- flags = gobject.SPAWN_SEARCH_PATH
- result = gobject.spawn_async(args, flags=flags,
- standard_output=standard_output)
- self._stdout = result[2]
diff --git a/shell/session/__init__.py b/shell/session/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/shell/session/__init__.py
+++ /dev/null
diff --git a/shell/sugar b/shell/sugar
index 17553d6..5cc4a49 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()