Пример #1
0
 def setUp (self):
     c = omero.client(pmap=['--Ice.Config='+(os.environ.get("ICE_CONFIG"))])
     try:
         self.root_password = c.ic.getProperties().getProperty('omero.rootpass')
         self.omero_host = c.ic.getProperties().getProperty('omero.host')
         self.omero_port = c.ic.getProperties().getProperty('omero.port')
         Server.reset()
         Server(host=self.omero_host, port=self.omero_port)
     finally:
         c.__del__()
Пример #2
0
 def test_load_server_list(self):
     SERVER_LIST = [[u'example1.com', 4064, u'omero1'], [u'example2.com', 4064, u'omero2'], [u'example3.com', 4064], [u'example4.com', 4064]]
     for s in SERVER_LIST:
         server = (len(s) > 2) and s[2] or None
         Server(host=s[0], port=s[1], server=server)
     Server.freeze()
     
     try:
         Server(host=u'example5.com', port=4064)
     except Exception, x:
         pass
Пример #3
0
 def test_constructor(self):
     # Create object with alias
     Server(host=u'example.com', port=4064, server=u'ome')
     
     # Create object without alias
     Server(host=u'example2.com', port=4065)
     
     # without any params
     try:
         Server()
     except Exception, x:
         pass
Пример #4
0
    def test_constructor(self):
        Server.reset()
        # Create object with alias
        Server(host=u'example.com', port=4064, server=u'ome')

        # Create object without alias
        Server(host=u'example2.com', port=4065)

        # without any params
        try:
            Server()
        except TypeError as te:
            assert str(te) == '__new__() takes at least 3 arguments (1 given)'
    def test_constructor(self):
        Server.reset()
        # Create object with alias
        Server(host=u'example.com', port=4064, server=u'ome')

        # Create object without alias
        Server(host=u'example2.com', port=4065)

        # without any params
        try:
            Server()
        except TypeError as te:
            assert str(te) == '__new__() takes at least 3 arguments (1 given)'
Пример #6
0
    def test_load_server_list(self):
        SERVER_LIST = [[u'example1.com', 4064, u'omero1'], [u'example2.com', 4064, u'omero2'], [u'example3.com', 4064], [u'example4.com', 4064]]
        for s in SERVER_LIST:
            server = (len(s) > 2) and s[2] or None
            Server(host=s[0], port=s[1], server=server)
        Server.freeze()
        
        try:
            Server(host=u'example5.com', port=4064)
        except Exception:
            pass
        else:
            self.fail('Error:No more instances allowed')

        Server(host=u'example1.com', port=4064)
Пример #7
0
 def test_get_and_find(self):
     SERVER_LIST = [[u'example1.com', 4064, u'omero1'], [u'example2.com', 4064, u'omero2'], [u'example3.com', 4064], [u'example4.com', 4064]]
     for s in SERVER_LIST:
         server = (len(s) > 2) and s[2] or None
         Server(host=s[0], port=s[1], server=server)
     
     s1 = Server.get(1)
     self.assertEquals(s1.host, u'example1.com')
     self.assertEquals(s1.port, 4064)
     self.assertEquals(s1.server, u'omero1')
     
     s2 = Server.find('example2.com')[0]
     self.assertEquals(s2.host, u'example2.com')
     self.assertEquals(s2.port, 4064)
     self.assertEquals(s2.server, u'omero2')
Пример #8
0
    def setUp (self):
        c = omero.client(pmap=['--Ice.Config='+(os.environ.get("ICE_CONFIG"))])
        try:
            self.root_password = c.ic.getProperties().getProperty('omero.rootpass')
            self.omero_host = c.ic.getProperties().getProperty('omero.host')
            self.omero_port = c.ic.getProperties().getProperty('omero.port')
            Server.reset()
            Server(host=self.omero_host, port=self.omero_port)
        finally:
            c.__del__()

        self.server_id = 1
        connector = Connector(self.server_id, True)
        self.rootconn = connector.create_connection('TEST.webadmin', 'root', self.root_password)
        if self.rootconn is None or not self.rootconn.isConnected() or not self.rootconn.keepAlive():
            raise Exception("Cannot connect")
Пример #9
0
    def setUp(self):
        c = omero.client(
            pmap=['--Ice.Config=' + (os.environ.get("ICE_CONFIG"))])
        try:
            self.root_password = c.ic.getProperties().getProperty(
                'omero.rootpass')
            omero_host = c.ic.getProperties().getProperty('omero.host')
        finally:
            c.__del__()

        blitz = Server.find(host=omero_host)
        if blitz is None:
            Server.reset()
            for s in settings.SERVER_LIST:
                server = (len(s) > 2) and unicode(s[2]) or None
                Server(host=unicode(s[0]), port=int(s[1]), server=server)
            Server.freeze()
            blitz = Server.find(server=omero_host)

        if len(blitz):
            self.server_id = blitz[0].id
            connector = Connector(self.server_id, True)
            self.rootconn = connector.create_connection(
                'TEST.webadmin', 'root', self.root_password)

            if self.rootconn is None or not self.rootconn.isConnected(
            ) or not self.rootconn.keepAlive():
                raise exceptions.Exception("Cannot connect")
        else:
            raise exceptions.Exception("'%s' is not on omero.web.server_list" %
                                       omero_host)
Пример #10
0
    def test_load_server_list(self):
        Server.reset()

        SERVER_LIST = [[u'example1.com', 4064, u'omero1'],
                       [u'example2.com', 4064, u'omero2'],
                       [u'example3.com', 4064],
                       [u'example4.com', 4064]]
        for s in SERVER_LIST:
            server = (len(s) > 2) and s[2] or None
            Server(host=s[0], port=s[1], server=server)
        Server.freeze()

        try:
            Server(host=u'example5.com', port=4064)
        except TypeError as te:
            assert str(te) == 'No more instances allowed'

        Server(host=u'example1.com', port=4064)
Пример #11
0
 def loginAsUser(self, username, password):
     blitz = Server.get(pk=self.server_id) 
     if blitz is not None:
         connector = Connector(self.server_id, True)
         conn = connector.create_connection('TEST.webadmin', username, password)
         if conn is None or not conn.isConnected() or not conn.keepAlive():
             raise Exception("Cannot connect")
         return conn
     else:
         raise Exception("'%s' is not on omero.web.server_list"  % self.omero_host)
Пример #12
0
    def test_get_and_find(self):
        Server.reset()

        SERVER_LIST = [[u'example1.com', 4064, u'omero1'],
                       [u'example2.com', 4064, u'omero2'],
                       [u'example3.com', 4064], [u'example4.com', 4064]]
        for s in SERVER_LIST:
            server = (len(s) > 2) and s[2] or None
            Server(host=s[0], port=s[1], server=server)

        s1 = Server.get(1)
        assert s1.host == u'example1.com'
        assert s1.port == 4064
        assert s1.server == u'omero1'

        s2 = Server.find('example2.com')[0]
        assert s2.host == u'example2.com'
        assert s2.port == 4064
        assert s2.server == u'omero2'
Пример #13
0
    def setUp(self):
        c = omero.client(
            pmap=['--Ice.Config=' + (os.environ.get("ICE_CONFIG"))])
        try:
            self.root_password = c.ic.getProperties().getProperty(
                'omero.rootpass')
            self.omero_host = c.ic.getProperties().getProperty('omero.host')
            self.omero_port = c.ic.getProperties().getProperty('omero.port')
            Server.reset()
            Server(host=self.omero_host, port=self.omero_port)
        finally:
            c.__del__()

        self.server_id = 1
        connector = Connector(self.server_id, True)
        self.rootconn = connector.create_connection('TEST.webadmin', 'root',
                                                    self.root_password)
        if self.rootconn is None or not self.rootconn.isConnected(
        ) or not self.rootconn.keepAlive():
            raise Exception("Cannot connect")
Пример #14
0
    def test_get_and_find(self):
        Server.reset()

        SERVER_LIST = [[u'example1.com', 4064, u'omero1'],
                       [u'example2.com', 4064, u'omero2'],
                       [u'example3.com', 4064],
                       [u'example4.com', 4064]]
        for s in SERVER_LIST:
            server = (len(s) > 2) and s[2] or None
            Server(host=s[0], port=s[1], server=server)

        s1 = Server.get(1)
        assert s1.host == u'example1.com'
        assert s1.port == 4064
        assert s1.server == u'omero1'

        s2 = Server.find('example2.com')[0]
        assert s2.host == u'example2.com'
        assert s2.port == 4064
        assert s2.server == u'omero2'
Пример #15
0
 def loginAsUser(self, username, password):
     blitz = Server.get(pk=self.server_id)
     if blitz is not None:
         connector = Connector(self.server_id, True)
         conn = connector.create_connection('TEST.webadmin', username,
                                            password)
         if conn is None or not conn.isConnected() or not conn.keepAlive():
             raise exceptions.Exception("Cannot connect")
         return conn
     else:
         raise exceptions.Exception("'%s' is not on omero.web.server_list" %
                                    omero_host)
    def setUp (self):
        c = omero.client(pmap=['--Ice.Config='+(os.environ.get("ICE_CONFIG"))])
        try:
            self.root_password = c.ic.getProperties().getProperty('omero.rootpass')
            omero_host = c.ic.getProperties().getProperty('omero.host')
        finally:
            c.__del__()

        blitz = Server.find(host=omero_host)
        if blitz is None:
            Server.reset()
            for s in settings.SERVER_LIST:
                server = (len(s) > 2) and unicode(s[2]) or None
                Server(host=unicode(s[0]), port=int(s[1]), server=server)
            Server.freeze()
            blitz = Server.find(server=omero_host)
        
        if len(blitz):
            self.server_id = blitz[0].id
            connector = Connector(self.server_id, True)
            self.rootconn = connector.create_connection('TEST.webadmin', 'root', self.root_password)

            if self.rootconn is None or not self.rootconn.isConnected() or not self.rootconn.keepAlive():
                raise exceptions.Exception("Cannot connect")
        else:
            raise exceptions.Exception("'%s' is not on omero.web.server_list" % omero_host)
Пример #17
0
    def test_load_server_list(self):
        Server.reset()

        SERVER_LIST = [[u'example1.com', 4064, u'omero1'],
                       [u'example2.com', 4064, u'omero2'],
                       [u'example3.com', 4064], [u'example4.com', 4064]]
        for s in SERVER_LIST:
            server = (len(s) > 2) and s[2] or None
            Server(host=s[0], port=s[1], server=server)
        Server.freeze()

        try:
            Server(host=u'example5.com', port=4064)
        except TypeError as te:
            assert str(te) == 'No more instances allowed'

        Server(host=u'example1.com', port=4064)
Пример #18
0
def load_server_list():
    for s in SERVER_LIST:
        server = (len(s) > 2) and unicode(s[2]) or None
        Server(host=unicode(s[0]), port=int(s[1]), server=server)
    Server.freeze()
Пример #19
0
def load_server_list():
    for s in SERVER_LIST:
        server = (len(s) > 2) and unicode(s[2]) or None
        Server(host=unicode(s[0]), port=int(s[1]), server=server)
    Server.freeze()
Пример #20
0
 def setUp(self):
     Server.reset()
Пример #21
0
import time
import random

if __name__ == '__main__':
    logger = logging.getLogger('connector.ZmqConnector')
    logger.setLevel(logging.INFO)

    formatter = logging.Formatter(
        '%(asctime)s%(levelname)8s()|%(filename)s:%(lineno)s - %(funcName)20s() - %(message)s'
    )

    ch = logging.StreamHandler(sys.stdout)
    ch.setFormatter(formatter)
    logger.addHandler(ch)

    server = Server(server_port=5556)

    while True:
        print('Waiting for message')
        message = server.receive_message()
        print('Received message: {}'.format(message))
        if int(message['my_value']) < 5:
            print('Replying...')
            server.send_message({'response': message['my_value']})
        elif message['my_value'] < 10:
            sleep_time = random.randint(0, 2)
            print('Simulating short delay, sleeping for {}'.format(sleep_time))
            time.sleep(sleep_time)
            print('Replying...')
            server.send_message({'response': message['my_value']})
        elif message['my_value'] < 15:
Пример #22
0
    
    def test_load_server_list(self):
        SERVER_LIST = [[u'example1.com', 4064, u'omero1'], [u'example2.com', 4064, u'omero2'], [u'example3.com', 4064], [u'example4.com', 4064]]
        for s in SERVER_LIST:
            server = (len(s) > 2) and s[2] or None
            Server(host=s[0], port=s[1], server=server)
        Server.freeze()
        
        try:
            Server(host=u'example5.com', port=4064)
        except Exception, x:
            pass
        else:
            self.fail('Error:No more instances allowed')

        Server(host=u'example1.com', port=4064)


# Testing client, URLs
class WebAdminUrlTest(WebAdminClientTest):
    
    def test_login(self):
        params = {
            'username': '******',
            'password': self.root_password,
            'server':self.server_id,
            'ssl':'on'
        }
        
        response = self.client.post(reverse(viewname="walogin"), params)
        # Check that the response was a 302 (redirect)
Пример #23
0
def load_server_list():
    for s in SERVER_LIST:  # from CUSTOM_SETTINGS_MAPPINGS  # noqa
        server = (len(s) > 2) and unicode(s[2]) or None
        Server(host=unicode(s[0]), port=int(s[1]), server=server)
    Server.freeze()
Пример #24
0
def load_server_list():
    for s in SERVER_LIST:  # from CUSTOM_SETTINGS_MAPPINGS  # noqa
        server = (len(s) > 2) and unicode(s[2]) or None
        Server(host=unicode(s[0]), port=int(s[1]), server=server)
    Server.freeze()
Пример #25
0
import os
import sys
sys.path.append(
    os.path.dirname(
        os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))
from connector import Server

print('Initializing server')
server = Server(server_port=5556)

print('Waiting for message....')
received_message = server.receive_message()

print('Received following message:\n\t{}'.format(received_message))

my_reply = 'This is my reply'

print('Sending reply....')
server.send_message(my_reply)

print('Done. Quitting...')