Handle exceptions raised when fetching details

Weboob does handle the raised exceptions when fetching housing posts
through the `WebNip` class. However, when fetching details, we directly
call the Weboob backend method and no exceptions handling is done.

When importing data with a `crontask`, websites may be offline for some
time, especially at night, then leading to a failure in import process.

Let's just handle such exceptions so that an offline website does not
break the whole import process. Details from the temporary offline
websites which could not be fetched will be fetched at next run.

This closes #60.
This commit is contained in:
Lucas Verney 2017-06-20 13:27:08 +02:00
parent 8e9cb2c1c7
commit 054c5679bb

View File

@ -213,7 +213,7 @@ class WeboobProxy(object):
housing.id = full_flat_id housing.id = full_flat_id
return json.dumps(housing, cls=WeboobEncoder) return json.dumps(housing, cls=WeboobEncoder)
except CallErrors as exc: except Exception as exc:
# If an error occured, just log it # If an error occured, just log it
LOGGER.error( LOGGER.error(
"An error occured while fetching housing %s: %s", "An error occured while fetching housing %s: %s",
@ -221,9 +221,6 @@ class WeboobProxy(object):
str(exc) str(exc)
) )
return "{}" return "{}"
except ValueError as exc:
LOGGER.error("ValueError for flat_id=%s: %s", flat_id, str(exc))
return "{}"
def fetch_flats(config): def fetch_flats(config):