Skip to content

Commit

Permalink
Improve mumo behavior with platforms in which Ice.getSliceDir behaves…
Browse files Browse the repository at this point in the history
… unexpected
  • Loading branch information
hacst committed Mar 23, 2013
1 parent 7c21c98 commit 1aac7ac
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
5 changes: 5 additions & 0 deletions mumo.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
28 changes: 22 additions & 6 deletions mumo.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
('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)),
Expand All @@ -70,6 +70,25 @@
'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
Expand All @@ -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:
Expand All @@ -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():
#
Expand Down

0 comments on commit 1aac7ac

Please sign in to comment.