display an error message when user IP address is localized outside of France (closes #1327)

This commit is contained in:
Romain Bignon 2014-01-17 00:15:33 +01:00
commit 17c2a74707
2 changed files with 8 additions and 2 deletions

View file

@ -21,7 +21,7 @@
from weboob.tools.browser import BaseBrowser
from .pages import CitiesPage, SearchPage, SearchErrorPage, \
SearchInProgressPage, ResultsPage
SearchInProgressPage, ResultsPage, ForeignPage
__all__ = ['VoyagesSNCFBrowser']
@ -38,6 +38,7 @@ class VoyagesSNCFBrowser(BaseBrowser):
'http://www.voyages-sncf.com/billet-train\?.+': SearchErrorPage,
'http://www.voyages-sncf.com/billet-train/recherche-en-cours.*': SearchInProgressPage,
'http://www.voyages-sncf.com/billet-train/resultat.*': ResultsPage,
'http://(?P<country>\w{2})\.voyages-sncf.com/\w{2}/.*': ForeignPage,
}
def get_stations(self):

View file

@ -28,9 +28,14 @@ from weboob.tools.mech import ClientForm
from weboob.capabilities.base import UserError, Currency
__all__ = ['CitiesPage', 'SearchPage']
__all__ = ['CitiesPage', 'SearchPage', 'SearchErrorPage', 'SearchInProgressPage',
'ResultsPage', 'ForeignPage']
class ForeignPage(BasePage):
def on_loaded(self):
raise UserError('Your IP address is localized in a country not supported by this module (%s). Currently only the French website is supported.' % self.group_dict['country'])
class CitiesPage(BasePage):
def get_stations(self):
result = json.loads(self.document[self.document.find('{'):-2])