repositories: Fix HTTP error handling for browser2
This commit is contained in:
parent
d087bc3c92
commit
fb011f2be6
1 changed files with 5 additions and 6 deletions
|
|
@ -38,13 +38,12 @@ from .modules import Module
|
||||||
from weboob.tools.log import getLogger
|
from weboob.tools.log import getLogger
|
||||||
from weboob.tools.misc import to_unicode
|
from weboob.tools.misc import to_unicode
|
||||||
from weboob.tools.browser2.browser import BaseBrowser, Weboob as WeboobProfile
|
from weboob.tools.browser2.browser import BaseBrowser, Weboob as WeboobProfile
|
||||||
|
from requests.exceptions import HTTPError
|
||||||
try:
|
try:
|
||||||
from configparser import RawConfigParser, DEFAULTSECT
|
from configparser import RawConfigParser, DEFAULTSECT
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from ConfigParser import RawConfigParser, DEFAULTSECT
|
from ConfigParser import RawConfigParser, DEFAULTSECT
|
||||||
|
|
||||||
BrowserUnavailable = object()
|
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['IProgress', 'ModuleInstallError', 'ModuleInfo', 'RepositoryUnavailable',
|
__all__ = ['IProgress', 'ModuleInstallError', 'ModuleInfo', 'RepositoryUnavailable',
|
||||||
'Repository', 'Versions', 'Repositories', 'InvalidSignature', 'Keyring']
|
'Repository', 'Versions', 'Repositories', 'InvalidSignature', 'Keyring']
|
||||||
|
|
@ -176,7 +175,7 @@ class Repository(object):
|
||||||
# This is a remote repository, download file
|
# This is a remote repository, download file
|
||||||
try:
|
try:
|
||||||
fp = BytesIO(browser.open(posixpath.join(self.url, self.INDEX)).content)
|
fp = BytesIO(browser.open(posixpath.join(self.url, self.INDEX)).content)
|
||||||
except BrowserUnavailable as e:
|
except HTTPError as e:
|
||||||
raise RepositoryUnavailable(unicode(e))
|
raise RepositoryUnavailable(unicode(e))
|
||||||
|
|
||||||
self.parse_index(fp)
|
self.parse_index(fp)
|
||||||
|
|
@ -205,7 +204,7 @@ class Repository(object):
|
||||||
try:
|
try:
|
||||||
keyring_data = browser.open(posixpath.join(self.url, self.KEYRING)).content
|
keyring_data = browser.open(posixpath.join(self.url, self.KEYRING)).content
|
||||||
sig_data = browser.open(posixpath.join(self.url, self.KEYRING + '.sig')).content
|
sig_data = browser.open(posixpath.join(self.url, self.KEYRING + '.sig')).content
|
||||||
except BrowserUnavailable as e:
|
except HTTPError as e:
|
||||||
raise RepositoryUnavailable(unicode(e))
|
raise RepositoryUnavailable(unicode(e))
|
||||||
if keyring.exists():
|
if keyring.exists():
|
||||||
if not keyring.is_valid(keyring_data, sig_data):
|
if not keyring.is_valid(keyring_data, sig_data):
|
||||||
|
|
@ -529,7 +528,7 @@ class Repositories(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
icon = self.browser.open(icon_url)
|
icon = self.browser.open(icon_url)
|
||||||
except BrowserUnavailable:
|
except HTTPError:
|
||||||
pass # no icon, no problem
|
pass # no icon, no problem
|
||||||
else:
|
else:
|
||||||
with open(dest_path, 'wb') as fp:
|
with open(dest_path, 'wb') as fp:
|
||||||
|
|
@ -656,7 +655,7 @@ class Repositories(object):
|
||||||
progress.progress(0.2, 'Downloading module...')
|
progress.progress(0.2, 'Downloading module...')
|
||||||
try:
|
try:
|
||||||
tardata = self.browser.open(module.url).content
|
tardata = self.browser.open(module.url).content
|
||||||
except BrowserUnavailable as e:
|
except HTTPError as e:
|
||||||
raise ModuleInstallError('Unable to fetch module: %s' % e)
|
raise ModuleInstallError('Unable to fetch module: %s' % e)
|
||||||
|
|
||||||
# Check signature
|
# Check signature
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue