Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/sugar
blob: 6c9cc6e04936f889adaab67e192139c1c0111562 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python

import sys
import os

curdir = os.path.dirname(__file__)

def append_to_python_path(path):
	if os.environ.has_key('PYTHONPATH'):
		os.environ['PYTHONPATH'] += ':' + path
	else:
		os.environ['PYTHONPATH'] = path

if curdir == '.':
	basedir = os.path.dirname(os.getcwd())
else:
	basedir = os.path.dirname(curdir)

console = False

if os.path.isfile(os.path.join(curdir, '__uninstalled__.py')):
	if basedir == '':
		print 'Running sugar from current directory...'
	else:
		print 'Running sugar from ' + basedir + ' ...'
	sys.path.insert(0, basedir)
	append_to_python_path(basedir)
	console = True
else:
	print 'Running the installed sugar...'
	
append_to_python_path(os.path.expanduser('~/.sugar/activities'))

if console:
	print 'Redirecting output to the console, press ctrl+d to open it.'
	
from sugar.session import session

session.start(console)