import msgpackrpc
import base64
import time

for i in range(3, 4):
    filepath = 'C:\\NESLProjects\\airsim_v1.2.0\\screenshot\\Drone1\\{}-0.png'.format(
        i)
    with open(filepath, 'rb') as binary_file:
        # Read the whole file at once
        data = binary_file.read()
    data = base64.b64encode(data)
    print(i)
    t1 = time.time()
    client = msgpackrpc.Client(msgpackrpc.Address("172.17.20.12", 18800))
    result = client.call('push', data, time.time())
    t2 = time.time()
    print(result)
    # print(t2-t1)
    # time.sleep(3)
Exemple #2
0
def doRpcClientToPythonSvc(port):
    address = msgpackrpc.Address('localhost', port)
    client = msgpackrpc.Client(address, unpack_encoding='utf-8')
    print client.call("Echo123", "A1", "B2", "C3")
    print client.call("EchoStruct", {"A" :"Aa", "B":"Bb", "C":"Cc"})
Exemple #3
0
 def __init__(self, ip, port):
     self.client = msgpackrpc.Client(msgpackrpc.Address(ip, port),
                                     timeout=3600)
Exemple #4
0
 def connect(self):
     self.client = msgpackrpc.Client(msgpackrpc.Address(self.host, self.port))
Exemple #5
0
    def getalldomain(self):
        redis_client = redis_conn()
        if redis_client.exists('getall'):
            json1 = redis_client.get('getall')
        else:
            getall = Domain.objects.all().filter(enable=1)
            #getall = Domain.objects.all()
            logger.info("getall: %d", len(getall))
            json1 = serializers.serialize("yaml", getall)
            redis_client.set('getall', json1)
            #logger.info("json: %s", json1)
            redis_client.expire('getall', 3600)
        return json1

    def push_metrics(self, x):
        bs = connbeanstalk()
        bs.use('url_check')
        bs.put(x)
        return 1

    def push_alarm(self, x):
        bs = connbeanstalk()
        bs.use('url_alarm')
        bs.put(x)
        return 1


server = msgpackrpc.Server(RpcServer())
server.listen(msgpackrpc.Address("0.0.0.0", CONFIG['listen']))
server.start()
Exemple #6
0
def main():
    server = msgpackrpc.Server(FooServer())
    server.listen(msgpackrpc.Address("localhost", 3000))
    server.start()
Exemple #7
0
#!/usr/bin/python
import msgpackrpc

client = msgpackrpc.Client(msgpackrpc.Address("127.0.0.1", 5555))
print "small potatoes"
for x in range(0, 10):
    result = client.call('reverse_and_multiply', 'yarbles', x)
    print x, result, '\n----'

#big input
print "10k input"
try:
    result = client.call('hello', 'y' * 10000)
    print "large input result:", len(result)
except msgpackrpc.error.RPCError as e:
    print "got exception:", e

print "16k input"
try:
    result = client.call('hello', 'y' * 16000)
    print "large input result:", len(result)
except msgpackrpc.error.RPCError as e:
    print "got exception:", e

print "17k input"
try:
    result = client.call('hello', 'y' * 17000)
    print "large input result:", len(result)
except msgpackrpc.error.RPCError as e:
    print "got exception:", e
        v_to = Vector3r().init_from_string(to_pos)
        logging.info('{} -> {}'.format(v_from, v_to))
        distance = lib_geo.getDistance(v_to, v_from)
        logging.info('{}'.format(distance))
        delta_t = int(distance / velocity)
        logging.info(
            'move {} from {} to {}, velocity={}, dist={}, delta_t={}'.format(
                station_name, from_pos, to_pos, velocity, distance, delta_t))
        station = self.Stations[station_name]
        self.net.startMobility(time=0, repetitions=0)
        self.net.mobility(station, 'start', time=1, position=from_pos)
        self.net.mobility(station, 'stop', time=delta_t + 1, position=to_pos)
        self.net.stopMobility(time=delta_t + 2)
        return True

    def start_cil(self):
        CLI_wifi(self.net)
        return True


######################## MAIN ########################

logging.basicConfig(level=logging.DEBUG)

ip = '172.17.20.12'
port = 18800
logging.info('starting msgpackrpc at {}:{}'.format(ip, port))
server = msgpackrpc.Server(MininetServer())
server.listen(msgpackrpc.Address(ip, port))
server.start()
Exemple #9
0
import msgpackrpc
import time

# this script repeatedly plays games and marks down the winners
autogame = msgpackrpc.Client(msgpackrpc.Address("127.0.0.1", 64720))


def launch_game():
    autogame.call(
        'ResetGameSettings'
    )  # usually reset the settings to make sure everything is valid
    autogame.call('SetGameRevealMap', 2)  # set map to "All Visible"
    autogame.call('SetGameMapType', 12)  # set map location to Black Forest
    autogame.call('SetGameMapSize', 0)
    autogame.call('SetGameDifficulty', 1)
    autogame.call('SetGameStartingAge', 0)
    autogame.call('SetGameType', 0)
    autogame.call('SetGameTeamsLocked', True)

    autogame.call('SetPlayerComputer', 1, "Barbarian")
    autogame.call('SetPlayerComputer', 2, "AT_Empire")

    autogame.call('SetRunFullSpeed',
                  True)  # run the game logic as fast as possible
    autogame.call('SetRunUnfocused',
                  True)  # allow the game to run while minimized
    return autogame.call('StartGame')  # start the match


num_games = 0
win_one = 0
Exemple #10
0
# Starting init process on each device which communicates
# to the the coordinator

import msgpackrpc

Heliot_Client_Port = 18800


class Heliot_Client(object):

    ## Coordinator calls check_connection
    ## and devices return true if they are working
    def check_connection(self):
        return True


server = msgpackrpc.Server(Heliot_Client())
server.listen(msgpackrpc.Address("localhost", Heliot_Client_Port))
server.start()
Exemple #11
0
def _call(ip, port, method, *args):
    client = msgpackrpc.Client(msgpackrpc.Address(ip, port))
    result = client.call(method, *args)
    return result
Exemple #12
0
 def __init__(self, ip = "", port = 41451, timeout_value = 3600):
     if (ip == ""):
         ip = "127.0.0.1"
     self.client = msgpackrpc.Client(msgpackrpc.Address(ip, port), timeout = timeout_value, pack_encoding = 'utf-8', unpack_encoding = 'utf-8')
Exemple #13
0
 def __init__(self, name, ip, port):
     self.name = name
     super(BaseClient, self).__init__(msgpackrpc.Address(ip, port),
                                      timeout=30)
Exemple #14
0
def doRpcClientToGoSvc(port):
    # print ">>>> port: ", port, " <<<<<"
    address = msgpackrpc.Address('localhost', port)
    client = msgpackrpc.Client(address, unpack_encoding='utf-8')
    print client.call("TestRpcInt.Echo123", ["A1", "B2", "C3"])
    print client.call("TestRpcInt.EchoStruct", {"A" :"Aa", "B":"Bb", "C":"Cc"})
Exemple #15
0
 def __init__(self, ip, port):
     self.client = msgpackrpc.Client(msgpackrpc.Address(ip, port), timeout = 3600, pack_encoding = 'utf-8', unpack_encoding = 'utf-8')
import msgpackrpc


class SumServer(object):
    def sum(self, x, y):
        return x + y


server = msgpackrpc.Server(SumServer())
server.listen(msgpackrpc.Address("localhost", 18800))
server.start()
Exemple #17
0
def main():
    client = msgpackrpc.Client(msgpackrpc.Address("localhost", 3000))
    result = client.call("sum", 1, 2)

    print(result)