Beispiel #1
0
 def __init__(self, smarthome):
     """
     Initializes the plugin
     """
     self.logger = logging.getLogger(__name__)
     self._sh = smarthome
     self._mvg_live = MVGLive.MVGLive()
Beispiel #2
0
def getCurrentTransports():
    foo = MVGLive.MVGLive()
    liveData = foo.getlivedata("Ackermannstraße")
    times = []
    for transport in liveData:
        if transport['product'] == "Tram":
            goesToPetuelring = False
            if transport['destination'] == "Petuelring":
                goesToPetuelring = True
            times.append((transport['time'], goesToPetuelring))
    return times
Beispiel #3
0
def getTable(stations):
    alldepartures = {}
    for (station,lines) in stations.iteritems():
        departures = defaultdict(list)
        data = MVGLive.getlivedata(station,50)
        for departure in data:
            line = departure['linename'].decode('utf-8')
            if not line in lines:
                continue
            k = ( line, departure['product'], departure['destination'])
            l = departures.get(k, [])
            l.append((int(departure['time']), r''))
            departures[k] = l
        alldepartures[station] = departures

    if (u'28', u'Tram', u'Sendlinger Tor') in alldepartures['Pinakotheken']:
        shortdest[u'27', u'Tram', u'Sendlinger Tor'] = (ur'', u'Sendlinger Tor', u'')
        shortdest[u'28', u'Tram', u'Sendlinger Tor'] = (ur'', u'Sendlinger Tor', u'')

    # rename and collapse some destinations
    usedshorts = {}
    for departures in alldepartures.itervalues():
        for ((oldline,prod,olddest),(newline,newdest,short)) in shortdest.iteritems():
            i = departures.get((oldline,prod,olddest), [])
            if i:
                departures[newline,prod,newdest] += map(lambda (t,_):
                        (t,short), i)
                del departures[oldline,prod,olddest]
                if short:
                    usedshorts[short] = olddest

    tex = []
    tex.append(ur"""
    \begin{tabularx}{\linewidth}{@{}l@{\,}c@{\ }L@{\,}r@{}}
    \rlap{Linie} & \hphantom{555} & Ziel & \hphantom{55,\,55,\,55}\llap{Abfahrten}\\
    """)

    for station, departures in alldepartures.iteritems():
        tex.append(ur"\midrule")

        for (line,prod,dest),v in sorted(departures.iteritems(), 
                key=lambda ((s,_,dest),x) : (toInt(s),dest)):
            tex.append(ur"""\includegraphics[height=.8em]{%s.pdf} & """ % prod)
            if 0 < toInt(line) <= 8:
                tex.append(ur"\includegraphics[height=.8em]{%s.pdf} & " % line)
            else:
                tex.append("%s & " % line)
            tex.append(ur"%s & %s \\" % (
                    dest,
                    r",\,".join(map(lambda (t,sup) : 
                        r"\hphantom{55}\llap{%i}" % t + (sup and
                            r"\rlap{\textsuperscript{\tiny{%s}}}" % sup),
                        sorted(v)[:3]))
                    ))
Beispiel #4
0
 def __init__(self, station, destination, line,
              offset, ubahn, tram, bus, sbahn):
     """Initialize the sensor."""
     import MVGLive
     self._station = station
     self._destination = destination
     self._line = line
     self._offset = offset
     self._ubahn = ubahn
     self._tram = tram
     self._bus = bus
     self._sbahn = sbahn
     self.mvg = MVGLive.MVGLive()
     self.nextdeparture = {}
Beispiel #5
0
 def __init__(self, station, destinations, directions, lines, products,
              timeoffset):
     """Initialize the sensor."""
     import MVGLive
     self._station = station
     self._destinations = destinations
     self._directions = directions
     self._lines = lines
     self._products = products
     self._timeoffset = timeoffset
     self._include_ubahn = True if 'U-Bahn' in self._products else False
     self._include_tram = True if 'Tram' in self._products else False
     self._include_bus = True if 'Bus' in self._products else False
     self._include_sbahn = True if 'S-Bahn' in self._products else False
     self.mvg = MVGLive.MVGLive()
     self.departures = {}
 def __init__(self, station, destinations, directions, lines, products,
              timeoffset, number):
     """Initialize the sensor."""
     self._station = station
     self._destinations = destinations
     self._directions = directions
     self._lines = lines
     self._products = products
     self._timeoffset = timeoffset
     self._number = number
     self._include_ubahn = "U-Bahn" in self._products
     self._include_tram = "Tram" in self._products
     self._include_bus = "Bus" in self._products
     self._include_sbahn = "S-Bahn" in self._products
     self.mvg = MVGLive.MVGLive()
     self.departures = []
Beispiel #7
0
import io
import os
import json
import MVGLive

stations = []
stations.append('Sandstraße')
stations.append('Theresienstraße')
stations.append('Görresstraße')

BASEDIR = os.path.dirname(os.path.realpath(__file__))

alldepartures = []
departures = []
for station in stations:
  alldepartures.append(MVGLive.getlivedata(station))


collected = 0
currentdeparture = 0
while collected < 9:
  for departureset in alldepartures:
    for departure in departureset:
      if departure['time'] == currentdeparture:
        departures.append(departure)
        collected += 1
  currentdeparture += 1

for departure in departures:
  os.system('wget -nc -O ' + BASEDIR + '/' + departure['linesymbol'] + ' ' + departure['linesymbolurl'] + '; if [ $? -eq 0 ]; then convert ' + BASEDIR + '/' + departure['linesymbol'] + ' ' + BASEDIR + '/' + departure['linesymbol'] + '.png; fi')
  os.system('wget -nc -O ' + BASEDIR + '/' + departure['productsymbol'] + ' ' + departure['productsymbolurl'] + '; if [ $? -eq 0 ]; then convert ' + BASEDIR + '/' + departure['productsymbol'] + ' ' + BASEDIR + '/' + departure['productsymbol'] + '.png; fi')
Beispiel #8
0
import json
import MVGLive
import sys

stations = []
stations.append('Sandstraße')
stations.append('Theresienstraße')
stations.append('Görresstraße')

BASEDIR = os.path.dirname(os.path.realpath(__file__))

alldepartures = []
departures = []
maxdepartures = 0
for station in stations:
  departuredata = MVGLive.getlivedata(station)
  if len(departuredata) > 0:
    alldepartures.append(departuredata)
    maxdepartures += len(departuredata)

if maxdepartures > 9:
  maxdepartures = 9

collected = 0
currentdeparture = 0
while collected < maxdepartures:
  for departureset in alldepartures:
    for departure in departureset:
      if departure['time'] == currentdeparture:
        departures.append(departure)
        collected += 1
Beispiel #9
0
 def __init__(self, sh, *args, **kwargs):
     """
     Initializes the plugin
     """
     self.logger = logging.getLogger(__name__)
     self._mvg_live = MVGLive.MVGLive()