Simplify profile/nick name code. Use SUGAR_NICK_NAME env.

This commit is contained in:
Marco Pesenti Gritti 2006-08-12 21:34:06 +02:00
parent 2636bc63d0
commit d41c761e02
3 changed files with 7 additions and 27 deletions

View File

@ -71,7 +71,7 @@ class Session:
process.start()
console = ConsoleWindow()
sugar.logger.start('Shell', console)
#sugar.logger.start('Shell', console)
process = MatchboxProcess()
process.start()

View File

@ -24,22 +24,6 @@ def add_to_python_path(path):
else:
os.environ['PYTHONPATH'] = path
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
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')
curdir = os.path.abspath(os.path.dirname(__file__))
basedir = os.path.dirname(curdir)

View File

@ -1,5 +1,6 @@
import os
import sys
import pwd
try:
from sugar.__uninstalled__ import *
@ -14,22 +15,17 @@ def add_to_python_path(path):
os.environ['PYTHONPATH'] = path
def get_user_dir():
if os.environ.has_key('SUGAR_USER_DIR'):
return os.environ['SUGAR_USER_DIR']
if os.environ.has_key('SUGAR_NICK_NAME'):
nick = get_nick_name()
return os.path.expanduser('~/.sugar-%s/' % nick)
else:
return os.path.expanduser('~/.sugar/')
def get_logging_level():
if os.environ.has_key('SUGAR_LOGGING_LEVEL'):
return os.environ['SUGAR_LOGGING_LEVEL']
else:
return 'warning'
return os.path.expanduser('~/.sugar')
def get_nick_name():
if os.environ.has_key('SUGAR_NICK_NAME'):
return os.environ['SUGAR_NICK_NAME']
else:
return None
return pwd.getpwuid(os.getuid())[0]
def get_data_dir():
return sugar_data_dir