Exemplo n.º 1
0
def run(username, stub):
    while (True):
        # print(chr(27) + "[2J")
        print(menu1.format(username))
        menu = input(">>> ")
        if flag: sleep(1)
        if menu == "1":
            while True:
                to_user = input("to user: "******"empty")

                lu = stub.ListAllUsers(m).username.split("\n")

                if not to_user in lu:
                    print("DESTINATARIO NO EXISTE")
                    continue

                body = input("   body:\n\t")
                date = dt.now().strftime('%Y-%m-%d %H:%M:%S')
                curr_mensaje = mail_pb2.Text(from_user=username,
                                             to_user=to_user,
                                             text=body,
                                             date=date)
                stub.SendText(curr_mensaje)
                # print("\t(Press any key to continue)"); getch.getch()
                break

        if menu == "2":
            m = mail_pb2.Request(username=username)
            lu = stub.ShowBandeja(m).username
            print(lu)
            input()
            # print("\t(Press any key to continue)"); getch.getch()

        elif menu == "3":
            m = mail_pb2.Request(username=username)
            users = stub.ListAllUsers(m)
            print(users.username)
            input()
            # print("\t(Press any key to continue)"); getch.getch()

        elif menu == "4":
            m = mail_pb2.Request(username=username)
            lu = stub.ShowEnviados(m).username
            print(lu)
            input()
            sleep(1)
            # print("\t(Press any key to continue)"); getch.getch()
        elif menu == "5":
            return
Exemplo n.º 2
0
 def Log(self, request, context):
     m = f"USUARIO {request.username} LOGGEADO"
     logging.info(m)
     if not request.username in enviados.keys():
         enviados[request.username] = []
         bandeja[request.username] = []
         m = f"USUARIO {request.username} REGISTRADO"
         logging.info(m)
     print(m)
     return mail_pb2.Request(username=m)
Exemplo n.º 3
0
            input()
            # print("\t(Press any key to continue)"); getch.getch()

        elif menu == "4":
            m = mail_pb2.Request(username=username)
            lu = stub.ShowEnviados(m).username
            print(lu)
            input()
            sleep(1)
            # print("\t(Press any key to continue)"); getch.getch()
        elif menu == "5":
            return
        # print("\t(Press any key to continue)"); getch.getch()


if __name__ == '__main__':
    # print(chr(27) + "[2J")
    print("INICIANDO CLIENTE")
    # server_ip = input().strip(); sleep(1);
    server_ip = "localhost"
    # server_ip = "SERVER"
    username = input("username: "******"TERMINANDO CLIENTE")
Exemplo n.º 4
0
 def ListAllUsers(self, request, context):
     m = "\n".join(enviados.keys())
     m = mail_pb2.Request(username=m)
     return m
Exemplo n.º 5
0
 def ShowEnviados(self, request, context):
     m = "\n\n".join(enviados[request.username])
     return mail_pb2.Request(username=m)
Exemplo n.º 6
0
 def ShowBandeja(self, request, context):
     m = "\n\n".join(bandeja[request.username])
     return mail_pb2.Request(username=m)