handle 'oops' error message
This commit is contained in:
parent
7b8798efd9
commit
c1204057dc
2 changed files with 34 additions and 24 deletions
|
|
@ -1,16 +1,16 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright(C) 2008-2010 Romain Bignon, Christophe Benz
|
# Copyright(C) 2008-2010 Romain Bignon, Christophe Benz
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation, version 3 of the License.
|
# the Free Software Foundation, version 3 of the License.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# 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.
|
||||||
|
|
@ -26,7 +26,7 @@ except ImportError:
|
||||||
import simplejson
|
import simplejson
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
from weboob.tools.browser import BaseBrowser
|
from weboob.tools.browser import BaseBrowser, BrowserUnavailable
|
||||||
from weboob.tools.parsers.html5libparser import Html5libParser
|
from weboob.tools.parsers.html5libparser import Html5libParser
|
||||||
|
|
||||||
from weboob.backends.aum.exceptions import AdopteWait
|
from weboob.backends.aum.exceptions import AdopteWait
|
||||||
|
|
@ -275,7 +275,11 @@ class AdopteUnMec(BaseBrowser):
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def _get_chat_infos(self):
|
def _get_chat_infos(self):
|
||||||
json = simplejson.load(self.openurl('http://www.adopteunmec.com/1.1_cht_get.php?anticache=%f' % random.random()))
|
try:
|
||||||
|
json = simplejson.load(self.openurl('http://www.adopteunmec.com/1.1_cht_get.php?anticache=%f' % random.random()))
|
||||||
|
except simplejson.JSONDecodeError:
|
||||||
|
raise BrowserUnavailable()
|
||||||
|
|
||||||
if json['error']:
|
if json['error']:
|
||||||
raise ChatException(u'Error while getting chat infos. json:\n%s' % json)
|
raise ChatException(u'Error while getting chat infos. json:\n%s' % json)
|
||||||
return json
|
return json
|
||||||
|
|
@ -317,7 +321,7 @@ class AdopteUnMec(BaseBrowser):
|
||||||
request = self.request_class(url, urllib.urlencode(data), headers)
|
request = self.request_class(url, urllib.urlencode(data), headers)
|
||||||
response = self.openurl(request).read()
|
response = self.openurl(request).read()
|
||||||
try:
|
try:
|
||||||
datetime.datetime.strptime(response, '%Y-%m-%d %H:%M:%S')
|
datetime.datetime.strptime(response, '%Y-%m-%d %H:%M:%S')
|
||||||
return True
|
return True
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,34 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
"""
|
# Copyright(C) 2008-2010 Romain Bignon
|
||||||
Copyright(C) 2008-2010 Romain Bignon
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
This program is free software; you can redistribute it and/or modify
|
# it under the terms of the GNU General Public License as published by
|
||||||
it under the terms of the GNU General Public License as published by
|
# the Free Software Foundation, version 3 of the License.
|
||||||
the Free Software Foundation, version 3 of the License.
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
This program is distributed in the hope that it will be useful,
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# GNU General Public License for more details.
|
||||||
GNU General Public License for more details.
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
You should have received a copy of the GNU General Public License
|
# 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.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from logging import error, warning
|
from logging import error, warning
|
||||||
from weboob.tools.browser import BasePage
|
from weboob.tools.browser import BasePage, BrowserUnavailable
|
||||||
|
|
||||||
class PageBase(BasePage):
|
class PageBase(BasePage):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
BasePage.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
|
# Check the 'oops' error message when adopteunmec guys are gay.
|
||||||
|
b = self.document.getElementsByTagName('body')[0]
|
||||||
|
for div in b.getElementsByTagName('div'):
|
||||||
|
if div.getAttribute('id') == 'oops':
|
||||||
|
raise BrowserUnavailable()
|
||||||
|
|
||||||
def open_contact_list_page(self):
|
def open_contact_list_page(self):
|
||||||
self.browser.follow_link(url_regex=r"/mails.php$")
|
self.browser.follow_link(url_regex=r"/mails.php$")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue