示例#1
0
def routes_list():
    """Returns a list of all available routes in the sf-muni agency."""
    params = utils.qs_params(command='routeList',data=request.args)
    resp=proxy_pass(params=params)
    jdata=xmltodict.parse(resp.content, dict_constructor=dict)
    stats.put_stats(response=resp, request=request)
    return jsonify(jdata)
示例#2
0
def predictions_stopId(stopId):
    """Show prediction by route with stopId only - least specific"""
    params = utils.qs_params(   command='predictions',
                                data=request.args,
                                stopId=stopId  )
    resp=proxy_pass(params=params)
    jdata=xmltodict.parse(resp.content, dict_constructor=dict)
    stats.put_stats(response=resp, request=request)
    return jsonify(jdata)
示例#3
0
def routes_config(routeTag):
    """Returns details about a given routeTag."""
    params = utils.qs_params(   command='routeConfig',
                                data=request.args,
                                r=routeTag  )
    resp=proxy_pass(params=params)
    jdata=xmltodict.parse(resp.content, dict_constructor=dict)
    stats.put_stats(response=resp, request=request)
    return jsonify(jdata)
示例#4
0
def vehicle_locations_route(routeTag):
    """Returns currently acitve vehicles for specified routeTag."""
    params = utils.qs_params(   command='vehicleLocations',
                                data=request.args,
                                r=routeTag              )
    resp=proxy_pass(params=params)
    jdata=xmltodict.parse(resp.content, dict_constructor=dict)
    stats.put_stats(response=resp, request=request)
    return jsonify(jdata)
示例#5
0
def routes_schedule(routeTag):
    """Return predictions for """
    params = utils.qs_params(   command='schedule',
                                data=request.args,
                                r=routeTag  )
    resp=proxy_pass(params=params)
    jdata=xmltodict.parse(resp.content, dict_constructor=dict)
    stats.put_stats(response=resp, request=request)
    return jsonify(jdata)
示例#6
0
def predictions_stopTag_and_route(routeTag,stopTag):
    """Show prediction by routes with routeTag and stopId - most specific"""
    params = utils.qs_params(   command='predictions',
                                data=request.args,
                                r=routeTag,
                                s=stopTag   )
    resp=proxy_pass(params=params)
    jdata=xmltodict.parse(resp.content, dict_constructor=dict)
    stats.put_stats(response=resp, request=request)
    return jsonify(jdata)
示例#7
0
def routes_off_hours(timewindow):
    """Returns all routes that are not running during the specified time frame. 
    Under construnction :( """
    params = utils.qs_params(   command='vehicleLocations',
                                data=request.args,
                                r=routeTag              )
    resp=proxy_pass(params=params)
    jdata=xmltodict.parse(resp.content, dict_constructor=dict)
    stats.put_stats(response=resp, request=request)
    return jsonify(jdata)
示例#8
0
def routes_messages():
    """Returns currently active messages and notifications for routes specified by parameter 'r'. 
    If you want to specify multiple routes, use the 'r[]' key in the query string. If no routes are
    specified, all active messages will be returned."""
    params = utils.qs_params(   command='messages',
                                data=request.args   )
    resp=proxy_pass(params=params)
    jdata=xmltodict.parse(resp.content, dict_constructor=dict)
    stats.put_stats(response=resp, request=request)
    return jsonify(jdata)
示例#9
0
def predictions_for_multi_stops():
    """Show time predictions for multiple stops specified by an array of 
    stop/route tags. Use the 'r' parameter suffixed with empty brackets as the key (r[]),
    and seperate route tags from stop tags with a vertical pipe delimited with commas (routeTag|stopTag)."""
    params = utils.qs_params(   command='predictionForMultiStops',
                                data=request.args   )
    resp=proxy_pass(params=params)
    jdata=xmltodict.parse(resp.content, dict_constructor=dict)
    stats.put_stats(response=resp, request=request)
    return jsonify(jdata)