mechanize 0.2 uses its own ControlNotFoundError exception
This commit is contained in:
parent
e5a8c2e277
commit
d5b1105b9c
3 changed files with 16 additions and 6 deletions
|
|
@ -16,7 +16,10 @@
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# 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
|
from .base import CragrBasePage
|
||||||
|
|
||||||
|
|
@ -33,7 +36,7 @@ class LoginPage(CragrBasePage):
|
||||||
try:
|
try:
|
||||||
self.browser['numero'] = login
|
self.browser['numero'] = login
|
||||||
self.browser['code'] = password
|
self.browser['code'] = password
|
||||||
except ClientForm.ControlNotFoundError:
|
except ControlNotFoundError:
|
||||||
try:
|
try:
|
||||||
self.browser['userLogin'] = login
|
self.browser['userLogin'] = login
|
||||||
self.browser['userPassword'] = password
|
self.browser['userPassword'] = password
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,11 @@
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# 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 mechanize import FormNotFoundError
|
||||||
from weboob.tools.browser import BasePage
|
from weboob.tools.browser import BasePage
|
||||||
|
|
||||||
|
|
@ -30,5 +33,5 @@ class PornPage(BasePage):
|
||||||
self.browser.select_form(nr=0)
|
self.browser.select_form(nr=0)
|
||||||
self.browser.submit(name='user_choice')
|
self.browser.submit(name='user_choice')
|
||||||
return False
|
return False
|
||||||
except (ClientForm.ControlNotFoundError,FormNotFoundError):
|
except (ControlNotFoundError,FormNotFoundError):
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,10 @@
|
||||||
import mechanize
|
import mechanize
|
||||||
import urllib
|
import urllib
|
||||||
import urllib2
|
import urllib2
|
||||||
import ClientForm
|
try:
|
||||||
|
from mechanize import ControlNotFoundError
|
||||||
|
except ImportError:
|
||||||
|
from ClientForm import ControlNotFoundError
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
from logging import warning, debug
|
from logging import warning, debug
|
||||||
|
|
@ -174,6 +177,7 @@ class BaseBrowser(mechanize.Browser):
|
||||||
if self.password:
|
if self.password:
|
||||||
try:
|
try:
|
||||||
self.home()
|
self.home()
|
||||||
|
# Do not abort the build of browser when the website is down.
|
||||||
except BrowserUnavailable:
|
except BrowserUnavailable:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -367,5 +371,5 @@ class BaseBrowser(mechanize.Browser):
|
||||||
else:
|
else:
|
||||||
value = self.str(args[label])
|
value = self.str(args[label])
|
||||||
self[field] = value
|
self[field] = value
|
||||||
except ClientForm.ControlNotFoundError:
|
except ControlNotFoundError:
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue