diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-11-13 22:01:39 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-11-13 22:01:39 +0100 |
commit | 40d7d3b373a392b68b43524a4049216b1223c81c (patch) | |
tree | c94245ae5f85c82018463628918ebfa3ce19fbb8 /chimere/route.py | |
parent | 1def4a4322e699cedd602143586eefa42edfabf8 (diff) | |
download | Chimère-40d7d3b373a392b68b43524a4049216b1223c81c.tar.bz2 Chimère-40d7d3b373a392b68b43524a4049216b1223c81c.zip |
Fail properly when the routing engine don't find a route - JS: manage routing messages
Diffstat (limited to 'chimere/route.py')
-rw-r--r-- | chimere/route.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/chimere/route.py b/chimere/route.py index 040a7be..eaa762a 100644 --- a/chimere/route.py +++ b/chimere/route.py @@ -26,6 +26,7 @@ import os, re, shutil, tempfile from BeautifulSoup import BeautifulSoup from subprocess import Popen, PIPE from django.contrib.gis.gdal import DataSource +from django.contrib.gis.gdal.error import OGRException from django.conf import settings @@ -71,7 +72,10 @@ class RoutinoRouter(Router): tmp_dir = tempfile.mkdtemp(prefix='chimere_') + os.sep p = Popen(args, stdout=PIPE, cwd=tmp_dir) p.communicate() - ds = DataSource(tmp_dir + 'shortest-track.gpx') + try: + ds = DataSource(tmp_dir + 'shortest-track.gpx') + except OGRException: + return [], None, None if not ds: return [], None, None layer = ds[0] |