Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error get_valores_climatologicos_mensuales / get_request_data con URL 'None' #13

Closed
bdeerausquin opened this issue Dec 17, 2019 · 6 comments
Labels

Comments

@bdeerausquin
Copy link

Hola Pablo,

al solicitar los datos de varias estaciones con get_valores_climatologicos_mensuales, si una de ellas no tiene datos,
{
"descripcion" : "No hay datos que satisfagan esos criterios",
"estado" : 404
}
la función devuelve el siguiente error:

requests.exceptions.MissingSchema: Invalid URL 'None': No schema supplied. Perhaps you meant http://None?

Saludos

@bdeerausquin
Copy link
Author

Hola Pablo,

me he mirado los cambios que propones en el pull y si los aplico a models.py, entonces me da el siguiente error:

requests.exceptions.InvalidHeader: Value for header {api_key: <bound method AemetHttpClient.get_api_key of <aemet.models.Aemet object at 0x00000208A744AEC8>>} must be of type str or bytes, not <class 'method'>

Un saludo.

@pablo-moreno
Copy link
Owner

Hola Pablo,

me he mirado los cambios que propones en el pull y si los aplico a models.py, entonces me da el siguiente error:

requests.exceptions.InvalidHeader: Value for header {api_key: <bound method AemetHttpClient.get_api_key of <aemet.models.Aemet object at 0x00000208A744AEC8>>} must be of type str or bytes, not <class 'method'>

Un saludo.

Correcto, ya debería estar corregido.

@bdeerausquin
Copy link
Author

Perfecto, muchas gracias!

@bdeerausquin
Copy link
Author

Hola Pablo,

he encontrado otro bug en la función get_valores_climatologicos_mensuales / get_request_data. Sólo se devuelven los valores del primer mes para el año seleccionado. Por ejemplo:

1387E: A CORUÑA AEROPUERTO
[
{
"estacion": {
"latitud": "431825N",
"provincia": "A CORU\u00d1A",
"altitud": "98",
"indicativo": "1387E",
"nombre": "A CORU\u00d1A AEROPUERTO",
"indsinop": "08002",
"longitud": "082219W"
},
"valores_climatologicos": {
"fecha": "2017-1",
"indicativo": "1387E",
"p_max": "13.7(27)",
"n_cub": "9.0",
"glo": "15233.0",
"hr": "79.0",
"n_gra": "0.0",
"n_fog": "11.0",
"q_max": "1023.3(15)",
"nw_55": "2.0",
"q_mar": "1023.9",
"q_med": "1011.2",
"tm_min": "4.2",
"ta_max": "17.3(05)",
"ts_min": "12.5",
"nt_30": "0.0",
"nv_0050": "0.0",
"n_des": "9.0",
"w_racha": "20/18.9(30)",
"np_100": "1.0",
"n_nub": "13.0",
"nw_91": "0.0",
"np_001": "17.0",
"ta_min": "-3.8(20)",
"w_rec": "211.0",
"e": "93.0",
"np_300": "0.0",
"nv_1000": "5.0",
"p_mes": "41.7",
"n_llu": "17.0",
"n_tor": "0.0",
"w_med": "8.0",
"nt_00": "10.0",
"ti_max": "7.2",
"n_nie": "0.0",
"tm_mes": "8.6",
"tm_max": "13.0",
"nv_0100": "0.0",
"q_min": "989.0(27)",
"np_010": "7.0"
},
"anyo": 2017
},

Saludos

@bdeerausquin bdeerausquin reopened this Dec 29, 2019
@bdeerausquin
Copy link
Author

Se me ocurre que una solución podría ser cambiar el try dentro de la función get_request_data a lo siguiente:

     try:
        return r.json()[:]

en vez de:

     try:
        return r.json()[0]

@pablo-moreno
Copy link
Owner

Hola @bdeerausquin , para obtener todos los resultados había que pasarle el parámetro todos=True a la función. Ya lo he cambiado en la función get_valores_climatologicos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants