From a32007ec7a87726f5ab780745382a47b07c40997 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 22 May 2006 22:14:22 -0400 Subject: [PATCH] Add two env vars to set nick name and user dir --- sugar/env.py | 11 ++++++++++- sugar/p2p/Buddy.py | 6 ++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/sugar/env.py b/sugar/env.py index ffea539a..82e47b1d 100644 --- a/sugar/env.py +++ b/sugar/env.py @@ -6,7 +6,16 @@ except ImportError: from sugar.__installed__ import * def get_user_dir(): - return os.path.expanduser('~/.sugar/') + if os.environ.has_key('SUGAR_USER_DIR'): + return os.environ['SUGAR_USER_DIR'] + else: + 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 def get_data_file(filename): for data_dir in get_data_dirs(): diff --git a/sugar/p2p/Buddy.py b/sugar/p2p/Buddy.py index ea08c216..c98ce965 100644 --- a/sugar/p2p/Buddy.py +++ b/sugar/p2p/Buddy.py @@ -82,8 +82,10 @@ class Owner(Buddy): """Class representing the owner of this machine/instance.""" def __init__(self, group): self._group = group - - nick = pwd.getpwuid(os.getuid())[0] + + nick = env.get_nick_name() + if not nick: + nick = pwd.getpwuid(os.getuid())[0] if not nick or not len(nick): nick = "n00b"