def ObtenerFotos(imagen: hug.types.text): directorio = imagen.strip().split("-")[0] pathito = f"./Reportes/{directorio}/" foto = os.path.join(pathito, imagen.strip()) return foto
def log_this(username: hug.types.text, compname: hug.types.text,stat: hug.types.text,time: hug.types.text, hug_timer=3): data = {'username':'******'.format(username),'compname':'{0}'.format(compname),'stat':'{0}'.format(stat),'time':'{0}'.format(time)} data2 = (username.strip(),compname,stat,time) try: c.execute("INSERT INTO users VALUES "+str(data2)) except sqlite3.OperationalError: makedb() c.execute("INSERT INTO users VALUES "+str(data2)) conn.commit() return data
def AltaUsuario(nombre: hug.types.text, apellidoPaterno: hug.types.text, apellidoMaterno: hug.types.text, email: hug.types.text, FeNa: hug.types.text, Password: hug.types.text, CURP: hug.types.text, Tipo: hug.types.number, body): global USUARIOLOG if (Tipo == 1): Delegacion = body.get("Delegacion") if Delegacion == None: return { "status": 404, "message": "El Usuario Gestor necesita una Delegacion asociada" } if nombre == "" or apellidoPaterno == "" or apellidoMaterno == "" or email == "" or FeNa == "" or Password == "" or CURP == "": return { "status": 404, "message": "El Usuario necesita todos los parametro" } today = datetime.now() year = today.year yearBorn = FeNa.strip().split("-")[0] if (int(year) - int(yearBorn)) < 16: return { "status": 404, "message": "El Usuario necesita tener mas de 16" } statusBase = base.insertarUsuario( nombre=nombre, apellidoPaterno=apellidoPaterno, apellidoMaterno=apellidoMaterno, email=email, FeNa=FeNa, Password=base.hash_string(Password), CURP=CURP, Tipo=Tipo, Delegacion="" if Tipo == 0 else Delegacion) if statusBase == 201: USUARIOLOG = email return { "status": statusBase, "message": "Usuario registrado con Exito" if statusBase == 201 else "Error al registrar Usuario" }