def test_getCommand(self):
     """Test wether getting commands from the network works.
        Sends command through TCP/IP and check wether the same command is received on the other end."""
     self.assertTrue(self.communicator.wait_listen(2), "Communicator not listening")
     CommandSocket = ThreadedSocket('localhost', self.testport, giveup=0, retry_timeout=0.1)
     self.assertTrue(CommandSocket.wait_connect(4), "Could not connect to communicator")
     CommandSocket.send(self.TestCommand)
     time.sleep(0.1) # Wait a bit for the socket to be available
     received, conn_id = self.communicator.get_command()
     self.assertEqual(received, self.TestCommand) #,"Oh no, we received something else than we sent!")
示例#2
0
 def test_getCommand(self):
     """Test wether getting commands from the network works.
        Sends command through TCP/IP and check wether the same command is received on the other end."""
     self.assertTrue(self.communicator.wait_listen(2),
                     "Communicator not listening")
     CommandSocket = ThreadedSocket('localhost',
                                    self.testport,
                                    giveup=0,
                                    retry_timeout=0.1)
     self.assertTrue(CommandSocket.wait_connect(4),
                     "Could not connect to communicator")
     CommandSocket.send(self.TestCommand)
     time.sleep(0.1)  # Wait a bit for the socket to be available
     received, conn_id = self.communicator.get_command()
     self.assertEqual(
         received, self.TestCommand
     )  #,"Oh no, we received something else than we sent!")
示例#3
0
if __name__ == "__main__":
    host = "localhost"
    port = 12345
    if len(sys.argv) > 2:
        host = sys.argv[1]
        port = int(sys.argv[2])
    # logging.getLogger('Borg.Brain').addHandler(util.loggingextra.ScreenOutput())
    # logging.getLogger('Borg.Brain').setLevel(logging.INFO)
    sock = ThreadedSocket(host, port, giveup=0, use_pickle=False, server=False)
    sock.start()
    try:
        start = time.time()
        while not sock.connected and time.time() - start < 2:
            time.sleep(0.01)
        if sock.connected:
            sock.send("quit\r\n")
            while sock.connected and time.time() - start < 2:
                time.sleep(0.01)
            if not sock.connected:
                print "Pioneercontroller at %s is running on port %d" % (host, port)
                sys.exit(0)
            else:
                print "Service running at %s on port %d but not behaving properly as pioneercontroller" % (host, port)
                print repr(sock.get_data())
                sys.exit(1)
        else:
            print "Pioneercontroller at %s is not running on port %d" % (host, port)
            sys.exit(1)
    except Exception as e:
        print repr(e)
        raise
import time

if __name__ == '__main__':
    host = "localhost"
    port = 49152
    if len(sys.argv) > 2:
        host = sys.argv[1]
        port = int(sys.argv[2])
    sock = ThreadedSocket(host, port, giveup=2)
    sock.start()
    try:
        start = time.time()
        while not sock.connected and time.time() - start < 1:
            time.sleep(0.01)
        if sock.connected:
            sock.send("diag")
            start = time.time()
            data = []
            while time.time() - start < 2 and data == []:
                time.sleep(0.01)
                data = sock.get_data()
            for item in data:
                if 'status' in item:
                    if item['status'] == 'Communicator is running ok':
                        print "Communicator at %s is running on port %d" % (
                            host, port)
                        sock.close()
                        sys.exit(0)

            print "Communicator at %s is not running on port %d" % (host, port)
            sock.close()
示例#5
0
import time

if __name__ == '__main__':
    host = "localhost"
    port = 49152
    if len(sys.argv) > 2:
        host = sys.argv[1]
        port = int(sys.argv[2])
    sock = ThreadedSocket(host, port, giveup=2)
    sock.start()
    try:
        start = time.time()
        while not sock.connected and time.time() - start < 1:
            time.sleep(0.01)
        if sock.connected:
            sock.send("diag")
            start = time.time()
            data = []
            while time.time() - start < 2 and data == []:
                time.sleep(0.01)
                data = sock.get_data()
            for item in data:
                if 'status' in item:
                    if item['status'] == 'Communicator is running ok':
                        print "Communicator at %s is running on port %d" % (host, port)
                        sock.close()
                        sys.exit(0)

            print "Communicator at %s is not running on port %d" % (host, port)
            sock.close()
            sys.exit(1)