mechanize 0.2 uses its own ControlNotFoundError exception

This commit is contained in:
Romain Bignon 2010-06-26 13:38:48 +02:00
commit d5b1105b9c
3 changed files with 16 additions and 6 deletions

View file

@ -16,7 +16,10 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import ClientForm
try:
from mechanize import ControlNotFoundError
except ImportError:
from ClientForm import ControlNotFoundError
from .base import CragrBasePage
@ -33,7 +36,7 @@ class LoginPage(CragrBasePage):
try:
self.browser['numero'] = login
self.browser['code'] = password
except ClientForm.ControlNotFoundError:
except ControlNotFoundError:
try:
self.browser['userLogin'] = login
self.browser['userPassword'] = password

View file

@ -15,8 +15,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
try:
from mechanize import ControlNotFoundError
except ImportError:
from ClientForm import ControlNotFoundError
import ClientForm
from mechanize import FormNotFoundError
from weboob.tools.browser import BasePage
@ -30,5 +33,5 @@ class PornPage(BasePage):
self.browser.select_form(nr=0)
self.browser.submit(name='user_choice')
return False
except (ClientForm.ControlNotFoundError,FormNotFoundError):
except (ControlNotFoundError,FormNotFoundError):
return True

View file

@ -19,7 +19,10 @@
import mechanize
import urllib
import urllib2
import ClientForm
try:
from mechanize import ControlNotFoundError
except ImportError:
from ClientForm import ControlNotFoundError
import re
import time
from logging import warning, debug
@ -174,6 +177,7 @@ class BaseBrowser(mechanize.Browser):
if self.password:
try:
self.home()
# Do not abort the build of browser when the website is down.
except BrowserUnavailable:
pass
@ -367,5 +371,5 @@ class BaseBrowser(mechanize.Browser):
else:
value = self.str(args[label])
self[field] = value
except ClientForm.ControlNotFoundError:
except ControlNotFoundError:
return