Esempio n. 1
0
def get_radio_info():
    client = Client()
    client.connect(host, port)

    print("Sending request to server...")
    # object variables as dict
    client.send(iradio_structs.station_info_request().__dict__)
    radio_list = client.recv()
    print("radio_list recieved")

    return jsonify(**radio_list)
Esempio n. 2
0
# default uses python 2
import sys, os
base_video_dir = os.environ['CLOUD_ROOT_DIR']
utils_dir = base_video_dir + '/utils/'
sys.path.append(utils_dir)

from jsonsocket import Client, Server

host = 'localhost'
port = 8000

# Client code:
client = Client()
#client.connect(host, port).send({'some_list': [123, 456]})
client.connect(host, port).send([123, 456])
response = client.recv()
print('response: ', response)
# response now is {'data': {'some_list': [123, 456]}}
client.close()
                # ONLY IF WE OFFLOAD, query the cloud model with the embedding
                if offload_decision:
                    # whether we have offloaded once for this frame
                    at_least_one_offload = True

                    # embedding vector to send to cloud server over a socket
                    embedding_vec_to_send_dict = {
                        'frame': frame_number,
                        'emb': [str(x) for x in vec[0]]
                    }

                    # connect to server and send
                    client.connect(host, port).send(embedding_vec_to_send_dict)

                    # recieve the results back
                    cloud_response_dict = client.recv()

                    # unpack the label from the cloud
                    cloud_name = cloud_response_dict['cloud_name']
                    cloud_SVM_proba = cloud_response_dict['cloud_SVM_proba']
                    cloud_numeric_prediction = cloud_response_dict[
                        'cloud_numeric_prediction']

                    print('frame: ', frame_number, 'RESPONSE CLOUD NAME: ',
                          cloud_name, 'RESPONSE SVM PROBA: ', cloud_SVM_proba,
                          'CLOUD PRED: ', cloud_numeric_prediction)
                else:
                    # this is PURELY for training a model
                    cloud_name, cloud_SVM_proba = query_facenet_model_SVM(
                        vec=vec, recognizer=cloud_recognizer, le=cloud_le)
                    cloud_numeric_prediction = get_numeric_prediction(
Esempio n. 4
0
#!/usr/bin/python           # This is client.py file

from jsonsocket import Client

host = '192.168.12.1' 	   
port = 7878                # Reserve a port for your service.
client = Client()
print 'Client starts.'

client.connect((host, port))
print 'Client connected.'

client.send({'tx_id': 1234, 'amount': 4321})
response = client.recv()
print response
client.close()