crtm_poll.crtm_api package¶
Submodules¶
crtm_poll.crtm_api.stop_times module¶
-
crtm_poll.crtm_api.stop_times.
fetch
(cod_stop, session, fetch_conf)[source]¶ Fetch the stops waiting time for a given stop reusing a session.
Passes some additional data to the fetch_log function. The CSV column names are: ‘actual_date,cod_stop,resp_time,resp_status,resp_length,timeout, connection_error,max_connections,timeout_time’
Keyword arguments: cod_stop – the stop code in CRTM’s format (e.g. 8_17491) session – the aiohttp ClientSession fetch_conf – dictionary with configuration parameters for fetching the content
Returns: text – response text
-
crtm_poll.crtm_api.stop_times.
fetch_log
(fetch_log, *args)[source]¶ Write the passed arguments as CSV to fetch_log if set.
-
crtm_poll.crtm_api.stop_times.
get_stop_times
(cod_stop, fetch_conf)[source]¶ Get the stop times for all the bus lines in a given stop.
Keyword arguments: cod_stop – the stop code in CRTM’s format (e.g. 8_17491) fetch_conf – dictionary with configuration parameters for fetching the content
Returns: json – API answer in JSON format time – request time in seconds
-
crtm_poll.crtm_api.stop_times.
get_stop_times_batch
(cod_stops, fetch_conf)[source]¶ Get the stop times for all the bus lines for the given stops.
Keyword arguments: cod_stops – an array of stop codes in CRTM’s format (e.g. 8_17491) fetch_conf – dictionary with configuration parameters for fetching the content
Returns: json_array – array of API answers in JSON format total_time – total spent time in seconds
-
crtm_poll.crtm_api.stop_times.
get_stop_times_batch_parsed
(cod_stops, fetch_conf)[source]¶ Get the stop times for all the bus lines for the given stops parsing the JSON answer to CSV.
The CSV column names are: ‘actual_date,cod_stop,cod_line,cod_issue,eta,destination_stop’
Keyword arguments: cod_stops – an array of stop codes in CRTM’s format (e.g. 8_17491)
Returns: csv_array – array of parsed API answers in CSV format total_time – total spent time in seconds
-
crtm_poll.crtm_api.stop_times.
run
(cod_stops, fetch_conf)[source]¶ Async function that generates a aiohttp ClientSession and fetches the given stops.
Keyword arguments: cod_stops – an array of stop codes in CRTM’s format (e.g. 8_17491) fetch_conf – dictionary with configuration parameters for fetching the content
Returns: responses – Array with the responses