The new woob repository is here: https://gitlab.com/woob/woob. This gitlab will be removed soon.

Commit 0ed6abb9 authored by thibault douge's avatar thibault douge Committed by Vincent A

[orange] return NotAvailable if the document is unavailable

parent 231a58eb
......@@ -25,6 +25,7 @@
from requests.exceptions import ConnectTimeout
from woob.browser import LoginBrowser, URL, need_login, StatesMixin
from woob.capabilities import NotAvailable
from woob.exceptions import (
BrowserIncorrectPassword, BrowserUnavailable, ActionNeeded, BrowserPasswordExpired,
ScrapingBlocked,
......@@ -318,8 +319,13 @@ def get_profile(self):
def download_document(self, document):
# sometimes the site sends us a server error when downloading the document.
# it is necessary to try again.
if document._is_v2:
# get 404 without this header
return self.open(document.url, headers={'x-orange-caller-id': 'ECQ'}).content
return self.open(document.url).content
try:
if document._is_v2:
# get 404 without this header
return self.open(document.url, headers={'x-orange-caller-id': 'ECQ'}).content
return self.open(document.url).content
except ClientError as e:
if e.response.status_code == 422:
# if the code is 422 the download of the document is currently unavailable
return NotAvailable
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment