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