def load_slice_files(icedir=os.path.normpath("../../Ice")): """ Load slice files. This can be done dynamically in Python. Note that this requires the ICEROOT environment variable to be (correctly) set. """ import Ice; # The following line throws an exception if ICEROOT is not an environment variable: iceroot = os.environ["ICEROOT"]; if not iceroot: print "WARNING: ICEROOT is not defined! It's required to load slice files dynamically!"; def create_load_string(target_file): """ Create a string which loads Slice definition files. @param target_file File to load. @return Formatted string. """ return "-I\"%s/slice\" -I\"%s\" --all %s/%s" % ( iceroot, icedir, icedir, target_file); ice_files = [ file for file in os.listdir(icedir) if file.endswith(".ice") ]; for file in ice_files: debug_reporter("Loading %s..." % file); Ice.loadSlice(create_load_string(file));
def __init__(self, slicePath, sliceOpts=''): self.slicePath = slicePath self.sliceOpts = sliceOpts self.RoboComps = dict() loadCommand = self.sliceOpts+' '+self.slicePath print 'Loading SLICE file: "'+loadCommand+'"' print '1' modulesA = [ module for module in sys.modules ] print '2' try: print '3', loadCommand Ice.loadSlice(loadCommand) print '4' modulesB = [ module for module in sys.modules ] newModules = [ module for module in modulesB if not module in modulesA ] for newModule in newModules: print ' New module: ' + newModule self.RoboComps[str(newModule)] = __import__(newModule) try: global global_ic global_ic = Ice.initialize(sys.argv) except: print ' global_ic' except: traceback.print_exc(file=sys.stdout) print 'Error loading ' + loadCommand + '.' finally: print 'Done loading ' + self.slicePath + '.'
def setup(bot): global _server,_meta bot.config.module_config('mumble_host',[None,'Host for mumble server']) bot.config.module_config('mumble_port',[0,'Port for mumble server']) bot.config.module_config('mumble_secret',[None,'Secret for mumble server']) if not bot.config.mumble_host or not bot.config.mumble_port: return prxstr = "s/1 -t:tcp -h %s -p %d -t 1000" % (bot.config.mumble_host,bot.config.mumble_port) meta_prxstr = "Meta:tcp -h %s -p %d -t 1000" % (bot.config.mumble_host,bot.config.mumble_port) props = Ice.createProperties() props.setProperty("Ice.ImplicitContext", "Shared") idata = Ice.InitializationData() idata.properties = props ice = Ice.initialize(idata) prx = ice.stringToProxy(str(prxstr)) prx_meta = ice.stringToProxy(str(meta_prxstr)) try: slice = IcePy.Operation('getSlice', Ice.OperationMode.Idempotent, Ice.OperationMode.Idempotent, True, (), (), (), IcePy._t_string, ()).invoke(prx_meta, ((), None)) (dynslicefiledesc, dynslicefilepath) = tempfile.mkstemp(suffix = '.ice') dynslicefile = os.fdopen(dynslicefiledesc, 'w') dynslicefile.write(slice) dynslicefile.flush() Ice.loadSlice('', ['-I' + Ice.getSliceDir(), dynslicefilepath]) dynslicefile.close() os.remove(dynslicefilepath) import Murmur if bot.config.mumble_secret: ice.getImplicitContext().put("secret", str(bot.config.mumble_secret)) _server = Murmur.ServerPrx.checkedCast(prx) _meta = Murmur.MetaPrx.checkedCast(prx_meta) bot.mumbleannounce = lambda msg: _server.sendMessageChannel(0,True,msg) except Exception, e: print str(e)
def connect(): # setup iceslice = os.environ.get('iceslice', '/usr/share/slice/Murmur.ice') iceincpath = os.environ.get('iceincpath', '/usr/share/Ice/slice') port = int(os.environ.get('port', '6502')) secret = os.environ.get('secret', '') messagemax = os.environ.get('messagemax', '65535') # open import Ice, sys Ice.loadSlice('--all -I%s %s' % (iceincpath, iceslice)) props = Ice.createProperties([]) props.setProperty('Ice.MessageSizeMax', str(messagemax)) props.setProperty('Ice.ImplicitContext', 'Shared') id = Ice.InitializationData() id.properties = props ice = Ice.initialize(id) ice.getImplicitContext().put('secret', secret) # init import Murmur meta = Murmur.MetaPrx.checkedCast(ice.stringToProxy('Meta:tcp -h 127.0.0.1 -p %s' % (port))) try: server = meta.getServer(1) except Murmur.InvalidSecretException: print 'Incorrect secret!' ice.shutdown() sys.exit(1) return server
def setup(self): """Sets up ICE""" if self.config.mumble: slicefile = self.config.mumble.slice icesecret = self.config.mumble.secret else: slicefile = self.config.mumble_slice icesecret = self.config.mumble_secret Ice.loadSlice('', ['-I' + Ice.getSliceDir(), slicefile ] ) prop = Ice.createProperties([]) prop.setProperty('Ice.Default.EncodingVersion', '1.0') prop.setProperty("Ice.ImplicitContext", "Shared") prop.setProperty("Ice.MessageSizeMax", "65535") idd = Ice.InitializationData() idd.properties = prop global ice ice = Ice.initialize(idd) ice.getImplicitContext().put("secret", icesecret.encode("utf-8")) global Murmur import Murmur ## Set up threaded checker print "set up and now starting timer thread" t = threading.Timer(20.0, mumble_auto_loop, [self]) t.start()
def __init__(self,slice = "Murmur.ice",proxy = "Meta:tcp -h 127.0.0.1 -p 6502"): Ice.loadSlice(slice) import Murmur ice = Ice.initialize() prx = ice.stringToProxy(proxy) self.murmur = Murmur.MetaPrx.checkedCast(prx) self.Murmur = Murmur
def __init__(self): try: Ice.loadSlice(self.settings['ice_file']) import Murmur self.mur = Murmur except: pass
def test_proxy_from(self): Ice.loadSlice('--all arch/foo.ice') import foo # locals to globals globals()['foo'] = foo class BarImpl(foo.Bar): def hello(): return 42 self.assertEqual(foo.BarPrx, WithIceService.proxy_from(BarImpl()))
def do_main_program(): # #--- Authenticator implementation # All of this has to go in here so we can correctly daemonize the tool # without loosing the file descriptors opened by the Ice module Ice.loadSlice(cfg.ice.slice) import Murmur class phpBBauthenticatorApp(Ice.Application): def run(self, args): self.shutdownOnInterrupt() if not self.initializeIceConnection(): return 1 # Serve till we are stopped self.communicator().waitForShutdown() if self.interrupted(): warning('Caught interrupt, shutting down') threadDB.disconnect() return 0 def initializeIceConnection(self): """ Establishes the two-way Ice connection and adds the authenticator to the configured servers """ ice = self.communicator() if cfg.glacier.enabled: #info('Connecting to Glacier2 server (%s:%d)', glacier_host, glacier_port) error('Glacier support not implemented yet') #TODO: Implement this info('Connecting to Ice server (%s:%d)', cfg.ice.host, cfg.ice.port) base = ice.stringToProxy('Meta:tcp -h %s -p %d' % (cfg.ice.host, cfg.ice.port)) try: meta = Murmur.MetaPrx.checkedCast(base) except Ice.LocalException, e: error('Could not connect to Ice server, error %d: %s', e.error, str(e).replace('\n', ' ')) return False adapter = ice.createObjectAdapterWithEndpoints('Callback.Client', 'tcp -h %s' % cfg.ice.host) adapter.activate() for server in meta.getBootedServers(): if not cfg.murmur.servers or server.id() in cfg.murmur.servers: info('Setting authenticator for server %d', server.id()) authprx = adapter.addWithUUID(phpBBauthenticator(server, adapter)) auth = Murmur.ServerUpdatingAuthenticatorPrx.uncheckedCast(authprx) server.setAuthenticator(auth) return True
def __init__(self, endpoint = 'tcp -h 127.0.0.1 -p 6502', secret = None): Ice.loadSlice('Murmur/Murmur.ice') prop = Ice.createProperties([]) prop.setProperty('Ice.ImplicitContext', 'Shared') idd = Ice.InitializationData() idd.properties = prop ice = Ice.initialize(idd) if secret is not None and secret != '': ice.getImplicitContext().put('secret', secret.encode('utf-8')) endpoint = 'Meta:'+endpoint prx = ice.stringToProxy(endpoint.encode('utf-8')) self.murmur = Murmur.MetaPrx.checkedCast(prx)
def __init__(self, secret): import Ice, IcePy # Setup Ice icepath = Ice.getSliceDir() prop = Ice.createProperties([]) prop.setProperty("Ice.ImplicitContext", "Shared") prop.setProperty("Ice.MessageSizeMax", "65535") idd = Ice.InitializationData() idd.properties = prop ice = Ice.initialize(idd) # Set the secret ice.getImplicitContext().put( "secret", secret ) # Initialization of a local connexion prx = ice.stringToProxy('Meta:tcp -h localhost -p 6502') prx.ice_ping() # Load the object definition Ice.loadSlice( '', ['-I' + icepath, "Murmur.ice" ] ) import Murmur self._murmur = Murmur.MetaPrx.checkedCast(prx) # Generic ACL ready to use self._password_ACL = [ Murmur.ACL( applyHere = True, applySubs = False, inherited = False, userid = -1, group = "all", allow = 0, deny = 910, ), Murmur.ACL( applyHere = True, applySubs = False, inherited = False, userid = -1, # The password is defined by adding a # in front of group name group = "", allow = 910, deny = 0, ) ] self._server = self._murmur.getServer(1)
def __init__(self, murmur_ice_path, murmur_host, murmur_icesecreatread, ice_port=6502, message_size_max=65535, exclude_keywords=[]): # Exclude names containing these keywords from being counted as users. # Useful for excluding bots self.exclude_keywords=exclude_keywords # Path to Slice and Murmur.ice Ice.loadSlice(f"--all -I{Ice.getSliceDir()} {murmur_ice_path}") props = Ice.createProperties([]) # MessageSizeMax; increase this value, if you get a MemoryLimitException. # Also check this value in murmur.ini of your Mumble-Server. # This value is being interpreted in kibiBytes. props.setProperty("Ice.MessageSizeMax", str(message_size_max)) props.setProperty("Ice.ImplicitContext", "Shared") props.setProperty("Ice.Default.EncodingVersion", "1.0") # Murmur 1.2.x uses Ice protocl 1.0 only id = Ice.InitializationData() id.properties = props self.ice = Ice.initialize(id) # Ice Password to get read access. # If there is no such var in your murmur.ini, this can have any value. # You can use the values of icesecret, icesecretread or icesecretwrite in your murmur.ini self.ice.getImplicitContext().put("secret", murmur_icesecreatread) import Murmur try: # Murmur host IP/DNS and ice_port should be provided self.meta = Murmur.MetaPrx.checkedCast(self.ice.stringToProxy(f'Meta:tcp -h {murmur_host} -p {ice_port}')) except (Ice.DNSException, Ice.ConnectionRefusedException): print('Connection refused.') exit(1) try: self.server=self.meta.getServer(1) except Murmur.InvalidSecretException: print('Given icesecreatread password is wrong.') exit(1) self.users = 0 self.excludedusers = 0 self.usersnotauth = 0 self._count_users()
def setup(self): """Sets up ICE""" slicefile = self.config.mumble_slice icesecret = self.config.mumble_secret Ice.loadSlice('', ['-I' + Ice.getSliceDir(), slicefile ] ) prop = Ice.createProperties([]) prop.setProperty("Ice.ImplicitContext", "Shared") prop.setProperty("Ice.MessageSizeMax", "65535") idd = Ice.InitializationData() idd.properties = prop global ice ice = Ice.initialize(idd) ice.getImplicitContext().put("secret", icesecret) global Murmur import Murmur ## Set up threaded checker t = threading.Timer(20.0, mumble_auto_loop, [self]) t.start()
def load_slice(self, proxy): mumble_slice = IcePy.Operation( 'getSlice', Ice.OperationMode.Idempotent, Ice.OperationMode.Idempotent, True, (), (), (), IcePy._t_string, () ).invoke(proxy, ((), None)) _, temp = tempfile.mkstemp(suffix='.ice') with open(temp, 'w') as slice_file: slice_file.write(mumble_slice) slice_file.flush() Ice.loadSlice('', ['-I' + Ice.getSliceDir(), temp]) os.remove(temp)
def loadSlice( slicefile ): """ Load the slice file with the correct include dir set, if possible. """ if hasattr( Ice, "getSliceDir" ): icepath = Ice.getSliceDir() else: icepath = None # Ice returns '' in getSliceDir() sometimes. (I kid you not.) if not icepath: try: from django.conf import settings except ImportError: # CTL is being used independently from MD icepath = None else: icepath = settings.SLICEDIR if not exists( join( icepath, "Ice", "SliceChecksumDict.ice" ) ): icepath = None if not icepath: # last resort when getSliceDir fails AND settings are wrong/unavailable, won't work for >=1.2.3 Ice.loadSlice( slicefile ) else: Ice.loadSlice( '', ['-I' + icepath, slicefile ] )
#!/usr/bin/env python # ********************************************************************** # # Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. # # ********************************************************************** import sys, traceback, Ice slice_dir = Ice.getSliceDir() if not slice_dir: print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Props.ice") import Demo def menu(): print(""" usage: 1: set properties (batch 1) 2: set properties (batch 2) c: show current properties s: shutdown server x: exit ?: help """) def show(admin):
import sys, os, Ice ROBOCOMP = '' try: ROBOCOMP = os.environ['ROBOCOMP'] except: print '$ROBOCOMP environment variable not set, using the default value /opt/robocomp' ROBOCOMP = '/opt/robocomp' if len(ROBOCOMP)<1: print 'ROBOCOMP environment variable not set! Exiting.' sys.exit() preStr = "-I/opt/robocomp/interfaces/ -I"+ROBOCOMP+"/interfaces/ --all /opt/robocomp/interfaces/" Ice.loadSlice(preStr+"JointMotor.ice") from RoboCompASRPublish import * class ASRPublishI(ASRPublish): def __init__(self, worker): self.worker = worker def newText(self, text, c): return self.worker.newText(text)
#!/usr/bin/env python # ********************************************************************** # # Copyright (c) 2003-2018 ZeroC, Inc. All rights reserved. # # ********************************************************************** import sys, traceback, time, Ice, IceStorm, getopt Ice.loadSlice('Clock.ice') import Demo class Publisher(Ice.Application): def usage(self): print("Usage: " + self.appName() + " [--datagram|--twoway|--oneway] [topic]") def run(self, args): try: opts, args = getopt.getopt(args[1:], '', ['datagram', 'twoway', 'oneway']) except getopt.GetoptError: self.usage() return 1 datagram = False twoway = False optsSet = 0 topicName = "time" for o, a in opts:
# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. # # This copy of Ice is licensed to you under the terms described in the # ICE_LICENSE file included in this distribution. # # ********************************************************************** import os, sys, traceback import Ice slice_dir = Ice.getSliceDir() if not slice_dir: print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Test.ice") import Test, TestI def run(args, communicator): communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000") adapter = communicator.createObjectAdapter("TestAdapter") ident = communicator.stringToIdentity("factory") adapter.add(TestI.RemoteCommunicatorFactoryI(), ident) adapter.activate() communicator.waitForShutdown() return True
#!/usr/bin/env python # ********************************************************************** # # Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. # # ********************************************************************** import sys, traceback, Ice, threading slice_dir = Ice.getSliceDir() if not slice_dir: print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Props.ice") import Demo class PropsI(Demo.Props, Ice.PropertiesAdminUpdateCallback): def __init__(self): self.called = False self.m = threading.Condition() def getChanges(self, current = None): self.m.acquire() try: # # Make sure that we have received the property updates before we # return the results. # while not self.called: self.m.wait()
#!/usr/bin/env python3 #/------------------------------------------------------------------------/ # Authors: Carlos Córdoba Ruiz & Álvaro Ángel-Moreno Pinilla #/------------------------------------------------------------------------/ import sys import Ice import os Ice.loadSlice('aux.ice --all -I .') import aux import drobots #Ice.loadSlice('drobots.ice') from robotcontroller import * class Factory(aux.ControllerFactory): def make(self, bot, container_robots, key,minas,nattackers, current = None): if bot.ice_isA("::drobots::Attacker") and nattackers<2: rc_servant = ControllerAttackerI(bot, container_robots,minas, key) rc_proxy = current.adapter.addWithUUID(rc_servant) print (rc_proxy) print ("Robot attacker") rc_proxy = current.adapter.createDirectProxy(rc_proxy.ice_getIdentity()) rc = aux.RobotControllerAttackerPrx.uncheckedCast(rc_proxy) else: rc_servant = ControllerDefenderI(bot, container_robots,minas, key)
#!/usr/bin/env python # ********************************************************************** # # Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. # # ********************************************************************** import sys, traceback, Ice Ice.loadSlice('Hello.ice') import Demo def menu(): print(""" usage: t: send greeting as twoway o: send greeting as oneway O: send greeting as batch oneway d: send greeting as datagram D: send greeting as batch datagram f: flush all batch requests T: set a timeout P: set a server delay S: switch secure mode on/off s: shutdown server x: exit ?: help """) class Client(Ice.Application): def run(self, args):
import os import sys from getpass import getpass from tempfile import mkdtemp import json import zipfile import time import shutil import Glacier2 import Ice Ice.loadSlice( '-I%s %s' % (Ice.getSliceDir(), os.path.abspath(os.path.join(__file__, '..', 'MotionDatabase.ice')))) import MotionDatabase from django.conf import settings from django.core.management.base import BaseCommand, CommandError from dataset.models import MotionFile, Annotation, Dataset from dataset.management.util import * DATA_PATH = os.path.abspath( os.path.join(__file__, '..', '..', '..', 'static', 'downloads')) ICE_CLIENT_CONFIG_PATH = os.path.abspath( os.path.join(__file__, '..', 'client.cfg')) def zipdir(basedir, archivename, callback_before=None, callback_after=None): assert os.path.isdir(basedir) with zipfile.ZipFile(archivename,
import os import pathlib import time import traceback import Ice import IceStorm from rich.console import Console, Text console = Console() Ice.loadSlice("-I ./src/ --all ./src/AprilBasedLocalization.ice") import RoboCompAprilBasedLocalization Ice.loadSlice("-I ./src/ --all ./src/AprilTags.ice") import RoboCompAprilTags Ice.loadSlice("-I ./src/ --all ./src/CameraSimple.ice") import RoboCompCameraSimple Ice.loadSlice("-I ./src/ --all ./src/GenericBase.ice") import RoboCompGenericBase Ice.loadSlice("-I ./src/ --all ./src/HandDetection.ice") import RoboCompHandDetection Ice.loadSlice("-I ./src/ --all ./src/JointMotor.ice") import RoboCompJointMotor Ice.loadSlice("-I ./src/ --all ./src/RGBD.ice") import RoboCompRGBD class tagsList(list): def __init__(self, iterable=list()): super(tagsList, self).__init__(iterable) def append(self, item): assert isinstance(item, RoboCompAprilTags.tag)
#!/usr/bin/env python # ********************************************************************** # # Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. # # This copy of Ice is licensed to you under the terms described in the # ICE_LICENSE file included in this distribution. # # ********************************************************************** import os, sys, traceback import Ice Ice.loadSlice('TestAMD.ice') import Test class InitialI(Test.Initial): def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() def pingPong(self, o, current=None): return Ice.Future.completed(o) def opOptionalException(self, a, b, o, current=None): f = Ice.Future() f.set_exception(Test.OptionalException(False, a, b, o)) return f def opDerivedException(self, a, b, o, current=None): f = Ice.Future()
#!/usr/bin/env python # ********************************************************************** # # Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved. # # This copy of Ice is licensed to you under the terms described in the # ICE_LICENSE file included in this distribution. # # ********************************************************************** import Ice, threading, sys Ice.loadSlice('-I. --all ClientPrivate.ice') import Test def test(b): if not b: raise RuntimeError('test assertion failed') class CallbackBase: def __init__(self): self._called = False self._cond = threading.Condition() def check(self): with self._cond: while not self._called: self._cond.wait() self._called = False
#!/usr/bin/python3 #-*- coding: utf-8 -*- import sys import Ice Ice.loadSlice('--all drobotsAux.ice') import drobots import drobotsAux import math import random class controllerAtacanteI(drobotsAux.controllerAtacante): def __init__(self): self.turno = 0 self.robot = None self.location = 0 self.minas = None self.robotsAmigos = None self.nombre = None self.anguloEnemigos = [] def setRobot(self, robot, minas, robotsAmigos, nombre, current=None): self.robot = robot self.minas = minas self.robotsAmigos = robotsAmigos self.nombre = nombre def turn(self, current=None): self.location = self.robot.location() print("ATACANTE-->Turno del robot atacante: " + str(self.nombre))
# # You should have received a copy of the GNU General Public License # along with RoboComp. If not, see <http://www.gnu.org/licenses/>. import sys, Ice, os from PySide2 import QtWidgets, QtCore ROBOCOMP = '' try: ROBOCOMP = os.environ['ROBOCOMP'] except KeyError: print '$ROBOCOMP environment variable not set, using the default value /opt/robocomp' ROBOCOMP = '/opt/robocomp' preStr = "-I/opt/robocomp/interfaces/ -I" + ROBOCOMP + "/interfaces/ --all /opt/robocomp/interfaces/" Ice.loadSlice(preStr + "CommonBehavior.ice") import RoboCompCommonBehavior additionalPathStr = '' icePaths = ['/opt/robocomp/interfaces'] try: SLICE_PATH = os.environ['SLICE_PATH'].split(':') for p in SLICE_PATH: icePaths.append(p) additionalPathStr += ' -I' + p + ' ' icePaths.append('/opt/robocomp/interfaces') except: print 'SLICE_PATH environment variable was not exported. Using only the default paths' pass ice_IMUPub = False
#!/usr/bin/env python # ********************************************************************** # # Copyright (c) 2003-2018 ZeroC, Inc. All rights reserved. # # This copy of Ice is licensed to you under the terms described in the # ICE_LICENSE file included in this distribution. # # ********************************************************************** import os, sys, traceback, threading, Ice, Glacier2 Ice.loadSlice("Callback.ice") import Test def test(b): if not b: raise RuntimeError('test assertion failed') class CallbackReceiverI(Test.CallbackReceiver): def __init__(self): self._received = False self._cond = threading.Condition() def callback(self, current): with self._cond: self._received = True self._cond.notify()
#!/usr/bin/env python # ********************************************************************** # # Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. # # ********************************************************************** import sys, threading, Ice, Glacier2 Ice.loadSlice('Callback.ice') import Demo def menu(): print(""" usage: t: send callback as twoway o: send callback as oneway O: send callback as batch oneway f: flush all batch requests v: set/reset override context field F: set/reset fake category s: shutdown server r: restart the session x: exit ?: help """) class CallbackReceiverI(Demo.CallbackReceiver): def callback(self, current=None): print("received callback")
import sys, traceback, time, Ice, pymysql Ice.loadSlice('../ice/py2serv.ice') Ice.updateModules() import py2serv class SenderI(py2serv.Sender): def send(self, round,msg, current=None): print("[Round #{}] Received: date={}, mission={}, action={}, idObjet={}" .format(round,msg.date,msg.mission,msg.action,msg.idObjet)) query = "INSERT INTO messages VALUE("+str(msg.idObjet)+",'"+msg.date+"',"+str(msg.mission)+",'"+msg.action+"','"+msg.type+"',"+str(msg.niveau)+")" #"+msg.type+" #print(query) cursor.execute(query) database.commit() #cursor.execute("select * from messages") def resetTable(self, current=None): cursor.execute("TRUNCATE TABLE messages") class Server(Ice.Application): def run(self, args): if len(args) > 1: print(self.appName() + ": too many arguments") return 1 adapter = self.communicator().createObjectAdapter("Sender") adapter.add(SenderI(), self.communicator().stringToIdentity("hello")) adapter.activate() self.communicator().waitForShutdown() return 0 database = pymysql.connect(host='localhost',
#!/usr/bin/env python # ********************************************************************** # # Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. # # This copy of Ice is licensed to you under the terms described in the # ICE_LICENSE file included in this distribution. # # ********************************************************************** import os, sys, traceback import Ice Ice.loadSlice('Test.ice') import Test, TestI, AllTests def run(args, communicator): communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010") adapter = communicator.createObjectAdapter("TestAdapter") d = TestI.DI() adapter.add(d, communicator.stringToIdentity("d")) adapter.addFacet(d, communicator.stringToIdentity("d"), "facetABCD") f = TestI.FI() adapter.addFacet(f, communicator.stringToIdentity("d"), "facetEF") h = TestI.HI(communicator) adapter.addFacet(h, communicator.stringToIdentity("d"), "facetGH") #adapter.activate() // Don't activate OA to ensure collocation is used.
import os import yaml import Ice from mumble.app import create_app with open('./config.yml') as f: config_file = yaml.load(f.read()) Ice.loadSlice('', ['-I' + Ice.getSliceDir(), config_file['SLICE_FILE']]) app = create_app(config_object=config_file) if __name__ == '__main__': app.run('0.0.0.0', port=int(os.environ.get('PORT', 5002)), debug=True)
# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. # # This copy of Ice is licensed to you under the terms described in the # ICE_LICENSE file included in this distribution. # # ********************************************************************** import os, sys, traceback, array import Ice slice_dir = Ice.getSliceDir() if not slice_dir: print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice('"-I' + slice_dir + '" TestAMD.ice') import Test def test(b): if not b: raise RuntimeError('test assertion failed') class ThrowerI(Test.Thrower): def shutdown_async(self, cb, current=None): current.adapter.getCommunicator().shutdown() cb.ice_response() def supportsUndeclaredExceptions_async(self, cb, current=None): cb.ice_response(True)
#!/usr/bin/env python # ********************************************************************** # # Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. # # This copy of Ice is licensed to you under the terms described in the # ICE_LICENSE file included in this distribution. # # ********************************************************************** import os, sys, traceback import Ice Ice.loadSlice('TestAMD.ice') import Test class InitialI(Test.Initial): def shutdown_async(self, cb, current=None): current.adapter.getCommunicator().shutdown() cb.ice_response() def pingPong_async(self, cb, o, current=None): cb.ice_response(o) def opOptionalException_async(self, cb, a, b, o, current=None): cb.ice_exception(Test.OptionalException(False, a, b, o)) def opDerivedException_async(self, cb, a, b, o, current=None): cb.ice_exception(Test.DerivedException(False, a, b, o, b, o))
#!/usr/bin/env python # ********************************************************************** # # Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved. # # This copy of Ice is licensed to you under the terms described in the # ICE_LICENSE file included in this distribution. # # ********************************************************************** import sys, traceback, Ice Ice.loadSlice('Filesystem.ice') import Filesystem # Recursively display the contents of directory "dir" # in tree fashion. For files, show the contents of # each file. The "depth" parameter is the current # nesting level (for indentation). def listRecursive(dir, depth): indent = '' depth = depth + 1 for i in range(depth): indent = indent + '\t' contents = dir.list() for node in contents: subdir = Filesystem.DirectoryPrx.checkedCast(node) file = Filesystem.FilePrx.uncheckedCast(node)
# # You should have received a copy of the GNU General Public License # along with RoboComp. If not, see <http://www.gnu.org/licenses/>. import sys, Ice, os ROBOCOMP = '' try: ROBOCOMP = os.environ['ROBOCOMP'] except KeyError: print( '$ROBOCOMP environment variable not set, using the default value /opt/robocomp' ) ROBOCOMP = '/opt/robocomp' Ice.loadSlice("-I ./src/ --all ./src/CommonBehavior.ice") import RoboCompCommonBehavior Ice.loadSlice("-I ./src/ --all ./src/CameraRGBDSimple.ice") import RoboCompCameraRGBDSimple Ice.loadSlice("-I ./src/ --all ./src/ObjectPoseEstimationRGB.ice") import RoboCompObjectPoseEstimationRGB Ice.loadSlice("-I ./src/ --all ./src/ObjectPoseEstimationRGBD.ice") import RoboCompObjectPoseEstimationRGBD class ImgType(list): def __init__(self, iterable=list()): super(ImgType, self).__init__(iterable) def append(self, item):
#!/usr/bin/env python # ********************************************************************** # # Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. # # This copy of Ice is licensed to you under the terms described in the # ICE_LICENSE file included in this distribution. # # ********************************************************************** import os, sys, traceback import Ice Ice.loadSlice('-I. --all ServerPrivateAMD.ice Forward.ice') import Test def test(b): if not b: raise RuntimeError('test assertion failed') class TestI(Test.TestIntf): def SBaseAsObject_async(self, cb, current=None): sb = Test.SBase() sb.sb = "SBase.sb" cb.ice_response(sb) def SBaseAsSBase_async(self, cb, current=None): sb = Test.SBase() sb.sb = "SBase.sb" cb.ice_response(sb)
#!/usr/bin/env python import sys, traceback, Ice Ice.loadSlice('BFAS.ice') import Noblis class Client(Ice.Application): def run(self, args): proxy = Noblis.BFASPrx.checkedCast(\ self.communicator().propertyToProxy('BFAS.Proxy').ice_twoway().ice_timeout(-1).ice_secure(False)) if not proxy: print args[0] + ": invalid proxy" return 1 try: infile = open("file.mtgl","r") proxy.analyzeFile(infile.read()) infile.close() except Ice.Exception, ex: print ex return 0 app = Client() sys.exit(app.main(sys.argv, "config.client"))
#!/usr/bin/env python # -*- coding: utf-8 import Ice, sys, sha from M2Crypto import X509; Ice.loadSlice('Murmur.ice') import Murmur class MetaCallbackI(Murmur.MetaCallback): def started(self, s, current=None): print "started" serverR=Murmur.ServerCallbackPrx.uncheckedCast(adapter.addWithUUID(ServerCallbackI(server, current.adapter))) s.addCallback(serverR) def stopped(self, s, current=None): print "stopped" class ServerCallbackI(Murmur.ServerCallback): def __init__(self, server, adapter): self.server = server self.contextR=Murmur.ServerContextCallbackPrx.uncheckedCast(adapter.addWithUUID(ServerContextCallbackI(server))) def userConnected(self, p, current=None): print "connected" print p self.server.addContextCallback(p.session, "flubber", "Power up the T", self.contextR, Murmur.ContextChannel | Murmur.ContextUser) if (self.server.hasPermission(p.session, 0, Murmur.PermissionWrite)): print "Is a global admin" certlist=self.server.getCertificateList(p.session) for cert in certlist: hash = sha.new()
#!/usr/bin/env python # # Copyright (c) ZeroC, Inc. All rights reserved. # import signal import sys import threading import Ice Ice.loadSlice('Session.ice') import Demo class HelloI(Demo.Hello): def __init__(self, name, id): self._name = name self._id = id def sayHello(self, c): print("Hello object #" + str(self._id) + " for session `" + self._name + "' says:\n" + "Hello " + self._name + "!") class SessionI(Demo.Session): def __init__(self, name): self._name = name self._lock = threading.Lock() self._destroy = False # true if destroy() was called, false otherwise. self._nextId = 0 # The id of the next hello object. This is used for tracing purposes. self._objs = [] # List of per-client allocated Hello objects.
#!/usr/bin/env python # ********************************************************************** # # Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved. # # This copy of Ice is licensed to you under the terms described in the # ICE_LICENSE file included in this distribution. # # ********************************************************************** import sys, Ice Ice.loadSlice('Callback.ice') import Demo def menu(): print(""" usage: t: send callback s: shutdown server x: exit ?: help """) class CallbackReceiverI(Demo.CallbackReceiver): def callback(self, current=None): print("received callback") class Client(Ice.Application): def run(self, args): if len(args) > 1:
# along with RoboComp. If not, see <http://www.gnu.org/licenses/>. # import sys, os, Ice ROBOCOMP = '' try: ROBOCOMP = os.environ['ROBOCOMP'] except: print( '$ROBOCOMP environment variable not set, using the default value /opt/robocomp' ) ROBOCOMP = '/opt/robocomp' if len(ROBOCOMP) < 1: raise RuntimeError('ROBOCOMP environment variable not set! Exiting.') Ice.loadSlice("-I ./src/ --all ./src/AprilTags.ice") from RoboCompAprilTags import * class AprilTagsI(AprilTags): def __init__(self, worker): self.worker = worker def newAprilTag(self, tags, c): return self.worker.AprilTags_newAprilTag(tags) def newAprilTagAndPose(self, tags, bState, hState, c): return self.worker.AprilTags_newAprilTagAndPose(tags, bState, hState)
#!/usr/bin/env python # ********************************************************************** # # Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. # # ********************************************************************** import sys, traceback, time, Ice, IceStorm, getopt Ice.loadSlice('Clock.ice') import Demo class Publisher(Ice.Application): def usage(self): print("Usage: " + self.appName() + " [--datagram|--twoway|--oneway] [topic]") def run(self, args): try: opts, args = getopt.getopt(args[1:], '', ['datagram', 'twoway', 'oneway']) except getopt.GetoptError: self.usage() return 1 datagram = False twoway = False optsSet = 0 topicName = "time" for o, a in opts: if o == "--datagram": datagram = True optsSet = optsSet + 1
# -*- coding: utf-8 -*- ''' Factoria encargado de crear los schedulers. David Carneros Prado 3B ''' import sys import Ice import IceStorm import downloads_scheduler #pylint: disable = E0401 #pyliny: disable = C0413 #pylint: disable = E1101 Ice.loadSlice('downloader.ice') import Downloader class SchedulerFactoryI(Downloader.SchedulerFactory): ''' Servant del factory ''' def __init__(self, publisher_synctime, publisher_progress, sync_topic): self.sync_topic = sync_topic self.publisher_progress = publisher_progress self.publisher_synctime = publisher_synctime self.schedulers = {} self.subscriber_synctimers = {} def make(self, name, current=None): ''' Create schedulers ''' if name in self.schedulers:
#!/usr/bin/env python # ********************************************************************** # # Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. # # This copy of Ice is licensed to you under the terms described in the # ICE_LICENSE file included in this distribution. # # ********************************************************************** import os, sys, traceback import Ice Ice.loadSlice('Test.ice') import Test class InitialI(Test.Initial): def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() def pingPong(self, o, current=None): return o def opOptionalException(self, a, b, o, current=None): raise Test.OptionalException(False, a, b, o) def opDerivedException(self, a, b, o, current=None): raise Test.DerivedException(False, a, b, o, b, o) def opRequiredException(self, a, b, o, current=None):
print 'can\'t read file' sys.exit() if len(lines) != 1: print 'empty?' sys.exit() if lines[0][0] != '/': print 'we need an absolute path in ~/.robocomp' sys.exit() ROBOCOMP = lines[0] print "Read $ROBOCOMP from ~/.robocomp <"+ROBOCOMP+">" preStr = "-I"+ROBOCOMP+"/interfaces/ --all "+ROBOCOMP+"/interfaces/" Ice.loadSlice(preStr+"RCRemote.ice") from RoboCompRemote import * class RCRemoteI(RCRemote): def __init__(self, worker): self.worker = worker def run(self, stuff, hashedPassword, path, binary, arguments, yakuakeTabName, c): return self.worker.run(stuff, hashedPassword, path, binary, arguments, yakuakeTabName) class SpecificWorker(GenericWorker): def __init__(self, proxy_map, passwd):
import settings import Ice # Create Flask app app = Flask(__name__) app.config['SECRET_KEY'] = os.urandom(24) # Initialize Digest Auth auth = HTTPDigestAuth() # If enabled, all endpoints will be digest auth protected auth_enabled = settings.ENABLE_AUTH # Load up Murmur slice file into Ice Ice.loadSlice('', ['-I' + Ice.getSliceDir(), os.path.join(settings.MURMUR_ROOT, settings.SLICE_FILE)]) import Murmur # Configure Ice properties props = Ice.createProperties() props.setProperty("Ice.ImplicitContext", "Shared") props.setProperty('Ice.Default.EncodingVersion', '1.0') props.setProperty('Ice.MessageSizeMax', str(settings.ICE_MESSAGESIZE)) idata = Ice.InitializationData() idata.properties = props # Create Ice connection ice = Ice.initialize(idata) proxy = ice.stringToProxy(settings.ICE_HOST) secret = settings.ICE_SECRET if secret != '':
# You should have received a copy of the GNU General Public License # along with RoboComp. If not, see <http://www.gnu.org/licenses/>. # import sys, os, Ice ROBOCOMP = '' try: ROBOCOMP = os.environ['ROBOCOMP'] except: print('$ROBOCOMP environment variable not set, using the default value /opt/robocomp') ROBOCOMP = '/opt/robocomp' if len(ROBOCOMP)<1: raise RuntimeError('ROBOCOMP environment variable not set! Exiting.') Ice.loadSlice("-I ./src/ --all ./src/MPTFeatures.ice") from RoboCompMPTFeatures import * class MPTFeaturesI(MPTFeatures): def __init__(self, worker): self.worker = worker def detectHumans(self, im, c): return self.worker.MPTFeatures_detectHumans(im) def getReidFeature(self, imlist, c): return self.worker.MPTFeatures_getReidFeature(imlist)
#! /usr/bin/env python import sys, traceback, Ice Ice.loadSlice("-I../UtilSlice/slice -I../OceSlice/slice --all ../UtilSlice/slice/Util.ice ../UtilSlice/slice/ObjectCache.ice ../OceSlice/slice/Relation.ice") import MyUtil import mop.hi.svc.relation status = 0 ic = None try: ic = Ice.initialize(["--Ice.Default.Locator=XiaoNei/Locator:default -h XiaoNeiRegistry -p 12000:default -h XiaoNeiRegistryReplica1 -p 12001:default -h XiaoNeiRegistryReplica2 -p 12002"]) #ic = Ice.initialize(sys.argv) relations = [] #config = [] for i in range(0, 10): print "Initializing proxy for ending with", i relations.append( mop.hi.svc.relation.InternalManagerPrx.checkedCast(ic.stringToProxy("IM@Relation" + str(i))) ) f = file("reloadRelation.txt") while True: line = f.readline() if len(line) == 0: break str = line.split(",") for i in str: uid=int(i) eid=uid % 10 print eid, uid relations[eid].reloadRequest(uid); relations[eid].reloadBlock(uid); relations[eid].reloadBlocked(uid); relations[eid].reloadBuddy(uid); relations[eid].reloadRelationGroup(uid); f.close()
#!/usr/bin/python3 # -*- coding: utf-8 -*- import sys import Ice Ice.loadSlice('Printer.ice') import Example class Client(Ice.Application): def run(self, argv): proxy = self.communicator().stringToProxy(argv[1]) printer = Example.PrinterPrx.checkedCast(proxy) if not printer: raise RuntimeError('Invalid proxy') printer.write('Rodrigo Díaz-Hellin Valera!') return 0 sys.exit(Client().main(sys.argv))