Improve mumo behavior with platforms in which Ice.getSliceDir behaves unexpected

This commit is contained in:
Stefan Hacker 2013-03-23 17:16:31 +01:00
parent 7c21c98824
commit 1aac7ac6df
2 changed files with 27 additions and 6 deletions

View File

@ -16,6 +16,11 @@ port = 6502
slice =
; Semicolon seperated list of slice include directories
; to consider. This is only used on legacy platforms
; with old or broken Ice versions.
slicedirs = /usr/share/slice;/usr/share/Ice/slice
; Shared secret between the MuMo and the Murmur
; server. For security reason you should always
; use a shared secret.

28
mumo.py
View File

@ -59,7 +59,7 @@ default.update({'ice':(('host', str, '127.0.0.1'),
('port', int, 6502),
('slice', str, ''),
('secret', str, ''),
('slicedir', str, '/usr/share/slice'),
('slicedirs', str, '/usr/share/slice;/usr/share/Ice/slice'),
('watchdog', int, 30),
('callback_host', str, '127.0.0.1'),
('callback_port', int, -1)),
@ -70,6 +70,25 @@ default.update({'ice':(('host', str, '127.0.0.1'),
'log':(('level', int, logging.DEBUG),
('file', str, 'mumo.log'))})
def load_slice(slice):
#
#--- Loads a given slicefile, used by dynload_slice and fsload_slice
# This function works around a number of differences between Ice python
# versions and distributions when it comes to slice include directories.
#
fallback_slicedirs = ["-I" + sdir for sdir in cfg.ice.slicedirs.split(';')]
if not hasattr(Ice, "getSliceDir"):
Ice.loadSlice('-I%s %s' % (" ".join(fallback_slicedirs), slice))
else:
slicedir = Ice.getSliceDir()
if not slicedir:
slicedirs = fallback_slicedirs
else:
slicedirs = ['-I' + slicedir]
Ice.loadSlice('', slicedirs + [slice])
def dynload_slice(prx):
#
#--- Dynamically retrieves the slice file from the target server
@ -82,7 +101,7 @@ def dynload_slice(prx):
dynslicefile = os.fdopen(dynslicefiledesc, 'w')
dynslicefile.write(slice)
dynslicefile.flush()
Ice.loadSlice('', ['-I' + Ice.getSliceDir(), dynslicefilepath])
load_slice(dynslicefilepath)
dynslicefile.close()
os.remove(dynslicefilepath)
except Exception, e:
@ -96,10 +115,7 @@ def fsload_slice(slice):
#--- Load slice from file system
#
debug("Loading slice from filesystem: %s" % slice)
if not hasattr(Ice, "getSliceDir"):
Ice.loadSlice('-I%s %s' % (cfg.ice.slicedir, slice))
else:
Ice.loadSlice('', ['-I' + Ice.getSliceDir(), slice])
load_slice(slice)
def do_main_program():
#