Add exception if the user provide a bad url

bzr revid: ced-86d62f683f3aad3e1654c0e89b4eccdc09b9cfbe
This commit is contained in:
ced 2007-09-20 08:49:02 +00:00
parent 8850fa66f4
commit 6f7bdabe0a
1 changed files with 9 additions and 1 deletions

View File

@ -405,7 +405,15 @@ class module(osv.osv):
self._update_category(cr, uid, id, terp.get('category', 'Uncategorized'))
for repository in robj.browse(cr, uid, robj.search(cr, uid, [])):
index_page = urllib.urlopen(repository.url).read()
try:
index_page = urllib.urlopen(repository.url).read()
except IOError, e:
if e.errno == 21:
raise orm.except_orm('Error',
'This url \'%s\' must provide an html file '
'with links to zip modules' % (repository.url))
else:
raise
modules = re.findall(repository.filter, index_page, re.I+re.M)
mod_sort = {}
for m in modules: