use several loggers for parts of weboob
This commit is contained in:
parent
a1a58c7c32
commit
84b4003bf4
14 changed files with 74 additions and 67 deletions
|
|
@ -19,7 +19,6 @@ from __future__ import with_statement
|
|||
|
||||
import datetime
|
||||
from dateutil import tz
|
||||
from logging import warning, debug
|
||||
|
||||
from weboob.capabilities.base import NotLoaded
|
||||
from weboob.capabilities.chat import ICapChat
|
||||
|
|
@ -30,6 +29,7 @@ from weboob.capabilities.account import ICapAccount
|
|||
from weboob.tools.backend import BaseBackend
|
||||
from weboob.tools.browser import BrowserUnavailable
|
||||
from weboob.tools.value import Value, ValuesDict, ValueBool
|
||||
from weboob.tools.log import getLogger
|
||||
|
||||
from .captcha import CaptchaError
|
||||
from .antispam import AntiSpam
|
||||
|
|
@ -105,7 +105,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
|
|||
if not contact.get_id():
|
||||
continue
|
||||
if self.antispam and not self.antispam.check(contact):
|
||||
debug('Skipped a spam-thread from %s' % contact.get_name())
|
||||
self.logger.debug('Skipped a spam-thread from %s' % contact.get_name())
|
||||
self.report_spam(contact.get_id(), contact.get_suppr_id())
|
||||
continue
|
||||
thread = Thread(contact.get_id())
|
||||
|
|
@ -141,7 +141,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
|
|||
for mail in mails:
|
||||
flags = 0
|
||||
if self.antispam and not self.antispam.check(mail):
|
||||
debug('Skipped a spam-mail from %s' % mail.sender)
|
||||
self.logger.debug('Skipped a spam-mail from %s' % mail.sender)
|
||||
self.report_spam(thread.id, contact and contact.get_suppr_id())
|
||||
break
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
|
|||
with self.browser:
|
||||
profiles[mail.profile_link] = self.browser.get_profile(mail.profile_link)
|
||||
if self.antispam and not self.antispam.check(profiles[mail.profile_link]):
|
||||
debug('Skipped a spam-mail-profile from %s' % mail.sender)
|
||||
self.logger.debug('Skipped a spam-mail-profile from %s' % mail.sender)
|
||||
self.report_spam(thread.id, contact and contact.get_suppr_id())
|
||||
break
|
||||
mail.signature += u'\n%s' % profiles[mail.profile_link].get_profile_text()
|
||||
|
|
@ -203,7 +203,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
|
|||
if not contact.get_id():
|
||||
continue
|
||||
if self.antispam and not self.antispam.check(contact):
|
||||
debug('Skipped a spam-unread-thread from %s' % contact.get_name())
|
||||
self.logger.debug('Skipped a spam-unread-thread from %s' % contact.get_name())
|
||||
self.report_spam(contact.get_id(), contact.get_suppr_id())
|
||||
continue
|
||||
slut = self._get_slut(contact.get_id())
|
||||
|
|
@ -224,7 +224,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
|
|||
new_baskets -= 1
|
||||
profile = self.browser.get_profile(ids[new_baskets])
|
||||
if self.antispam and not self.antispam.check(profile):
|
||||
debug('Skipped a spam-basket from %s' % profile.get_name())
|
||||
self.logger.debug('Skipped a spam-basket from %s' % profile.get_name())
|
||||
self.report_spam(profile.get_id())
|
||||
continue
|
||||
|
||||
|
|
@ -242,7 +242,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
|
|||
flags=Message.IS_UNREAD)
|
||||
yield thread.root
|
||||
except BrowserUnavailable, e:
|
||||
debug('No messages, browser is unavailable: %s' % e)
|
||||
self.logger.debug('No messages, browser is unavailable: %s' % e)
|
||||
pass # don't care about waiting
|
||||
|
||||
def set_message_read(self, message):
|
||||
|
|
@ -345,7 +345,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
|
|||
elif contact['cat'] == 2:
|
||||
s = Contact.STATUS_AWAY
|
||||
else:
|
||||
warning('Unknown AuM contact status: %s' % contact['cat'])
|
||||
self.logger.warning('Unknown AuM contact status: %s' % contact['cat'])
|
||||
|
||||
if not status & s or ids and contact['id'] in ids:
|
||||
continue
|
||||
|
|
@ -405,7 +405,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
|
|||
country= account.properties['country'].value,
|
||||
godfather= account.properties['godfather'].value)
|
||||
except CaptchaError:
|
||||
debug('Unable to resolve captcha. Retrying...')
|
||||
getLogger('aum').debug('Unable to resolve captcha. Retrying...')
|
||||
browser = None
|
||||
|
||||
def get_account(self):
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
import datetime
|
||||
import time
|
||||
from logging import warning
|
||||
import random
|
||||
import simplejson
|
||||
import urllib
|
||||
|
|
@ -225,20 +224,20 @@ class AuMBrowser(BaseBrowser):
|
|||
@pageaccess
|
||||
def send_charm(self, id):
|
||||
result = self.openurl('http://www.adopteunmec.com/fajax_addBasket.php?id=%s' % id).read()
|
||||
warning('Charm: %s' % result)
|
||||
self.logger.warning('Charm: %s' % result)
|
||||
return result.find('noMoreFlashes') < 0
|
||||
|
||||
@pageaccess
|
||||
def add_basket(self, id):
|
||||
result = self.openurl('http://www.adopteunmec.com/fajax_addBasket.php?id=%s' % id).read()
|
||||
warning('Basket: %s' % result)
|
||||
self.logger.warning('Basket: %s' % result)
|
||||
# TODO check if it works (but it should)
|
||||
return True
|
||||
|
||||
@pageaccess
|
||||
def deblock(self, id):
|
||||
result = self.openurl('http://www.adopteunmec.com/fajax_postMessage.php?action=deblock&to=%s' % id).read()
|
||||
warning('Deblock: %s' % result)
|
||||
self.logger.warning('Deblock: %s' % result)
|
||||
return True
|
||||
|
||||
@pageaccess
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@
|
|||
|
||||
from __future__ import with_statement
|
||||
|
||||
from logging import info
|
||||
from random import randint
|
||||
|
||||
from weboob.tools.browser import BrowserUnavailable
|
||||
from weboob.capabilities.dating import Optimization
|
||||
from weboob.tools.log import getLogger
|
||||
|
||||
|
||||
__all__ = ['ProfilesWalker']
|
||||
|
|
@ -33,9 +33,10 @@ class ProfilesWalker(Optimization):
|
|||
self.sched = sched
|
||||
self.storage = storage
|
||||
self.browser = browser
|
||||
self.logger = getLogger('walker', browser.logger)
|
||||
|
||||
self.visited_profiles = set(storage.get('profiles_walker', 'viewed'))
|
||||
info(u'Loaded %d already visited profiles from storage.' % len(self.visited_profiles))
|
||||
self.logger.info(u'Loaded %d already visited profiles from storage.' % len(self.visited_profiles))
|
||||
self.profiles_queue = set()
|
||||
|
||||
def save(self):
|
||||
|
|
@ -57,7 +58,7 @@ class ProfilesWalker(Optimization):
|
|||
try:
|
||||
with self.browser:
|
||||
profiles_to_visit = self.browser.search_profiles().difference(self.visited_profiles)
|
||||
info(u'Enqueuing profiles to visit: %s' % profiles_to_visit)
|
||||
self.logger.info(u'Enqueuing profiles to visit: %s' % profiles_to_visit)
|
||||
self.profiles_queue = set(profiles_to_visit)
|
||||
self.save()
|
||||
except BrowserUnavailable:
|
||||
|
|
@ -73,7 +74,7 @@ class ProfilesWalker(Optimization):
|
|||
try:
|
||||
with self.browser:
|
||||
profile = self.browser.get_profile(id)
|
||||
info(u'Visited profile %s (%s)' % (profile.get_name(), id))
|
||||
self.logger.info(u'Visited profile %s (%s)' % (profile.get_name(), id))
|
||||
|
||||
# Get score from the aum_score module
|
||||
#d = self.nucentral_core.callService(context.Context.fromComponent(self), 'aum_score', 'score', profile)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
|
||||
import re
|
||||
from logging import error, warning
|
||||
from weboob.tools.browser import BasePage, BrowserUnavailable
|
||||
|
||||
class PageBase(BasePage):
|
||||
|
|
@ -61,7 +60,7 @@ class PageBase(BasePage):
|
|||
child = tag.childNodes[0].childNodes[0].childNodes[3]
|
||||
return int(child.childNodes[0].childNodes[1].data.replace(' ', '').strip())
|
||||
|
||||
error("Error: I can't find the score :(")
|
||||
self.logger.error("Error: I can't find the score :(")
|
||||
return '0'
|
||||
|
||||
def __get_indicator(self, elementName):
|
||||
|
|
@ -74,14 +73,14 @@ class PageBase(BasePage):
|
|||
|
||||
if not hasattr(child, 'data'):
|
||||
if child.tagName != u'blink':
|
||||
warning("Warning: %s counter isn't a blink and hasn't data" % elementName)
|
||||
self.logger.warning("Warning: %s counter isn't a blink and hasn't data" % elementName)
|
||||
child = child.childNodes[0]
|
||||
if not hasattr(child, 'data'):
|
||||
break
|
||||
|
||||
return int(child.data)
|
||||
|
||||
error("Error: I can't find the %s counter :(" % elementName)
|
||||
self.logger.error("Error: I can't find the %s counter :(" % elementName)
|
||||
return 0
|
||||
|
||||
MYNAME_REGEXP = re.compile("Bonjour (.*)")
|
||||
|
|
@ -95,7 +94,7 @@ class PageBase(BasePage):
|
|||
if m:
|
||||
return m.group(1)
|
||||
|
||||
warning('Warning: Unable to fetch name')
|
||||
self.logger.warning('Warning: Unable to fetch name')
|
||||
return '?'
|
||||
|
||||
def nb_new_mails(self):
|
||||
|
|
|
|||
|
|
@ -362,7 +362,7 @@ class ProfilePage(PageBase):
|
|||
try:
|
||||
fields[label1].put_value(d, value2)
|
||||
except KeyError:
|
||||
warning('Unable to find "%s" (%s)' % (label1, repr(label1)))
|
||||
self.logger.warning('Unable to find "%s" (%s)' % (label1, repr(label1)))
|
||||
elif label1 and label2:
|
||||
# two titles, so there will have a list of value in
|
||||
# next lines on each columns
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
from __future__ import with_statement
|
||||
|
||||
from logging import warning
|
||||
|
||||
from weboob.capabilities.messages import ICapMessages, Message, Thread
|
||||
from weboob.tools.backend import BaseBackend
|
||||
from weboob.tools.value import Value, ValuesDict
|
||||
|
|
@ -52,7 +50,7 @@ class FourChanBackend(BaseBackend, ICapMessages):
|
|||
id = thread.id
|
||||
|
||||
if not '.' in id:
|
||||
warning('Malformated ID (%s)' % id)
|
||||
self.logger.warning('Malformated ID (%s)' % id)
|
||||
return
|
||||
|
||||
board, thread_id = self._splitid(id)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
from datetime import datetime
|
||||
|
||||
import re
|
||||
from logging import warning
|
||||
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
|
|
@ -53,7 +52,7 @@ class BoardPage(BasePage):
|
|||
if m:
|
||||
self.board = m.group(1)
|
||||
else:
|
||||
warning('Unable to find board')
|
||||
self.logger.warning('Unable to find board')
|
||||
self.board = 'unknown'
|
||||
|
||||
forms = self.document.getroot().cssselect('form')
|
||||
|
|
@ -65,7 +64,7 @@ class BoardPage(BasePage):
|
|||
break
|
||||
|
||||
if form is None:
|
||||
warning('No delform :(')
|
||||
self.logger.warning('No delform :(')
|
||||
|
||||
article = None
|
||||
for div in form.getchildren():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue