Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Showing BVG Departures In Your Office

Markus H
October 16, 2013

Showing BVG Departures In Your Office

Markus H

October 16, 2013
Tweet

More Decks by Markus H

Other Decks in Technology

Transcript

  1. Intention » Distance to bus stop short but still lots

    of obstacles » Got a flat screen with wall mount » Useful to just look at a screen and see the next departures Markus Holtermann // PyCon.DE 2013 // CC-BY-SA 1
  2. Technical Details class QueryApi(object): # Performs the requests to the

    data source def call(self): """Needs to return a Response""" class Response(object): # Returned by a QueryApi, contains list of Departures @property def departures(self): return self._departures @total_ordering class Departure(object): # Start and end station, next departure time def __init__(self, start, end, when, line, ...): # Some magic happens here Markus Holtermann // PyCon.DE 2013 // CC-BY-SA 3
  3. Technical Details class ActualDepartureQueryApi(QueryApi): """Checks for bus departures as they

    are provided on-the-fly""" class ScheduledDepartureQueryApi(QueryApi): """Checks for :class:`Vehicle` departures""" class Vehicle(): S = 64 U = 32 TRAM = 16 BUS = 8 FERRY = 4 RB = 2 IC = 1 Markus Holtermann // PyCon.DE 2013 // CC-BY-SA 4
  4. How To Use It In [1]: from bvggrabber.api.actualdeparture import ActualDepartureQueryApi

    In [2]: resp = ActualDepartureQueryApi("Ernst-Reuter-Platz").call() In [3]: resp.departures Out[3]: [('Ernst-Reuter-Platz', [Start: Ernst-Reuter-Platz, End: S+U Zoologischer Garten, when: 10:13, now: 10:09, line: Bus M45, Start: Ernst-Reuter-Platz, End: S+U Zoologischer Garten, when: 10:16, now: 10:09, line: Bus 245, Start: Ernst-Reuter-Platz, End: S+U Zoologischer Garten, when: 10:20, now: 10:09, line: Bus M45, Start: Ernst-Reuter-Platz, End: S Nordbahnhof via Hbf, when: 10:10, now: 10:09, line: Bus 245, Start: Ernst-Reuter-Platz, End: S Nordbahnhof via Hbf, when: 10:12, now: 10:09, line: Bus 245, Start: Ernst-Reuter-Platz, End: Flughafen Tegel, when: 10:13, now: 10:09, line: Bus X9])] Markus Holtermann // PyCon.DE 2013 // CC-BY-SA 5
  5. How To Use It Markus Holtermann // PyCon.DE 2013 //

    CC-BY-SA 6 In [4]: from bvggrabber.api.scheduleddeparture import ScheduledDepartureQueryApi In [5]: resp = ScheduledDepartureQueryApi("Ernst-Reuter-Platz").call() In [6]: resp.departures Out[6]: [('Ernst-Reuter-Platz', [Start: Ernst-Reuter-Platz, End: Hertzallee (Berlin), when: 10:11, now: 10:11, line: Bus M45, Start: Ernst-Reuter-Platz, End: S+U Pankow (Berlin), when: 10:11, now: 10:11, line: U2, Start: Ernst-Reuter-Platz, End: S Nordbahnhof/Gartenstr. (Berlin), when: 10:12, now: 10: 11, line: Bus 245, Start: Ernst-Reuter-Platz, End: U Ruhleben (Berlin), when: 10:13, now: 10:11, line: U2, Start: Ernst-Reuter-Platz, End: Flughafen Tegel (Airport) (Berlin), when: 10:13, now: 10: 11, line: Bus X9])]