Fix a bunch of bugs, more cleanups
This commit is contained in:
parent
d12b780074
commit
2bbedf988b
@ -69,8 +69,8 @@ class ActivityRegistry:
|
||||
activity_exec = cp.get('Activity', 'exec')
|
||||
elif cp.has_option('Activity', 'python_module'):
|
||||
python_module = cp.get('Activity', 'python_module')
|
||||
activity_exec = 'python -m sugar/activity/Activity %s %s' \
|
||||
% (activity_id, python_module)
|
||||
activity_exec = '%s %s %s' % (env.get_activity_runner(),
|
||||
activity_id, python_module)
|
||||
env.add_to_python_path(directory)
|
||||
else:
|
||||
logging.error('%s must specifiy exec or python_module' % (path))
|
||||
|
@ -1,4 +1,4 @@
|
||||
bin_SCRIPTS = sugar
|
||||
bin_SCRIPTS = sugar sugar-activity
|
||||
|
||||
sugardir = $(pkgdatadir)/shell
|
||||
sugar_PYTHON = \
|
||||
|
@ -6,18 +6,12 @@ class Process:
|
||||
"""Object representing one of the session processes"""
|
||||
|
||||
def __init__(self, command):
|
||||
self._pid = None
|
||||
self._command = command
|
||||
|
||||
def get_name(self):
|
||||
return self._command
|
||||
|
||||
def start(self):
|
||||
print self._command
|
||||
logging.debug('Start %s' % (self._command))
|
||||
|
||||
args = self._command.split()
|
||||
flags = gobject.SPAWN_SEARCH_PATH or gobject.SPAWN_STDERR_TO_DEV_NULL
|
||||
result = gobject.spawn_async(args, flags=flags, standard_output=True)
|
||||
self._pid = result[0]
|
||||
self._stdout = result[2]
|
||||
flags = gobject.SPAWN_SEARCH_PATH
|
||||
result = gobject.spawn_async(args, flags=flags)
|
||||
|
@ -1,9 +1,10 @@
|
||||
import os
|
||||
import gtk
|
||||
import sugar.theme
|
||||
import gobject
|
||||
|
||||
from Shell import Shell
|
||||
from Process import Process
|
||||
import sugar.theme
|
||||
|
||||
class ActivityProcess(Process):
|
||||
def __init__(self, module):
|
||||
@ -21,7 +22,11 @@ class DbusProcess(Process):
|
||||
return 'Dbus'
|
||||
|
||||
def start(self):
|
||||
Process.start(self)
|
||||
args = self._command.split()
|
||||
flags = gobject.SPAWN_SEARCH_PATH
|
||||
result = gobject.spawn_async(args, flags=flags, standard_output=True,
|
||||
standard_error=True)
|
||||
self._stdout = result[2]
|
||||
|
||||
dbus_file = os.fdopen(self._stdout)
|
||||
addr = dbus_file.readline()
|
||||
@ -42,9 +47,6 @@ class Session:
|
||||
def __init__(self):
|
||||
sugar.theme.setup()
|
||||
|
||||
self._shell = Shell()
|
||||
self._shell.start()
|
||||
|
||||
def start(self):
|
||||
"""Start the session"""
|
||||
process = DbusProcess()
|
||||
@ -53,7 +55,10 @@ class Session:
|
||||
process = MatchboxProcess()
|
||||
process.start()
|
||||
|
||||
registry = self._shell.get_registry()
|
||||
shell = Shell()
|
||||
shell.start()
|
||||
|
||||
registry = shell.get_registry()
|
||||
for activity_module in registry.list_activities():
|
||||
process = ActivityProcess(activity_module)
|
||||
process.start()
|
||||
|
@ -3,6 +3,7 @@ import os
|
||||
import dbus
|
||||
import gtk
|
||||
import wnck
|
||||
import gobject
|
||||
|
||||
from sugar.LogWriter import LogWriter
|
||||
from ConsoleLogger import ConsoleLogger
|
||||
|
14
shell/sugar
14
shell/sugar
@ -5,8 +5,6 @@ import os
|
||||
import pwd
|
||||
import random
|
||||
|
||||
from Emulator import Emulator
|
||||
|
||||
def add_to_python_path(path):
|
||||
sys.path.insert(0, path)
|
||||
if os.environ.has_key('PYTHONPATH'):
|
||||
@ -15,10 +13,6 @@ def add_to_python_path(path):
|
||||
else:
|
||||
os.environ['PYTHONPATH'] = path
|
||||
|
||||
# FIXE Don't run the emulator on the OLPC
|
||||
emulator = Emulator()
|
||||
emulator.start()
|
||||
|
||||
i = 0
|
||||
for arg in sys.argv:
|
||||
if arg == '--test-user':
|
||||
@ -47,7 +41,13 @@ else:
|
||||
add_to_python_path(os.path.join(sugar.env.get_data_dir(), 'shell'))
|
||||
print 'Running the installed sugar...'
|
||||
|
||||
print 'Redirecting output to the console, press Ctrl+Down to open it.'
|
||||
from Emulator import Emulator
|
||||
|
||||
# FIXE Don't run the emulator on the OLPC
|
||||
emulator = Emulator()
|
||||
emulator.start()
|
||||
|
||||
print 'Redirecting output to the console, press F3 to open it.'
|
||||
|
||||
from Session import Session
|
||||
|
||||
|
16
shell/sugar-activity
Executable file
16
shell/sugar-activity
Executable file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import sys
|
||||
|
||||
import gobject
|
||||
|
||||
from sugar.activity import Activity
|
||||
from sugar.LogWriter import LogWriter
|
||||
from sugar import theme
|
||||
|
||||
theme.setup()
|
||||
|
||||
lw = LogWriter(sys.argv[1])
|
||||
lw.start()
|
||||
|
||||
Activity.register_factory(sys.argv[1], sys.argv[2])
|
@ -1,2 +1,3 @@
|
||||
sugar_data_dir = '@prefix@/share/sugar'
|
||||
sugar_activity_runner = '@prefix@/bin/sugar-activity'
|
||||
sugar_activities_dir = '@prefix@/share/sugar/activities'
|
||||
|
@ -1,4 +1,5 @@
|
||||
import os
|
||||
|
||||
sugar_data_dir = os.path.dirname(os.path.dirname(__file__))
|
||||
sugar_activity_runner = os.path.join(sugar_data_dir, 'shell/sugar-activity')
|
||||
sugar_activities_dir = os.path.join(sugar_data_dir, 'activities')
|
||||
|
@ -11,7 +11,6 @@ import gtk, gobject
|
||||
from sugar.LogWriter import LogWriter
|
||||
from sugar import keybindings
|
||||
import sugar.util
|
||||
import sugar.theme
|
||||
|
||||
SHELL_SERVICE_NAME = "caom.redhat.Sugar.Shell"
|
||||
SHELL_SERVICE_PATH = "/com/redhat/Sugar/Shell"
|
||||
@ -83,13 +82,8 @@ def create(activity_name, service = None, args = None):
|
||||
else:
|
||||
factory.create()
|
||||
|
||||
def main(activity_name, activity_class):
|
||||
"""Starts the activity main loop."""
|
||||
sugar.theme.setup()
|
||||
|
||||
log_writer = LogWriter(activity_name)
|
||||
log_writer.start()
|
||||
|
||||
def register_factory(activity_name, activity_class):
|
||||
"""Register the activity factory."""
|
||||
factory = ActivityFactory(activity_name, activity_class)
|
||||
|
||||
gtk.main()
|
||||
@ -98,8 +92,7 @@ class ActivityDbusService(dbus.service.Object):
|
||||
"""Base dbus service object that each Activity uses to export dbus methods.
|
||||
|
||||
The dbus service is separate from the actual Activity object so that we can
|
||||
tightly control what stuff passes through print aaaa
|
||||
the dbus python bindings."""
|
||||
tightly control what stuff passes through the dbus python bindings."""
|
||||
|
||||
_ALLOWED_CALLBACKS = [ON_PUBLISH_CB]
|
||||
|
||||
@ -223,6 +216,3 @@ class Activity(gtk.Window):
|
||||
def publish(self):
|
||||
"""Called to request the activity to publish itself on the network."""
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1], sys.argv[2])
|
||||
|
@ -36,3 +36,6 @@ def get_data_dir():
|
||||
|
||||
def get_activities_dir():
|
||||
return sugar_activities_dir
|
||||
|
||||
def get_activity_runner():
|
||||
return sugar_activity_runner
|
||||
|
Loading…
Reference in New Issue
Block a user