Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(1)  |  Call(1)  |  Derive(0)  |  Import(0)
busLastSeen

Given a stopID and a route returns the last seen location of the bus

:param:     stopID  int
:param:     route   int
:return:    str

        def busLastSeen(stopID, route):
    """
    busLastSeen

    Given a stopID and a route returns the last seen location of the bus

    :param:     stopID  int
    :param:     route   int
    :return:    str
    """
    url = "%sarrivals?appID=%s&locIDs=%s" % (BASE_URI, APP_ID, stopID)

    try:
        f = urlopen(url)
    except HTTPError:
        return None

    response = f.read()

    dom = parseString(response)
    arrivalElems = dom.getElementsByTagName("arrival")

    for arrival in arrivalElems:
        try:
            arrivalRoute = arrival.getAttribute("route")
            if arrivalRoute == str(route):
                pos = arrival.getElementsByTagName("blockPosition")[0]
                seenAt = pos.getAttribute("at")[:-3]
                mins = (int(time()) - long(seenAt)) / 60
                secs = (int(time()) - long(seenAt)) % 60
                location = getAddress(
                    {
                        'lat' : pos.getAttribute("lat"),
                        'lng' : pos.getAttribute("lng")
                    }
                )
                return "Your bus was last seen on %s %s minutes and %s seconds ago" % (location, mins, secs)
        except IndexError:
            pass

    return "I'm sorry I don't have that information"
        


src/t/r/Tribot-HEAD/irc.py   Tribot(Download)
 
        if len(args) > 1:
            result = api.busLastSeen(args[0], args[1])
        else:
            result = "Sorry, no information found."