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

Showing BVG Departures In Your Office

Cd7648c536b4dbe940246b74044fbc52?s=47 Markus H
October 16, 2013

Showing BVG Departures In Your Office

Cd7648c536b4dbe940246b74044fbc52?s=128

Markus H

October 16, 2013
Tweet

Transcript

  1. Showing BVG Departures In Your Office markusholtermann.eu // @m_holtermann

  2. 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
  3. How It Looks Markus Holtermann // PyCon.DE 2013 // CC-BY-SA

    2
  4. How It Looks Markus Holtermann // PyCon.DE 2013 // CC-BY-SA

    2
  5. 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
  6. 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
  7. 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
  8. 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])]
  9. Grab The Code github.com/Markush2010/bvg-grabber/ Markus Holtermann // PyCon.DE 2013 //

    CC-BY-SA 7
  10. Thank You markusholtermann.eu // @m_holtermann