Fix bug in path initialization

This commit is contained in:
Marco Pesenti Gritti 2006-06-21 16:35:57 -04:00
parent 26684a091c
commit 43b5e7e1a1

View File

@ -9,6 +9,13 @@ import pygtk
pygtk.require('2.0') pygtk.require('2.0')
import gobject import gobject
def add_to_python_path(path):
sys.path.insert(0, path)
if os.environ.has_key('PYTHONPATH'):
os.environ['PYTHONPATH'] += ':' + path
else:
os.environ['PYTHONPATH'] = path
def start_dbus(): def start_dbus():
curdir = os.path.dirname(__file__) curdir = os.path.dirname(__file__)
args = "/bin/dbus-daemon --session --print-address".split() args = "/bin/dbus-daemon --session --print-address".split()
@ -53,14 +60,13 @@ if not os.environ.has_key("SUGAR_NICK_NAME"):
curdir = os.path.abspath(os.path.dirname(__file__)) curdir = os.path.abspath(os.path.dirname(__file__))
basedir = os.path.dirname(curdir) basedir = os.path.dirname(curdir)
import sugar.env
if os.path.isfile(os.path.join(basedir, 'sugar/__uninstalled__.py')): if os.path.isfile(os.path.join(basedir, 'sugar/__uninstalled__.py')):
print 'Running sugar from ' + basedir + ' ...' print 'Running sugar from ' + basedir + ' ...'
sugar.env.add_to_python_path(basedir) add_to_python_path(basedir)
sugar.env.add_to_python_path(os.path.join(basedir, 'shell')) add_to_python_path(os.path.join(basedir, 'shell'))
else: else:
sugar.env.add_to_python_path(os.path.join(sugar.env.get_data_dir(), 'shell')) import sugar.env
add_to_python_path(os.path.join(sugar.env.get_data_dir(), 'shell'))
print 'Running the installed sugar...' print 'Running the installed sugar...'
print 'Redirecting output to the console, press ctrl+d to open it.' print 'Redirecting output to the console, press ctrl+d to open it.'