import socket, json
from db_uci import dbuci
from comunicacion import sendT, listenB, registerS
srv = 'ccdli'

#log in usuario
def loginU(login):
    crsr = dbuci.cursor()
    crsr.execute("SELECT * FROM users WHERE username = %s AND password = %s AND rol = %s", (login["username"],login["password"],login["rol"]))
    fetched = crsr.fetchone()
    if fetched:
        response = {"respuesta":{"username":fetched[1],"password":fetched[2],"rol":fetched[3]}}
        sendT(sckt, srv, json.dumps(response))
    else:
        response = {"respuesta":"No es posible entrar con el usuario ingresado."}
        sendT(sckt, srv, json.dumps(response))

if __name__ == "__main__":
    try:
        sckt = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        server_address = ('localhost', 5000)
        print('Servicio: Conectándose a {} puerto {}'.format(*server_address))
        sckt.connect(server_address)
    except: 
        print("No es posible la conexión al bus")
        quit() 

    registerS(sckt, srv)

    while True:
        nS, mT = listenB(sckt)
        if nS == srv:
            loginU(login = json.loads(mT))
        else:
            response = {"respuesta":"servicio equivocado"}
            sendT(sckt, srv, json.dumps(response))
32fff3da285ecee03b37bbc0ed054f451c6684c5
<mask token>


def loginU(login):
    crsr = dbuci.cursor()
    crsr.execute(
        'SELECT * FROM users WHERE username = %s AND password = %s AND rol = %s'
        , (login['username'], login['password'], login['rol']))
    fetched = crsr.fetchone()
    if fetched:
        response = {'respuesta': {'username': fetched[1], 'password':
            fetched[2], 'rol': fetched[3]}}
        sendT(sckt, srv, json.dumps(response))
    else:
        response = {'respuesta':
            'No es posible entrar con el usuario ingresado.'}
        sendT(sckt, srv, json.dumps(response))


<mask token>

<mask token>


def loginU(login):
    crsr = dbuci.cursor()
    crsr.execute(
        'SELECT * FROM users WHERE username = %s AND password = %s AND rol = %s'
        , (login['username'], login['password'], login['rol']))
    fetched = crsr.fetchone()
    if fetched:
        response = {'respuesta': {'username': fetched[1], 'password':
            fetched[2], 'rol': fetched[3]}}
        sendT(sckt, srv, json.dumps(response))
    else:
        response = {'respuesta':
            'No es posible entrar con el usuario ingresado.'}
        sendT(sckt, srv, json.dumps(response))


if __name__ == '__main__':
    try:
        sckt = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        server_address = 'localhost', 5000
        print('Servicio: Conectándose a {} puerto {}'.format(*server_address))
        sckt.connect(server_address)
    except:
        print('No es posible la conexión al bus')
        quit()
    registerS(sckt, srv)
    while True:
        nS, mT = listenB(sckt)
        if nS == srv:
            loginU(login=json.loads(mT))
        else:
            response = {'respuesta': 'servicio equivocado'}
            sendT(sckt, srv, json.dumps(response))

<mask token>
srv = 'ccdli'


def loginU(login):
    crsr = dbuci.cursor()
    crsr.execute(
        'SELECT * FROM users WHERE username = %s AND password = %s AND rol = %s'
        , (login['username'], login['password'], login['rol']))
    fetched = crsr.fetchone()
    if fetched:
        response = {'respuesta': {'username': fetched[1], 'password':
            fetched[2], 'rol': fetched[3]}}
        sendT(sckt, srv, json.dumps(response))
    else:
        response = {'respuesta':
            'No es posible entrar con el usuario ingresado.'}
        sendT(sckt, srv, json.dumps(response))


if __name__ == '__main__':
    try:
        sckt = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        server_address = 'localhost', 5000
        print('Servicio: Conectándose a {} puerto {}'.format(*server_address))
        sckt.connect(server_address)
    except:
        print('No es posible la conexión al bus')
        quit()
    registerS(sckt, srv)
    while True:
        nS, mT = listenB(sckt)
        if nS == srv:
            loginU(login=json.loads(mT))
        else:
            response = {'respuesta': 'servicio equivocado'}
            sendT(sckt, srv, json.dumps(response))

import socket, json
from db_uci import dbuci
from comunicacion import sendT, listenB, registerS
srv = 'ccdli'


def loginU(login):
    crsr = dbuci.cursor()
    crsr.execute(
        'SELECT * FROM users WHERE username = %s AND password = %s AND rol = %s'
        , (login['username'], login['password'], login['rol']))
    fetched = crsr.fetchone()
    if fetched:
        response = {'respuesta': {'username': fetched[1], 'password':
            fetched[2], 'rol': fetched[3]}}
        sendT(sckt, srv, json.dumps(response))
    else:
        response = {'respuesta':
            'No es posible entrar con el usuario ingresado.'}
        sendT(sckt, srv, json.dumps(response))


if __name__ == '__main__':
    try:
        sckt = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        server_address = 'localhost', 5000
        print('Servicio: Conectándose a {} puerto {}'.format(*server_address))
        sckt.connect(server_address)
    except:
        print('No es posible la conexión al bus')
        quit()
    registerS(sckt, srv)
    while True:
        nS, mT = listenB(sckt)
        if nS == srv:
            loginU(login=json.loads(mT))
        else:
            response = {'respuesta': 'servicio equivocado'}
            sendT(sckt, srv, json.dumps(response))

import socket, json
from db_uci import dbuci
from comunicacion import sendT, listenB, registerS
srv = 'ccdli'

#log in usuario
def loginU(login):
    crsr = dbuci.cursor()
    crsr.execute("SELECT * FROM users WHERE username = %s AND password = %s AND rol = %s", (login["username"],login["password"],login["rol"]))
    fetched = crsr.fetchone()
    if fetched:
        response = {"respuesta":{"username":fetched[1],"password":fetched[2],"rol":fetched[3]}}
        sendT(sckt, srv, json.dumps(response))
    else:
        response = {"respuesta":"No es posible entrar con el usuario ingresado."}
        sendT(sckt, srv, json.dumps(response))

if __name__ == "__main__":
    try:
        sckt = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        server_address = ('localhost', 5000)
        print('Servicio: Conectándose a {} puerto {}'.format(*server_address))
        sckt.connect(server_address)
    except: 
        print("No es posible la conexión al bus")
        quit() 

    registerS(sckt, srv)

    while True:
        nS, mT = listenB(sckt)
        if nS == srv:
            loginU(login = json.loads(mT))
        else:
            response = {"respuesta":"servicio equivocado"}
            sendT(sckt, srv, json.dumps(response))