Dont break if PYTHONPATH is undefined

This commit is contained in:
Marco Pesenti Gritti 2006-05-18 16:42:56 -04:00
parent fd8a921d96
commit 8b24b5eaaa

View File

@ -5,6 +5,12 @@ import os
curdir = os.path.dirname(__file__) 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 == '.': if curdir == '.':
basedir = os.path.dirname(os.getcwd()) basedir = os.path.dirname(os.getcwd())
else: else:
@ -18,12 +24,12 @@ if os.path.isfile(os.path.join(curdir, '__uninstalled__.py')):
else: else:
print 'Running sugar from ' + basedir + ' ...' print 'Running sugar from ' + basedir + ' ...'
sys.path.insert(0, basedir) sys.path.insert(0, basedir)
os.environ['PYTHONPATH'] += ':' + basedir append_to_python_path(basedir)
console = True console = True
else: else:
print 'Running the installed sugar...' print 'Running the installed sugar...'
os.environ['PYTHONPATH'] += ':' + os.path.expanduser('~/.sugar/activities') append_to_python_path(os.path.expanduser('~/.sugar/activities'))
if console: if console:
print 'Redirecting output to the console, press ctrl+d to open it.' print 'Redirecting output to the console, press ctrl+d to open it.'