コード例 #1
0
def readwork(workconfig):
    global reader
    while 1:
        msglist0 = {}
        try:
            rst1, msglist = reader.readMessages(READ_QUEUE_NAME, msglist0)
        except Exception as e:
            lg.info('read msg err : %s' % e)
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            lg.info((exc_type, fname, exc_tb.tb_lineno))

            gevent.sleep(5)
            id = Ice.InitializationData()
            if id.properties == None:
                id.properties = Ice.createProperties(sys.argv)
            if Ice.intVersion() > 30500:
                if not id.properties.getProperty(
                        "Ice.Default.EncodingVersion"):
                    id.properties.setProperty("Ice.Default.EncodingVersion",
                                              "1.0")
            ic = Ice.initialize(id)
            base = ic.stringToProxy('gmqObjectId:tcp -h %s  -p %s' %
                                    (QUEUE_IP, QUEUE_PORT))
            reader = GMQ.MsgQueuePrx.checkedCast(base)
            continue

        gevent.sleep(0.1)
        if len(msglist) == 0:
            gevent.sleep(0.5)
            continue

        for msg in msglist:
            print msg
            try:
                jsoninfo = json.loads(msg)
                print(jsoninfo)
                taskInfo = {
                    'task_id': jsoninfo['task_id'],
                    'plat_id': jsoninfo['plat_id'],
                    'obj_id': jsoninfo['obj_id'],
                    'obj_name': jsoninfo['obj_name'],
                    'obj_code': jsoninfo['obj_code'],
                    'obj_ext': jsoninfo['obj_ext'],
                    'create_time': jsoninfo['create_time'],
                    'task_send_time': jsoninfo['task_send_time'],
                    'sn': jsoninfo['sn'],
                    'mode': jsoninfo['mode']
                }
                tasks.put(taskInfo)
            except Exception as e:
                lg.info('unknown err process:%s' % (e))
コード例 #2
0
ファイル: Client.py プロジェクト: zj771484545/ice
    def run(self, args):
        sys.stdout.write("testing Slice predefined macros... ")
        sys.stdout.flush()

        d = Test.Default()
        test(d.x == 10)
        test(d.y == 10)

        nd = Test.NoDefault()
        test(nd.x != 10)
        test(nd.y != 10)

        c = Test.PythonOnly()
        test(c.lang == "python")
        test(c.version == Ice.intVersion())
        print("ok")
コード例 #3
0
    def run(self, args):
        sys.stdout.write("testing Slice predefined macros... ")
        sys.stdout.flush()

        d = Test.Default()
        test(d.x == 10)
        test(d.y == 10)

        nd = Test.NoDefault()
        test(nd.x != 10)
        test(nd.y != 10)

        c = Test.PythonOnly()
        test(c.lang == "python")
        test(c.version == Ice.intVersion())
        print("ok")
コード例 #4
0
ファイル: clients.py プロジェクト: lucalianas/openmicroscopy
    def _initData(self, id):
        """
        Initializes the current client via an Ice.InitializationData
        instance. This is called by all of the constructors, but may
        also be called on createSession(name, pass) if a previous
        call to closeSession() has nulled the Ice.Communicator.
        """

        if not id:
            raise omero.ClientError("No initialization data provided.")

        # Strictly necessary for this class to work
        id.properties.setProperty("Ice.ImplicitContext", "Shared")
        id.properties.setProperty("Ice.ACM.Client", "0")
        id.properties.setProperty("Ice.CacheMessageBuffers", "0")
        id.properties.setProperty("Ice.RetryIntervals", "-1")
        id.properties.setProperty("Ice.Default.EndpointSelection", "Ordered")
        id.properties.setProperty("Ice.Default.PreferSecure", "1")
        id.properties.setProperty("Ice.Plugin.IceSSL", "IceSSL:createIceSSL")
        id.properties.setProperty("IceSSL.Ciphers", "ADH")
        id.properties.setProperty("IceSSL.Protocols", "tls1")
        id.properties.setProperty("IceSSL.VerifyPeer", "0")

        # Setting block size
        blockSize = id.properties.getProperty("omero.block_size")
        if not blockSize or len(blockSize) == 0:
            id.properties.setProperty("omero.block_size",
                                      str(omero.constants.DEFAULTBLOCKSIZE))

        # Set the default encoding if this is Ice 3.5 or later
        # and none is set.
        if Ice.intVersion() >= 30500:
            if not id.properties.getProperty("Ice.Default.EncodingVersion"):
                id.properties.setProperty("Ice.Default.EncodingVersion", "1.0")

        # Setting MessageSizeMax
        messageSize = id.properties.getProperty("Ice.MessageSizeMax")
        if not messageSize or len(messageSize) == 0:
            id.properties.setProperty("Ice.MessageSizeMax",
                                      str(omero.constants.MESSAGESIZEMAX))

        # Setting ConnectTimeout
        self.parseAndSetInt(id, "Ice.Override.ConnectTimeout",\
                           omero.constants.CONNECTTIMEOUT)

        # Set large thread pool max values for all communicators
        for x in ("Client", "Server"):
            sizemax = id.properties.getProperty("Ice.ThreadPool.%s.SizeMax" %
                                                x)
            if not sizemax or len(sizemax) == 0:
                id.properties.setProperty("Ice.ThreadPool.%s.SizeMax" % x,
                                          "50")

        # Port, setting to default if not present
        port = self.parseAndSetInt(id, "omero.port",\
                                  omero.constants.GLACIER2PORT)

        # Default Router, set a default and then replace
        router = id.properties.getProperty("Ice.Default.Router")
        if not router or len(router) == 0:
            router = str(omero.constants.DEFAULTROUTER)
        host = id.properties.getPropertyWithDefault(
            "omero.host", """<"omero.host" not set>""")
        router = router.replace("@omero.port@", str(port))
        router = router.replace("@omero.host@", str(host))
        id.properties.setProperty("Ice.Default.Router", router)

        # Dump properties
        dump = id.properties.getProperty("omero.dump")
        if len(dump) > 0:
            m = self.getPropertyMap(id.properties)
            keys = list(m.keys())
            keys.sort()
            for key in keys:
                print "%s=%s" % (key, m[key])

        self.__lock.acquire()
        try:
            if self.__ic:
                raise omero.ClientError("Client already initialized")

            try:
                self.__ic = Ice.initialize(id)
            except Ice.EndpointParseException:
                msg = "No host specified. "
                msg += "Use omero.client(HOSTNAME), ICE_CONFIG, or similar."
                raise omero.ClientError(msg)

            if not self.__ic:
                raise omero.ClientError("Improper initialization")

            # Register Object Factory
            import ObjectFactoryRegistrar as ofr
            ofr.registerObjectFactory(self.__ic, self)

            for of in omero.rtypes.ObjectFactories.values():
                of.register(self.__ic)

            # Define our unique identifier (used during close/detach)
            self.__uuid = str(uuid.uuid4())
            ctx = self.__ic.getImplicitContext()
            if not ctx:
                raise omero.ClientError(
                    "Ice.ImplicitContext not set to Shared")
            ctx.put(omero.constants.CLIENTUUID, self.__uuid)

            # ticket:2951 - sending user group
            group = id.properties.getPropertyWithDefault("omero.group", "")
            if group:
                ctx.put("omero.group", group)

        finally:
            self.__lock.release()
コード例 #5
0
status = True


def test(b):
    if not b:
        raise RuntimeError('test assertion failed')


try:
    sys.stdout.write("testing Slice predefined macros... ")
    sys.stdout.flush()

    d = Test.Default()
    test(d.x == 10)
    test(d.y == 10)

    nd = Test.NoDefault()
    test(nd.x != 10)
    test(nd.y != 10)

    c = Test.PythonOnly()
    test(c.lang == "python")
    test(c.version == Ice.intVersion())
    print("ok")
except:
    traceback.print_exc()
    status = False

sys.exit(not status)
コード例 #6
0
ファイル: clients.py プロジェクト: sbesson/openmicroscopy
    def _initData(self, id):
        """
        Initializes the current client via an Ice.InitializationData
        instance. This is called by all of the constructors, but may
        also be called on createSession(name, pass) if a previous
        call to closeSession() has nulled the Ice.Communicator.
        """

        if not id:
            raise omero.ClientError("No initialization data provided.")

        # Strictly necessary for this class to work
        id.properties.setProperty("Ice.ImplicitContext", "Shared")
        id.properties.setProperty("Ice.ACM.Client", "0")
        id.properties.setProperty("Ice.CacheMessageBuffers", "0")
        id.properties.setProperty("Ice.RetryIntervals", "-1")
        id.properties.setProperty("Ice.Default.EndpointSelection", "Ordered")
        id.properties.setProperty("Ice.Default.PreferSecure", "1")
        id.properties.setProperty("Ice.Plugin.IceSSL" , "IceSSL:createIceSSL")
        id.properties.setProperty("IceSSL.Ciphers" , "ADH")
        id.properties.setProperty("IceSSL.Protocols" , "tls1")
        id.properties.setProperty("IceSSL.VerifyPeer" , "0")

        # Setting block size
        blockSize = id.properties.getProperty("omero.block_size")
        if not blockSize or len(blockSize) == 0:
            id.properties.setProperty("omero.block_size", str(omero.constants.DEFAULTBLOCKSIZE))

        # Set the default encoding if this is Ice 3.5 or later
        # and none is set.
        if Ice.intVersion() >= 30500:
            if not id.properties.getProperty("Ice.Default.EncodingVersion"):
                id.properties.setProperty("Ice.Default.EncodingVersion", "1.0")

        # Setting MessageSizeMax
        messageSize = id.properties.getProperty("Ice.MessageSizeMax")
        if not messageSize or len(messageSize) == 0:
            id.properties.setProperty("Ice.MessageSizeMax", str(omero.constants.MESSAGESIZEMAX))

        # Setting ConnectTimeout
        self.parseAndSetInt(id, "Ice.Override.ConnectTimeout",\
                           omero.constants.CONNECTTIMEOUT)

        # Set large thread pool max values for all communicators
        for x in ("Client", "Server"):
            sizemax = id.properties.getProperty("Ice.ThreadPool.%s.SizeMax" % x)
            if not sizemax or len(sizemax) == 0:
                id.properties.setProperty("Ice.ThreadPool.%s.SizeMax" % x, "50")

        # Port, setting to default if not present
        port = self.parseAndSetInt(id, "omero.port",\
                                  omero.constants.GLACIER2PORT)

        # Default Router, set a default and then replace
        router = id.properties.getProperty("Ice.Default.Router")
        if not router or len(router) == 0:
            router = str(omero.constants.DEFAULTROUTER)
        host = id.properties.getPropertyWithDefault("omero.host", """<"omero.host" not set>""")
        router = router.replace("@omero.port@", str(port))
        router = router.replace("@omero.host@", str(host))
        id.properties.setProperty("Ice.Default.Router", router)

        # Dump properties
        dump = id.properties.getProperty("omero.dump")
        if len(dump) > 0:
            m = self.getPropertyMap(id.properties)
            keys = list(m.keys())
            keys.sort()
            for key in keys:
                print "%s=%s" % (key, m[key])

        self.__lock.acquire()
        try:
            if self.__ic:
                raise omero.ClientError("Client already initialized")

            try:
                self.__ic = Ice.initialize(id)
            except Ice.EndpointParseException:
                msg = "No host specified. "
                msg += "Use omero.client(HOSTNAME), ICE_CONFIG, or similar."
                raise omero.ClientError(msg)

            if not self.__ic:
                raise omero.ClientError("Improper initialization")

            # Register Object Factory
            import ObjectFactoryRegistrar as ofr
            ofr.registerObjectFactory(self.__ic, self)

            for of in omero.rtypes.ObjectFactories.values():
                of.register(self.__ic)

            # Define our unique identifier (used during close/detach)
            self.__uuid = str(uuid.uuid4())
            ctx = self.__ic.getImplicitContext()
            if not ctx:
                raise omero.ClientError("Ice.ImplicitContext not set to Shared")
            ctx.put(omero.constants.CLIENTUUID, self.__uuid)

            # ticket:2951 - sending user group
            group = id.properties.getPropertyWithDefault("omero.group", "")
            if group:
                ctx.put("omero.group", group)

        finally:
            self.__lock.release()
コード例 #7
0
ファイル: Client.py プロジェクト: BlackHoleJet/ice
Ice.loadSlice('Test.ice')
import Test, copy

status = True

def test(b):
    if not b:
        raise RuntimeError('test assertion failed')

try:
    sys.stdout.write("testing Slice predefined macros... ")
    sys.stdout.flush()

    d = Test.Default()
    test(d.x == 10)
    test(d.y == 10)

    nd = Test.NoDefault()
    test(nd.x != 10)
    test(nd.y != 10)

    c = Test.PythonOnly()
    test(c.lang == "python")
    test(c.version == Ice.intVersion())
    print("ok")
except:
    traceback.print_exc()
    status = False

sys.exit(not status)
コード例 #8
0
def asynchronous():
    workconfigs = [{'mode': 0, 'num': str(i)} for i in xrange(5)]
    readmsg_config = {'mode': 1, 'num': 0}
    workconfigs.append(readmsg_config)

    threads = [gevent.spawn(worker, workconfig) for workconfig in workconfigs]
    gevent.joinall(threads)


if __name__ == '__main__':
    tasks = Queue(maxsize=40)

    id = Ice.InitializationData()
    if id.properties == None:
        id.properties = Ice.createProperties(sys.argv)
    if Ice.intVersion() > 30500:
        if not id.properties.getProperty("Ice.Default.EncodingVersion"):
            id.properties.setProperty("Ice.Default.EncodingVersion", "1.0")
    ic = Ice.initialize(id)
    base = ic.stringToProxy(IMMQ_PROXY)
    reader = GMQ.MsgQueuePrx.checkedCast(base)
    print reader

    if not reader:
        raise RuntimeError("Invalid proxy")

    signal.signal(signal.SIGINT, signal_handler)
    asynchronous()
    ic.destroy()