Make it easy to run two instances. See README
This commit is contained in:
parent
a32007ec7a
commit
9df1c653d5
48
README
48
README
@ -26,46 +26,12 @@ To run the python sources from your source tree run
|
|||||||
|
|
||||||
$ sugar/sugar
|
$ sugar/sugar
|
||||||
|
|
||||||
You can also run the components separately:
|
Running multiple instances on the same machine
|
||||||
|
==============================================
|
||||||
|
|
||||||
$ source ./setup-run-from-source.sh # needs bash
|
You can use the --test command line options.
|
||||||
|
For example:
|
||||||
in the top-level directory. Icons and other resources are still loaded
|
|
||||||
from the installed location though.
|
|
||||||
|
|
||||||
To run the shell
|
|
||||||
|
|
||||||
$ cd shell/src
|
|
||||||
$ ./shell.py
|
|
||||||
|
|
||||||
You can run activities like this
|
|
||||||
|
|
||||||
$ cd browser
|
|
||||||
$ ./browser.py
|
|
||||||
|
|
||||||
(Just remember to have the shell running)
|
|
||||||
|
|
||||||
|
|
||||||
Running two instances on the same machine
|
|
||||||
=========================================
|
|
||||||
|
|
||||||
1) Install Xephyr
|
|
||||||
2) Add another user to your machine, lets call that user 'sugar'
|
|
||||||
2) Run Xepyhr as your normal user:
|
|
||||||
|
|
||||||
$ Xephyr -ac -host-cursor -screen 800x600 :1
|
|
||||||
|
|
||||||
3) In a new shell:
|
|
||||||
|
|
||||||
$ su sugar -
|
|
||||||
$ dbus-daemon --session --print-address
|
|
||||||
|
|
||||||
4) In another new shell
|
|
||||||
|
|
||||||
$ su sugar -
|
|
||||||
$ export DISPLAY=:1
|
|
||||||
$ export DBUS_SESSION_BUS_ADDRESS=<output dbus-daemon command from above>
|
|
||||||
$ metacity &
|
|
||||||
|
|
||||||
5) In the previous shell, run sugar
|
|
||||||
|
|
||||||
|
sugar/sugar --test my_nick_name1
|
||||||
|
sugar/sugar --test my_nick_name2
|
||||||
|
...
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
export PYTHONPATH=`pwd`
|
|
@ -1,3 +0,0 @@
|
|||||||
#!/bin/tcsh
|
|
||||||
|
|
||||||
setenv PYTHONPATH `pwd`
|
|
@ -1,67 +0,0 @@
|
|||||||
#!/usr/bin/python -t
|
|
||||||
|
|
||||||
import sys, os
|
|
||||||
import gtk, gobject
|
|
||||||
import pwd
|
|
||||||
import types
|
|
||||||
|
|
||||||
def change_user(user):
|
|
||||||
try:
|
|
||||||
pwrec = pwd.getpwnam(user)
|
|
||||||
except KeyError:
|
|
||||||
raise Exception("Username '%s' does not exist." % user)
|
|
||||||
uid = pwrec[2]
|
|
||||||
os.setuid(uid)
|
|
||||||
return (pwrec[6], pwrec[5])
|
|
||||||
|
|
||||||
def shell_watch_cb(pid, condition, user_data=None):
|
|
||||||
gtk.main_quit()
|
|
||||||
|
|
||||||
def main():
|
|
||||||
if len(sys.argv) < 2:
|
|
||||||
print "Usage: %s <test user>" % sys.argv[0]
|
|
||||||
user = sys.argv[1]
|
|
||||||
|
|
||||||
# Start Xephyr
|
|
||||||
DISPLAY = ":10"
|
|
||||||
args = "/usr/bin/Xephyr -ac -host-cursor -screen 800x600 %s" % DISPLAY
|
|
||||||
args = args.split()
|
|
||||||
(xephyr_pid, ign1, ign2, ign3) = gobject.spawn_async(args, flags=gobject.SPAWN_STDERR_TO_DEV_NULL | gobject.SPAWN_STDOUT_TO_DEV_NULL)
|
|
||||||
print "Xepyhr pid is %d" % xephyr_pid
|
|
||||||
|
|
||||||
(shell, home) = change_user(user)
|
|
||||||
|
|
||||||
args = "/bin/dbus-daemon --session --print-address".split()
|
|
||||||
(dbus_pid, ign1, dbus_stdout, ign3) = gobject.spawn_async(args, flags=gobject.SPAWN_STDERR_TO_DEV_NULL, standard_output=True)
|
|
||||||
dbus_file = os.fdopen(dbus_stdout)
|
|
||||||
addr = dbus_file.readline()
|
|
||||||
addr = addr.strip()
|
|
||||||
print "dbus-daemon pid is %d, session bus address is %s" % (dbus_pid, addr)
|
|
||||||
dbus_file.close()
|
|
||||||
|
|
||||||
os.environ["DISPLAY"] = DISPLAY
|
|
||||||
os.environ["DBUS_SESSION_BUS_ADDRESS"] = addr
|
|
||||||
os.environ["HOME"] = home
|
|
||||||
|
|
||||||
args = "/usr/bin/metacity"
|
|
||||||
(metacity_pid, ign1, ign2, ign3) = gobject.spawn_async([args], flags=gobject.SPAWN_STDERR_TO_DEV_NULL | gobject.SPAWN_STDOUT_TO_DEV_NULL)
|
|
||||||
|
|
||||||
print "\n"
|
|
||||||
(shell_pid, ign1, ign2, ign3) = gobject.spawn_async([shell], flags=gobject.SPAWN_LEAVE_DESCRIPTORS_OPEN | gobject.SPAWN_CHILD_INHERITS_STDIN | gobject.SPAWN_DO_NOT_REAP_CHILD)
|
|
||||||
gobject.child_watch_add(shell_pid, shell_watch_cb)
|
|
||||||
try:
|
|
||||||
gtk.main()
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
os.kill(dbus_pid, 9)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
os.kill(metacity_pid, 9)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
41
sugar/sugar
41
sugar/sugar
@ -3,7 +3,9 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
curdir = os.path.dirname(__file__)
|
import pygtk
|
||||||
|
pygtk.require('2.0')
|
||||||
|
import gobject
|
||||||
|
|
||||||
def append_to_python_path(path):
|
def append_to_python_path(path):
|
||||||
if os.environ.has_key('PYTHONPATH'):
|
if os.environ.has_key('PYTHONPATH'):
|
||||||
@ -11,6 +13,40 @@ def append_to_python_path(path):
|
|||||||
else:
|
else:
|
||||||
os.environ['PYTHONPATH'] = path
|
os.environ['PYTHONPATH'] = path
|
||||||
|
|
||||||
|
def start_dbus():
|
||||||
|
curdir = os.path.dirname(__file__)
|
||||||
|
args = "/bin/dbus-daemon --session --print-address".split()
|
||||||
|
(dbus_pid, ign1, dbus_stdout, ign3) = gobject.spawn_async(args, flags=gobject.SPAWN_STDERR_TO_DEV_NULL, standard_output=True)
|
||||||
|
dbus_file = os.fdopen(dbus_stdout)
|
||||||
|
addr = dbus_file.readline()
|
||||||
|
addr = addr.strip()
|
||||||
|
print "dbus-daemon pid is %d, session bus address is %s" % (dbus_pid, addr)
|
||||||
|
dbus_file.close()
|
||||||
|
|
||||||
|
os.environ["DBUS_SESSION_BUS_ADDRESS"] = addr
|
||||||
|
|
||||||
|
return dbus_pid
|
||||||
|
|
||||||
|
def stop_dbus(dbus_pid):
|
||||||
|
try:
|
||||||
|
print 'Closing dbus-daemon, pid %d' % (dbus_pid)
|
||||||
|
os.kill(dbus_pid, 9)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
dbus_daemon_pid = None
|
||||||
|
for arg in sys.argv:
|
||||||
|
if arg == '--test-user':
|
||||||
|
user = sys.argv[i + 1]
|
||||||
|
user_dir = os.path.expanduser('~/.sugar-' + user)
|
||||||
|
os.environ['SUGAR_NICK_NAME'] = user
|
||||||
|
os.environ['SUGAR_USER_DIR'] = user_dir
|
||||||
|
dbus_daemon_pid = start_dbus()
|
||||||
|
started_dbus = True
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
curdir = os.path.dirname(__file__)
|
||||||
if curdir == '.':
|
if curdir == '.':
|
||||||
basedir = os.path.dirname(os.getcwd())
|
basedir = os.path.dirname(os.getcwd())
|
||||||
else:
|
else:
|
||||||
@ -37,3 +73,6 @@ if console:
|
|||||||
from sugar.session import session
|
from sugar.session import session
|
||||||
|
|
||||||
session.start(console)
|
session.start(console)
|
||||||
|
|
||||||
|
if dbus_daemon_pid:
|
||||||
|
stop_dbus(dbus_daemon_pid)
|
||||||
|
Loading…
Reference in New Issue
Block a user