Exemple #1
0
    def configure_slice(self):
        logging.info('Configuring Ice slice.')

        slicedir = Ice.getSliceDir()
        if not slicedir:
            slicedir = ["-I/usr/share/Ice/slice", "-I/usr/share/slice"]
        else:
            slicedir = ['-I' + slicedir]

        try:
            logging.info('Trying to retrieve slice dynamically from server...')
            op = None
            if IcePy.intVersion() < 30500L:
                # Old 3.4 signature with 9 parameters
                op = IcePy.Operation('getSlice', Ice.OperationMode.Idempotent,
                                     Ice.OperationMode.Idempotent, True, (),
                                     (), (), IcePy._t_string, ())
            else:
                # New 3.5 signature with 10 parameters.
                op = IcePy.Operation('getSlice', Ice.OperationMode.Idempotent,
                                     Ice.OperationMode.Idempotent, True, None,
                                     (), (), (),
                                     ((), IcePy._t_string, False, 0), ())

            slice = op.invoke(self.prx, ((), None))
            (dynslicefiledesc,
             dynslicefilepath) = tempfile.mkstemp(suffix='.ice')
            dynslicefile = os.fdopen(dynslicefiledesc, 'w')
            dynslicefile.write(slice)
            dynslicefile.flush()
            Ice.loadSlice('', slicedir + [dynslicefilepath])
            dynslicefile.close()
            os.remove(dynslicefilepath)

        except Exception:
            logging.error('Can not retrieve slice from server...')
            raise SystemExit(1)
Exemple #2
0
    # ifself is taken from http://wiki.mumble.info/wiki/Mice
    slicedir = Ice.getSliceDir()
    if not slicedir:
        # Some platforms incorrectly return None as the slice path
        # try to work around this for the known ones.
        slicedir = ["-I/usr/share/Ice/slice", "-I/usr/share/slice"]
    else:
        slicedir = ['-I' + slicedir]

    try:
        # Trying to retrieve slice dynamically from server...
        # Check IcePy version as this internal function changes between version.
        # In case it breaks with future versions use slice2py and search for
        # "IcePy.Operation('getSlice'," for updates in the generated bindings.
        op = None
        if IcePy.intVersion() < 30500:
            # Old 3.4 signature with 9 parameters
            op = IcePy.Operation('getSlice', Ice.OperationMode.Idempotent, Ice.OperationMode.Idempotent, True, (), (), (), IcePy._t_string, ())

        else:
            # New 3.5 signature with 10 parameters.
            op = IcePy.Operation('getSlice', Ice.OperationMode.Idempotent, Ice.OperationMode.Idempotent, True, None, (), (), (), ((), IcePy._t_string, False, 0), ())

        slice = op.invoke(prx, ((), None))
        (dynslicefiledesc, dynslicefilepath)  = tempfile.mkstemp(suffix = '.ice')
        dynslicefile = os.fdopen(dynslicefiledesc, 'w')
        dynslicefile.write(slice)
        dynslicefile.flush()
        Ice.loadSlice('', slicedir + [dynslicefilepath])
        dynslicefile.close()
        os.remove(dynslicefilepath)
Exemple #3
0
slicedir = Ice.getSliceDir()
if not slicedir:
    # Some platforms incorrectly return None as the slice path
    # try to work around this for the known ones.
    slicedir = ["-I/usr/share/Ice/slice", "-I/usr/share/slice"]
else:
    slicedir = ['-I' + slicedir]

try:
    print "Trying to retrieve slice dynamically from server...",
    # Check IcePy version as this internal function changes between version.
    # In case it breaks with future versions use slice2py and search for
    # "IcePy.Operation('getSlice'," for updates in the generated bindings.
    op = None
    if IcePy.intVersion() < 30500L:
        # Old 3.4 signature with 9 parameters
        op = IcePy.Operation('getSlice', Ice.OperationMode.Idempotent, Ice.OperationMode.Idempotent, True, (), (), (), IcePy._t_string, ())

    else:
        # New 3.5 signature with 10 parameters.
        op = IcePy.Operation('getSlice', Ice.OperationMode.Idempotent, Ice.OperationMode.Idempotent, True, None, (), (), (), ((), IcePy._t_string, False, 0), ())

    slice = op.invoke(prx, ((), None))
    (dynslicefiledesc, dynslicefilepath)  = tempfile.mkstemp(suffix = '.ice')
    dynslicefile = os.fdopen(dynslicefiledesc, 'w')
    dynslicefile.write(slice)
    dynslicefile.flush()
    Ice.loadSlice('', slicedir + [dynslicefilepath])
    dynslicefile.close()
    os.remove(dynslicefilepath)
slicedir = Ice.getSliceDir()
if not slicedir:
    # Some platforms incorrectly return None as the slice path
    # try to work around this for the known ones.
    slicedir = ["-I/usr/share/Ice/slice", "-I/usr/share/slice"]
else:
    slicedir = ['-I' + slicedir]

try:
    print "Trying to retrieve slice dynamically from server...",
    # Check IcePy version as this internal function changes between version.
    # In case it breaks with future versions use slice2py and search for
    # "IcePy.Operation('getSlice'," for updates in the generated bindings.
    op = None
    if IcePy.intVersion() < 30500L:
        # Old 3.4 signature with 9 parameters
        op = IcePy.Operation('getSlice', Ice.OperationMode.Idempotent,
                             Ice.OperationMode.Idempotent, True, (), (), (),
                             IcePy._t_string, ())

    else:
        # New 3.5 signature with 10 parameters.
        op = IcePy.Operation('getSlice', Ice.OperationMode.Idempotent,
                             Ice.OperationMode.Idempotent, True, None, (), (),
                             (), ((), IcePy._t_string, False, 0), ())

    slice = op.invoke(prx, ((), None))
    (dynslicefiledesc, dynslicefilepath) = tempfile.mkstemp(suffix='.ice')
    dynslicefile = os.fdopen(dynslicefiledesc, 'w')
    dynslicefile.write(slice)
Exemple #5
0
 def connect(self, ctxtype):
     ctxtype = ctxtype.strip().upper()
     if ctxtype.lower() not in ('ice', 'grpc'):
         raise ValueError('You have specified an invalid connection type.')
     _cxcfg = self.cfg[ctxtype]
     self.cfg[ctxtype]['spec'] = os.path.join(
         os.path.abspath(os.path.expanduser(self.cfg[ctxtype]['spec'])))
     # ICE START
     _props = {
         'ImplicitContext': 'Shared',
         'Default.EncodingVersion': '1.0',
         'MessageSizeMax': str(self.cfg['ICE']['max_size'])
     }
     _prop_data = Ice.createProperties()
     for k, v in _props.items():
         _prop_data.setProperty('Ice.{0}'.format(k), v)
     _conn = Ice.InitializationData()
     _conn.properties = _prop_data
     self.ice = Ice.initialize(_conn)
     _host = 'Meta:{0} -h {1} -p {2} -t 1000'.format(
         self.cfg['ICE']['proto'], self.cfg['ICE']['host'],
         self.cfg['ICE']['port'])
     _ctx = self.ice.stringToProxy(_host)
     # I owe a lot of neat tricks here to:
     # https://raw.githubusercontent.com/mumble-voip/mumble-scripts/master/Helpers/mice.py
     # Namely, the load-slice-from-server stuff especially
     _slicedir = Ice.getSliceDir()
     if not _slicedir:
         _slicedir = ["-I/usr/share/Ice/slice", "-I/usr/share/slice"]
     else:
         _slicedir = ['-I' + _slicedir]
     if self.cfg['ICE']['slice'] == '':
         if IcePy.intVersion() < 30500:
             # Old 3.4 signature with 9 parameters
             _op = IcePy.Operation('getSlice', Ice.OperationMode.Idempotent,
                                   Ice.OperationMode.Idempotent, True, (),
                                   (), (), IcePy._t_string, ())
         else:
             # New 3.5 signature with 10 parameters.
             _op = IcePy.Operation('getSlice', Ice.OperationMode.Idempotent,
                                   Ice.OperationMode.Idempotent, True, None,
                                   (), (), (),
                                   ((), IcePy._t_string, False, 0), ())
         _slice = _op.invoke(_ctx, ((), None))
         (_filedesc, _filepath) = tempfile.mkstemp(suffix='.ice')
         _slicefile = os.fdopen(_filedesc, 'w')
         _slicefile.write(_slice)
         _slicefile.flush()
         Ice.loadSlice('', _slicedir + [_filepath])
         _slicefile.close()
         os.remove(_filepath)
     else:  # A .ice file was explicitly defined in the cfg
         _slicedir.append(self.cfg[ctxtype]['spec'])
         Ice.loadSlice('', _slicedir)
     import Murmur
     self.conn = {}
     if self.cfg['AUTH']['read'] != '':
         _secret = self.ice.getImplicitContext().put(
             "secret", self.cfg['AUTH']['read'])
         self.conn['read'] = Murmur.MetaPrx.checkedCast(_ctx)
     else:
         self.conn['read'] = False
     if self.cfg['AUTH']['write'] != '':
         _secret = self.ice.getImplicitContext().put(
             "secret", self.cfg['AUTH']['write'])
         self.conn['write'] = Murmur.MetaPrx.checkedCast(_ctx)
     else:
         self.conn['write'] = False
     return ()