def connectToSpec(self, specVersion):
        self.connection = SpecConnectionsManager().getConnection(specVersion)
        self.__specVersion = specVersion

        SpecEventsDispatcher.connect(self.connection, 'connected',
                                     self.__connected)
        SpecEventsDispatcher.connect(self.connection, 'disconnected',
                                     self.__disconnected)

        if self.connection.isSpecConnected():
            self.__connected()
Exemple #2
0
def waitConnection(connection, timeout=None):
    """Wait for a connection to Spec to be established

    Arguments:
    connection -- a 'host:port' string
    timeout -- optional timeout (defaults to None)
    """
    if type(connection) in (str, bytes):
        from SpecClient.SpecConnectionsManager import SpecConnectionsManager
        connection = SpecConnectionsManager().getConnection(str(connection))

    w = SpecWaitObject(connection)

    w.waitConnection(timeout=timeout)
Exemple #3
0
    def _connectToServer(self, host, specname):

        server_conn = SpecConnectionsManager(
            False).getConnection("%s:%s" % (host, specname))
        #server_conn = SpecConnection("%s:%s" % (host,specname))

        if server_conn:
            # if we use an already existing spec connection the dispatcher will not send events.
            # but as the connection is already available. we do not need them
            if server_conn.dispatcher.connected:
                self.differ_connected = True
            else:
                Dispatcher.connect(server_conn, 'connected',
                                   self.server_connected)
                Dispatcher.connect(server_conn, 'disconnected',
                                   self.server_disconnected)

        return server_conn
Exemple #4
0
def waitReply(connection, command, argsTuple, timeout=None):
    """Wait for a reply from a remote Spec server

    Arguments:
    connection -- a 'host:port' string
    command -- command to execute
    argsTuple -- tuple of arguments for the command
    timeout -- optional timeout (defaults to None)
    """
    if type(connection) in (str, bytes):
        connection = str(connection)
        from SpecClient.SpecConnectionsManager import SpecConnectionsManager
        connection = SpecConnectionsManager().getConnection(connection)
        waitConnection(connection, timeout=timeout)

    w = SpecWaitObject(connection)
    w.waitReply(command, argsTuple, timeout=timeout)

    return w.value
Exemple #5
0
def waitChannelUpdate(chanName, connection, waitValue=None, timeout=None):
    """Wait for a channel to be updated

    Arguments:
    chanName -- channel name (e.g 'var/toto')
    connection -- a 'host:port' string
    waitValue -- value to wait (defaults to None)
    timeout -- optional timeout (defaults to None)
    """
    if type(connection) in (str, bytes):
        connection = str(connection)
        from SpecClient.SpecConnectionsManager import SpecConnectionsManager
        connection = SpecConnectionsManager().getConnection(connection)
        waitConnection(connection, timeout=timeout)

    w = SpecWaitObject(connection)
    w.waitChannelUpdate(chanName, waitValue=waitValue, timeout=timeout)

    return w.value