2006-05-12 08:34:20 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
2006-06-16 21:48:44 +02:00
|
|
|
import pwd
|
|
|
|
import random
|
2006-05-12 08:34:20 +02:00
|
|
|
|
2006-07-27 10:35:59 +02:00
|
|
|
import pygtk
|
|
|
|
pygtk.require('2.0')
|
|
|
|
|
2006-07-19 13:38:24 +02:00
|
|
|
def add_to_bin_path(path):
|
|
|
|
if os.environ.has_key('PATH'):
|
|
|
|
old_path = os.environ['PATH']
|
|
|
|
os.environ['PATH'] = path + ':' + old_path
|
|
|
|
else:
|
|
|
|
os.environ['PATH'] = path
|
|
|
|
|
2006-06-21 22:35:57 +02:00
|
|
|
def add_to_python_path(path):
|
|
|
|
sys.path.insert(0, path)
|
|
|
|
if os.environ.has_key('PYTHONPATH'):
|
2006-07-10 16:16:30 +02:00
|
|
|
old_path = os.environ['PYTHONPATH']
|
|
|
|
os.environ['PYTHONPATH'] = path + ':' + old_path
|
2006-06-21 22:35:57 +02:00
|
|
|
else:
|
|
|
|
os.environ['PYTHONPATH'] = path
|
|
|
|
|
2006-05-23 04:40:49 +02:00
|
|
|
i = 0
|
|
|
|
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
|
|
|
|
i += 1
|
|
|
|
|
2006-06-16 21:48:44 +02:00
|
|
|
if not os.environ.has_key("SUGAR_NICK_NAME"):
|
|
|
|
nick = pwd.getpwuid(os.getuid())[0]
|
|
|
|
if not nick or not len(nick):
|
|
|
|
nick = "Guest %d" % random.randint(1, 10000)
|
|
|
|
os.environ['SUGAR_NICK_NAME'] = nick
|
|
|
|
os.environ['SUGAR_USER_DIR'] = os.path.expanduser('~/.sugar')
|
|
|
|
|
2006-06-21 20:23:18 +02:00
|
|
|
curdir = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
basedir = os.path.dirname(curdir)
|
|
|
|
|
|
|
|
if os.path.isfile(os.path.join(basedir, 'sugar/__uninstalled__.py')):
|
|
|
|
print 'Running sugar from ' + basedir + ' ...'
|
2006-07-19 13:38:24 +02:00
|
|
|
add_to_bin_path(os.path.join(basedir, 'shell'))
|
2006-06-21 22:35:57 +02:00
|
|
|
add_to_python_path(basedir)
|
|
|
|
add_to_python_path(os.path.join(basedir, 'shell'))
|
2006-05-12 08:34:20 +02:00
|
|
|
else:
|
2006-06-21 22:35:57 +02:00
|
|
|
import sugar.env
|
|
|
|
add_to_python_path(os.path.join(sugar.env.get_data_dir(), 'shell'))
|
2006-05-17 06:12:01 +02:00
|
|
|
print 'Running the installed sugar...'
|
2006-07-12 22:17:57 +02:00
|
|
|
|
|
|
|
from Emulator import Emulator
|
|
|
|
|
|
|
|
# FIXE Don't run the emulator on the OLPC
|
|
|
|
emulator = Emulator()
|
|
|
|
emulator.start()
|
2006-05-18 07:17:40 +02:00
|
|
|
|
2006-07-12 22:17:57 +02:00
|
|
|
print 'Redirecting output to the console, press F3 to open it.'
|
2006-05-16 22:32:08 +02:00
|
|
|
|
2006-07-12 13:20:41 +02:00
|
|
|
from Session import Session
|
2006-05-16 22:32:08 +02:00
|
|
|
|
2006-06-20 04:39:57 +02:00
|
|
|
session = Session()
|
2006-05-23 22:02:13 +02:00
|
|
|
session.start()
|