Example #1
0
class IdentityClient(TCPServiceClient):
    def __init__(self):
        super(IdentityClient, self).__init__("IdentityService", 1)

    @request
    def create(self, user_name, password):
        return locals()

    @subscribe
    def password_changed(self, user_name):
        print("Password changed event received")
        yield from asyncio.sleep(4)
        print("Password changed {}".format(user_name))

    def repeat_request(self):
        yield from asyncio.sleep(5)
        yield from self.create('test', 'test@123')
        yield from self.repeat_request()

if __name__ == '__main__':
    tcp = AccountService(ACCOUNTS_HOST, ACCOUNTS_PORT)
    tcp.clients = [IdentityClient()]
    Host.registry_host = REGISTRY_HOST
    Host.registry_port = REGISTRY_PORT
    Host.pubsub_host = REDIS_HOST
    Host.pubsub_port = REDIS_PORT
    Host.name = 'Identity'
    Host.attach_service(tcp)
    Host.run()
Example #2
0
                    for_ghost = '0 '+str(disp[0])+' '+str(disp[1])+'\n'
                    if dist(pen_cords, cur_cords) > 10:
                        for_ghost = '1 1 0\n' + for_ghost + '1 0 0\n'
                    ghost_data += for_ghost
                else:
                    if line[0:5] == '1 1 0':
                        continue
                    cords = line.strip().split('*')[1].split(' ')
                    pen_cords = (int(cords[0]), int(cords[1]))
                    ghost_data += line.split('*')[0] + '\n'
        ghost_data += '1 1 0\n'
        requests.post(GHOST_ADDRESS, ghost_data)
        f.close()
        self.ocrres = asyncio.Future()
        res = yield from self.ocrres
        return Response(status=200, body=res.encode())

    # Response from the Ghost Server which contains the recognized string.
    @get(path='/ocrres/{res}')
    def req5(self, request: Request):
        self.ocrres.set_result(request.match_info.get('res'))
        return Response(status=200, body='thanx'.encode())


if __name__ == '__main__':
    http = TaggerService(MY_URL, 4501)
    Host.configure('TaggerService')
    Host.attach_http_service(http)
    Host.ronin = True
    Host.run()