A pass at fixing single-computer with more than one sugar instance work
This commit is contained in:
parent
c7075255f8
commit
cd3d98cb77
@ -6,6 +6,7 @@ import os
|
||||
import string
|
||||
import random
|
||||
from sugar import util
|
||||
from sugar import env
|
||||
|
||||
def _get_local_ip_address(ifname):
|
||||
"""Call Linux specific bits to retrieve our own IP address."""
|
||||
@ -196,7 +197,8 @@ class PresenceService(gobject.GObject):
|
||||
buddy.add_service(service)
|
||||
except KeyError:
|
||||
# Should this service mark the owner?
|
||||
if service.get_address() in self._local_addrs.values():
|
||||
owner_nick = env.get_nick_name()
|
||||
if name == owner_nick and service.get_address() in self._local_addrs.values():
|
||||
buddy = Buddy.Owner(service)
|
||||
self._owner = buddy
|
||||
print "Set owner to %s" % name
|
||||
|
@ -3,7 +3,6 @@ from sugar.presence import Service
|
||||
from sugar.presence import Buddy
|
||||
from sugar.presence import PresenceService
|
||||
from sugar.p2p import Stream
|
||||
import pwd
|
||||
import os
|
||||
import random
|
||||
import base64
|
||||
@ -16,11 +15,6 @@ class ShellOwner(object):
|
||||
server portion of the Owner, paired with the client portion in Buddy.py."""
|
||||
def __init__(self):
|
||||
nick = env.get_nick_name()
|
||||
if not nick:
|
||||
nick = pwd.getpwuid(os.getuid())[0]
|
||||
if not nick or not len(nick):
|
||||
nick = "Guest"
|
||||
|
||||
user_dir = env.get_user_dir()
|
||||
if not os.path.exists(user_dir):
|
||||
try:
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
import sys
|
||||
import os
|
||||
import pwd
|
||||
import random
|
||||
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
@ -47,6 +49,13 @@ for arg in sys.argv:
|
||||
started_dbus = True
|
||||
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.dirname(__file__)
|
||||
if curdir == '.':
|
||||
basedir = os.path.dirname(os.getcwd())
|
||||
|
Loading…
Reference in New Issue
Block a user