__website__ = 'https://github.com/kelvan/gotoVienna/'
__license__ = 'GNU General Public License v3 or later'
+from datetime import datetime
+
+t = datetime.now()
+
from PySide.QtCore import QAbstractListModel, QModelIndex, QObject, Slot, Signal
from PySide.QtGui import QApplication
from PySide.QtDeclarative import QDeclarativeView
# Assume test from source directory, use relative path
view.setSource(os.path.join(os.path.dirname(__file__), 'qml/main.qml'))
+ print datetime.now() - t
+
view.showFullScreen()
sys.exit(app.exec_())
return []
# open url for 90 min timeslot / get departure for next 90 min
- bs = BeautifulSoup(urlopen(url + "&departureSizeTimeSlot=90"))
- print url
- lines = bs.findAll('table')[-2].findAll('tr')
- if len(lines) == 1:
- station = lines[0].span.text.replace(' ', '')
- line = lines[0].findAll('span')[-1].text.replace(' ', '')
+ retry = 0
+ tries = 2
+ while retry < tries:
+ bs = BeautifulSoup(urlopen(url + "&departureSizeTimeSlot=90"))
+ try:
+ lines = bs.find('form', {'name': 'mainform'}).table.findAll('tr')[1]
+ except AttributeError:
+ print 'FetchError'
+ msg = bs.findAll('span', {'class': 'rot fett'})
+ if len(msg) > 0 and str(msg[0].text).find(u'technischen St') > 0:
+ print 'Temporary problem'
+ print '\n'.join(map(lambda x: x.text.replace(' ', ''), msg))
+ # FIXME Change to error message after fixing qml gui
+ return []
+ # FIXME more testing
+ retry += 1
+ if retry == tries:
+ return []
+ if len(lines.findAll('td', {'class': 'info'})) > 0:
+ station = lines.span.text.replace(' ', '')
+ line = lines.findAll('span')[-1].text.replace(' ', '')
else:
- station = lines[1].td.span.text.replace(' ', '')
- line = '??'
+ station = lines.td.span.text.replace(' ', '')
+ line = lines.find('td', {'align': 'right'}).span.text.replace(' ', '')
result_lines = bs.findAll('table')[-1].findAll('tr')