Install services in user dir if dbus is recent enough.

This commit is contained in:
Marco Pesenti Gritti 2006-11-02 20:16:36 +01:00
parent 59c777e109
commit 561169809b
3 changed files with 20 additions and 5 deletions

View File

@ -70,7 +70,7 @@ for i in range(1, len(sys.argv)):
emulator = Emulator(fullscreen) emulator = Emulator(fullscreen)
emulator.start() emulator.start()
# FIXME temporary until dbus support services in home dir if env.get_dbus_version() < '0.95':
if not os.path.isdir('/tmp/sugar-services'): if not os.path.isdir('/tmp/sugar-services'):
os.mkdir('/tmp/sugar-services') os.mkdir('/tmp/sugar-services')

View File

@ -10,10 +10,13 @@ class _ServiceParser(ConfigParser):
class _ServiceManager(object): class _ServiceManager(object):
def __init__(self): def __init__(self):
if env.get_dbus_version() < '0.95':
self._path = '/tmp/sugar-services' self._path = '/tmp/sugar-services'
else:
self._path = os.path.expanduser('~/.local/share/dbus-1/services')
if not os.path.isdir(self._path): if not os.path.isdir(self._path):
os.mkdir(self._path) os.makedirs(self._path)
def add(self, bundle): def add(self, bundle):
name = bundle.get_service_name() name = bundle.get_service_name()

View File

@ -56,3 +56,15 @@ def get_dbus_config():
def get_shell_bin_dir(): def get_shell_bin_dir():
return sugar_shell_bin_dir return sugar_shell_bin_dir
_dbus_version = None
def get_dbus_version():
global _dbus_version
if _dbus_version == None:
f = os.popen('dbus-daemon --version')
version_line = f.readline()
if version_line:
splitted_line = version_line.split()
_dbus_version = splitted_line[len(splitted_line) - 1]
f.close()
return _dbus_version