Example #1
0
    def __init__(self, ip_addr, port_num):
        global action
        global action_set_time

        # init server
        self.auth = server_auth.server_auth()
        # Create a TCP/IP socket
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        # Bind the socket to the port
        server_address = (ip_addr, port_num)
        print('starting up on %s port %s' % server_address, file=sys.stderr)
        self.sock.bind(server_address)
        # Listen for incoming connections
        self.sock.listen(3)
        self.actions = ['wavehands', 'busdriver', 'frontback', 'sidestep', 'jumping']
#[                'jumpingjack', 'turnclap', 'squatturnclap', 'windowcleaning', 'windowcleaner360']
        self.filename = "logServer.csv"
        self.columns = ['timestamp', 'action',
                'goal', 'time_delta',
                'correct', 'voltage', 'current', 'power', 'cumpower']
        self.df = pd.DataFrame(columns=self.columns)
        self.df = self.df.set_index('timestamp')
        action = None
        action_set_time = None
        self.timeout = 60
        self.no_response = False
Example #2
0
def testAuthentication(action, voltage, current, power, cumpower):
    from server_auth import server_auth
    server = server_auth()
    aesKey = "abcdef1234_12345"
    cipherText = encryptText(aesKey, action, voltage, current, power, cumpower)
    plainText = server.decryptText(cipherText, aesKey)
    for k in plainText:
        print("{0}: {1}".format(k, plainText[k]))
    def __init__(self, ip_addr, port_num):

        threading.Thread.__init__(self)

        self.shutdown = threading.Event()



        # init server

        self.auth = server_auth()

        # Create a TCP/IP socket

        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        # Bind the socket to the port

        server_address = (ip_addr, port_num)

        print('starting up on %s port %s' % server_address, file=sys.stderr)

        self.sock.bind(server_address)

        # Listen for incoming connections

        self.sock.listen(1)

        self.actions = ['wipers', 'wipers', 'wipers', 'wipers',

                        'number7', 'number7', 'number7', 'number7',

                        'chicken', 'chicken', 'chicken', 'chicken',

                        'sidestep', 'sidestep', 'sidestep', 'sidestep',

                        'turnclap', 'turnclap', 'turnclap', 'turnclap']

                   'numbersix', 'numbersix', 'numbersix', 'numbersix',

                   'salute', 'salute', 'salute', 'salute',

                   'mermaid', 'mermaid', 'mermaid', 'mermaid',

                   'swing', 'swing', 'swing', 'swing',

                   'cowboy', 'cowboy', 'cowboy', 'cowboy']
Example #4
0
    def __init__(self, ip_addr, port_num):
        threading.Thread.__init__(self)
        self.shutdown = threading.Event()

        # init server
        self.auth = server_auth()
        # Create a TCP/IP socket
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        # Bind the socket to the port
        server_address = (ip_addr, port_num)

        print('starting up on %s port %s' % server_address, file=sys.stderr)

        self.sock.bind(server_address)
        # Listen for incoming connections
        self.sock.listen(1)
        self.actions = [
            'wipers', 'wipers', 'wipers', 'wipers', 'number7', 'number7',
            'number7', 'number7', 'chicken', 'chicken', 'chicken', 'chicken',
            'sidestep', 'sidestep', 'sidestep', 'sidestep', 'turnclap',
            'turnclap', 'turnclap', 'turnclap'
        ]
        #           'numbersix', 'numbersix', 'numbersix', 'numbersix',
        #           'salute', 'salute', 'salute', 'salute',
        #           'mermaid', 'mermaid', 'mermaid', 'mermaid',
        #           'swing', 'swing', 'swing', 'swing',
        #           'cowboy', 'cowboy', 'cowboy', 'cowboy']

        self.n_moves = len(self.actions)
        self.indices = np.arange(self.n_moves)
        self.filename = "logServer.csv"
        self.columns = [
            'timestamp', 'action', 'goal', 'time_delta', 'correct', 'voltage',
            'current', 'power', 'cumpower'
        ]
        self.df = pd.DataFrame(columns=self.columns)
        self.df = self.df.set_index('timestamp')
        self.action = None
        self.action_set_time = None
        self.x = 0
        self.timeout = 30
        self.no_response = False
        self.connection = None
        self.timer = None
        self.logout = False
Example #5
0
    def __init__(self, ip_addr, port_num):
        global action
        global action_set_time

        # init server
        self.auth = server_auth.server_auth()
        # Create a TCP/IP socket
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        # Bind the socket to the port
        server_address = (ip_addr, port_num)
        print('starting up on %s port %s' % server_address, file=sys.stderr)
        self.sock.bind(server_address)
        # Listen for incoming connections
        self.sock.listen(1)
        self.actions = [
            'wavehands', 'wavehands', 'wavehands', 'wavehands', 'jump', 'jump',
            'jump', 'jump', 'frontback', 'frontback', 'frontback', 'frontback',
            'frontback', 'frontback', 'frontback', 'frontback', 'turnclap',
            'turnclap', 'turnclap', 'turnclap', 'windowcleaning',
            'windowcleaning', 'windowcleaning', 'windowcleaning', 'numbersix',
            'numbersix', 'numbersix', 'numbersix', 'jumpleftright',
            'jumpleftright', 'jumpleftright', 'jumpleftright', 'sidestep',
            'sidestep', 'sidestep', 'sidestep', 'squatturnclap',
            'squatturnclap', 'squatturnclap', 'squatturnclap',
            'windowcleaner360', 'windowcleaner360', 'windowcleaner360',
            'windowcleaner360'
        ]
        self.indices = [
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
            19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
            36, 37, 38, 39
        ]
        self.filename = "logServer.csv"
        self.columns = [
            'timestamp', 'action', 'goal', 'time_delta', 'correct', 'voltage',
            'current', 'power', 'cumpower'
        ]
        self.df = pd.DataFrame(columns=self.columns)
        self.df = self.df.set_index('timestamp')
        action = None
        action_set_time = None
        self.timeout = 60
        self.no_response = False
 def __init__(self, ip_addr, port_num):
     threading.Thread.__init__(self)
     self.shutdown = threading.Event()
     # init server
     self.auth = server_auth()
     # Create a TCP/IP socket
     self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     # Bind the socket to the port
     server_address = (ip_addr, port_num)
     print('starting up on %s port %s' % server_address, file=sys.stderr)
     self.sock.bind(server_address)
     # Listen for incoming connections
     self.sock.listen(1)
     self.actions = [
         'hunchback', 'hunchback', 'hunchback', 'hunchback', 'raffles',
         'raffles', 'raffles', 'raffles', 'chicken', 'chicken', 'chicken',
         'chicken', 'crab', 'crab', 'crab', 'crab', 'cowboy', 'cowboy',
         'cowboy', 'cowboy', 'runningman', 'runningman', 'runningman',
         'runningman', 'doublepump', 'doublepump', 'doublepump',
         'doublepump', 'mermaid', 'mermaid', 'mermaid', 'mermaid', 'snake',
         'snake', 'snake', 'snake', 'jamesbond', 'jamesbond', 'jamesbond',
         'jamesbond'
     ]
     self.n_moves = len(self.actions)
     self.indices = np.arange(self.n_moves)
     self.filename = "logServer.csv"
     self.columns = [
         'timestamp', 'action', 'goal', 'time_delta', 'correct', 'voltage',
         'current', 'power', 'cumpower'
     ]
     self.df = pd.DataFrame(columns=self.columns)
     self.df = self.df.set_index('timestamp')
     self.action = None
     self.action_set_time = None
     self.x = 0
     self.timeout = 20
     self.no_response = False
     self.connection = None
     self.timer = None
     self.logout = False
     self.correct = 0
Example #7
0
    def __init__(self, ip_addr, port_num):
        global action
        global action_set_time

        # init server
        self.auth = server_auth.server_auth()
        # Create a TCP/IP socket
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        # Bind the socket to the port
        server_address = (ip_addr, port_num)
        print('starting up on %s port %s' % server_address, file=sys.stderr)
        self.sock.bind(server_address)
        # Listen for incoming connections
        self.sock.listen(3)
        self.actions = ['busdriver', 'frontback', 'jumping', 'jumpingjack', 'sidestep',
                'squatturnclap', 'turnclap', 'wavehands', 'windowcleaner360',
                'windowcleaning']
        self.filename = "logServer.csv"
        self.columns = ['timestamp', 'action',
                'goal', 'time_delta',
                'correct', 'voltage', 'current', 'power', 'cumpower']
        self.df = pd.DataFrame(columns=self.columns)
        self.df = self.df.set_index('timestamp')
        action = None
        action_set_time = None
        self.timeout = 60
        self.getAction()

        while True:
            # Wait for a connection
            print('waiting for a connection', file=sys.stderr)
            connection, client_address = self.sock.accept()
            key = input("Enter the secret key: ")
            self.secret_key = hashlib.sha256(key.encode()).digest()

            print('connection from', client_address, file=sys.stderr)

            if len(self.secret_key) == 16 or len(self.secret_key) == 24 or len(self.secret_key) == 32:
              pass
            else:
              print ("AES key must be either 16, 24, or 32 bytes long")
              break

            # Receive the data in small chunks and retransmit it
            while True:
                data = connection.recv(1024)
                print('received')
                if data:
                        try:
                            msg = data
                            print('%s' %msg)
                            decodedmsg = self.auth.decryptText(msg,self.secret_key)
                            if decodedmsg['action'] == "logout  ":
                                print("bye bye")
                            elif len(decodedmsg['action']) == 0:
                                pass
                            print('before log move')
                            self.logMoveMade(decodedmsg['action'], decodedmsg['voltage'],decodedmsg['current'],decodedmsg['power'],decodedmsg['cumpower'])
                            print("{} :: {} :: {} :: {} :: {}".format(decodedmsg['action'].strip(), decodedmsg['voltage'].strip(),decodedmsg['current'].strip(),decodedmsg['power'].strip(),decodedmsg['cumpower'].strip()))
                                
                        except Exception as e:
                            print(e)
                else:
                     print('no more data from', client_address, file=sys.stderr)
                     connection.close()
                     break
Example #8
0
    def __init__(self, ip_addr, port_num):

        threading.Thread.__init__(self)

        self.shutdown = threading.Event()

        # init server
        self.auth = server_auth()

        # Create a TCP/IP socket
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        print("socket created")

        # Binding the socket to the port
        server_address = (ip_addr, port_num)
        print('starting up on %s port %s' % server_address, file=sys.stderr)
        try:
            self.sock.bind(server_address)
        except socket.error as msg:
            print(msg)
        print("Socket bind complete.")

        # Listen for incoming connections
        self.sock.listen(1)
        connection, address = s.accept(
        )  #we define the connection and address as what the socket accepts
        print("Connected to " + address[0] + ":" + str(address[1]))

        self.actions = [
            'handmotor', 'handmotor', 'handmotor', 'handmotor', 'bunny',
            'bunny', 'bunny', 'bunny', 'tapshoulders', 'tapshoulders',
            'tapshoulders', 'tapshoulders', 'rocket', 'rocket', 'rocket',
            'rocket', 'cowboy', 'cowboy', 'cowboy', 'cowboy'
        ]

        #           'hunchback', 'hunchback', 'hunchback', 'hunchback',

        #           'jamesbond', 'jamesbond', 'jamesbond', 'jamesbond',

        #           'chicken', 'chicken', 'chicken', 'chicken',

        #           'movingsalute', 'movingsalute', 'movingsalute', 'movingsalute',

        #           'whip', 'whip', 'whip', 'whip']

        self.n_moves = len(self.actions)

        self.indices = np.arange(self.n_moves)

        self.filename = "logServer.csv"

        self.columns = [
            'timestamp', 'action', 'goal', 'time_delta', 'correct', 'voltage',
            'current', 'power', 'cumpower'
        ]

        self.df = pd.DataFrame(columns=self.columns)

        self.df = self.df.set_index('timestamp')

        self.action = None

        self.action_set_time = None

        self.x = 0

        self.timeout = 60

        self.no_response = False

        self.connection = None

        self.timer = None

        self.logout = False
Example #9
0
    def __init__(self, ip_addr, port_num):

        threading.Thread.__init__(self)

        self.shutdown = threading.Event()



        # init server

        self.auth = server_auth()

        # Create a TCP/IP socket

        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        # Bind the socket to the port

        server_address = (ip_addr, port_num)

        print('starting up on %s port %s' % server_address)

        self.sock.bind(server_address)

        # Listen for incoming connections

        self.sock.listen(1)

        self.actions = ['handmotor', 'handmotor', 'handmotor', 'handmotor',

                        'bunny', 'bunny', 'bunny', 'bunny',

                        'tapshoulders', 'tapshoulders', 'tapshoulders', 'tapshoulders',

                        'rocket', 'rocket', 'rocket', 'rocket',

                        'cowboy', 'cowboy', 'cowboy', 'cowboy']

        #           'hunchback', 'hunchback', 'hunchback', 'hunchback',

        #           'jamesbond', 'jamesbond', 'jamesbond', 'jamesbond',

        #           'chicken', 'chicken', 'chicken', 'chicken',

        #           'movingsalute', 'movingsalute', 'movingsalute', 'movingsalute',

        #           'whip', 'whip', 'whip', 'whip']



        self.n_moves = len(self.actions)

        self.indices = np.arange(self.n_moves)

        self.filename = "logServer.csv"

        self.columns = ['timestamp', 'action', 'goal', 'time_delta', 'correct', 'voltage', 'current', 'power',

                        'cumpower']

        self.df = pd.DataFrame(columns=self.columns)

        self.df = self.df.set_index('timestamp')

        self.action = None

        self.action_set_time = None

        self.x = 0

        self.timeout = 60

        self.no_response = False

        self.connection = None

        self.timer = None

        self.logout = False