本文整理汇总了Python中weboob.core.Weboob.do方法的典型用法代码示例。如果您正苦于以下问题:Python Weboob.do方法的具体用法?Python Weboob.do怎么用?Python Weboob.do使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weboob.core.Weboob
的用法示例。
在下文中一共展示了Weboob.do方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MyThread
# 需要导入模块: from weboob.core import Weboob [as 别名]
# 或者: from weboob.core.Weboob import do [as 别名]
class MyThread(Thread):
daemon = True
def __init__(self, bot):
Thread.__init__(self)
self.weboob = Weboob(storage=StandardStorage(STORAGE_FILE))
self.weboob.load_backends()
self.bot = bot
self.bot.set_weboob(self.weboob)
def run(self):
for ev in self.bot.joined.itervalues():
ev.wait()
self.weboob.repeat(300, self.check_board)
self.weboob.repeat(600, self.check_dlfp)
self.weboob.loop()
def find_keywords(self, text):
for word in [
'weboob', 'videoob', 'havesex', 'havedate', 'monboob', 'boobmsg',
'flatboob', 'boobill', 'pastoob', 'radioob', 'translaboob', 'traveloob', 'handjoob',
'boobathon', 'boobank', 'boobtracker', 'comparoob', 'wetboobs',
'webcontentedit', 'weboorrents', u'sàt', u'salut à toi', 'assnet',
'budget insight', 'budget-insight', 'budgetinsight', 'budgea']:
if word in text.lower():
return word
return None
def check_dlfp(self):
for backend, msg in self.weboob.do('iter_unread_messages', backends=['dlfp']):
word = self.find_keywords(msg.content)
if word is not None:
url = msg.signature[msg.signature.find('https://linuxfr'):]
self.bot.send_message('[DLFP] %s talks about %s: %s' % (
msg.sender, word, url))
backend.set_message_read(msg)
def check_board(self):
def iter_messages(backend):
with backend.browser:
return backend.browser.iter_new_board_messages()
for backend, msg in self.weboob.do(iter_messages, backends=['dlfp']):
word = self.find_keywords(msg.message)
if word is not None and msg.login != 'moules':
message = msg.message.replace(word, '\002%s\002' % word)
self.bot.send_message('[DLFP] <%s> %s' % (msg.login, message))
def stop(self):
self.weboob.want_stop()
self.weboob.deinit()
示例2: BoobankChecker
# 需要导入模块: from weboob.core import Weboob [as 别名]
# 或者: from weboob.core.Weboob import do [as 别名]
class BoobankChecker():
def __init__(self):
self.ind = appindicator.Indicator.new(APPINDICATOR_ID,
os.path.abspath(resource_filename('boobank_indicator.data',
'indicator-boobank.png')),
appindicator.IndicatorCategory.APPLICATION_STATUS)
self.menu = Gtk.Menu()
self.ind.set_menu(self.menu)
logging.basicConfig()
if 'weboob_path' in os.environ:
self.weboob = Weboob(os.environ['weboob_path'])
else:
self.weboob = Weboob()
self.weboob.load_backends(CapBank)
def clean_menu(self, menu):
for i in menu.get_children():
submenu = i.get_submenu()
if submenu:
self.clean_menu(i)
menu.remove(i)
def check_boobank(self):
self.ind.set_status(appindicator.IndicatorStatus.ACTIVE)
self.clean_menu(self.menu)
total = 0
currency = ''
threads = []
try:
for account in self.weboob.do('iter_accounts'):
balance = account.balance
if account.coming:
balance += account.coming
if account.type != Account.TYPE_LOAN:
total += balance
image = "green_light.png" if balance > 0 else "red_light.png"
else:
image = "personal-loan.png"
currency = account.currency_text
label = "%s: %s%s" % (account.label, balance, account.currency_text)
account_item = create_image_menu_item(label, image)
thread = BoobankTransactionsChecker(self.weboob, account_item, account)
thread.start()
threads.append(thread)
except CallErrors as errors:
self.bcall_errors_handler(errors)
for thread in threads:
thread.join()
for thread in threads:
self.menu.append(thread.menu)
thread.menu.show()
if len(self.menu.get_children()) == 0:
Notify.Notification.new('<b>Boobank</b>',
'No Bank account found\n Please configure one by running boobank',
'notification-message-im').show()
sep = Gtk.SeparatorMenuItem()
self.menu.append(sep)
sep.show()
total_item = Gtk.MenuItem("%s: %s%s" % ("Total", total, currency))
self.menu.append(total_item)
total_item.show()
sep = Gtk.SeparatorMenuItem()
self.menu.append(sep)
sep.show()
btnQuit = Gtk.ImageMenuItem()
image = Gtk.Image()
image.set_from_stock(Gtk.STOCK_QUIT, Gtk.IconSize.BUTTON)
btnQuit.set_image(image)
btnQuit.set_label('Quit')
btnQuit.set_always_show_image(True)
btnQuit.connect("activate", self.quit)
self.menu.append(btnQuit)
btnQuit.show()
def quit(self, widget):
Gtk.main_quit()
def bcall_errors_handler(self, errors):
"""
Handler for the CallErrors exception.
"""
self.ind.set_status(appindicator.IndicatorStatus.ATTENTION)
for backend, error, backtrace in errors.errors:
notify = True
#.........这里部分代码省略.........
示例3: MyThread
# 需要导入模块: from weboob.core import Weboob [as 别名]
# 或者: from weboob.core.Weboob import do [as 别名]
class MyThread(Thread):
daemon = True
def __init__(self, bot):
Thread.__init__(self)
self.weboob = Weboob(storage=StandardStorage(STORAGE_FILE))
self.weboob.load_backends()
self.bot = bot
self.bot.set_weboob(self.weboob)
def run(self):
for ev in self.bot.joined.itervalues():
ev.wait()
self.weboob.repeat(300, self.check_board)
self.weboob.repeat(600, self.check_dlfp)
self.weboob.repeat(600, self.check_twitter)
self.weboob.loop()
def find_keywords(self, text):
for word in [
'weboob', 'videoob', 'havesex', 'havedate', 'monboob', 'boobmsg',
'flatboob', 'boobill', 'pastoob', 'radioob', 'translaboob', 'traveloob', 'handjoob',
'boobathon', 'boobank', 'boobtracker', 'comparoob', 'wetboobs',
'webcontentedit', 'weboorrents', 'assnet', 'budget insight', 'budget-insight', 'budgetinsight', 'budgea']:
if word in text.lower():
return word
return None
def check_twitter(self):
nb_tweets = 10
for backend in self.weboob.iter_backends(module='twitter'):
for thread in list(itertools.islice(backend.iter_resources(None, ['search', 'weboob']),
0,
nb_tweets)):
if not backend.storage.get('lastpurge'):
backend.storage.set('lastpurge', datetime.now() - timedelta(days=60))
backend.storage.save()
if thread.id not in backend.storage.get('seen', default={}) and\
thread.date > backend.storage.get('lastpurge'):
_item = thread.id.split('#')
url = 'https://twitter.com/%s/status/%s' % (_item[0], _item[1])
for msg in self.bot.on_url(url):
self.bot.send_message('%s: %s' % (_item[0], url))
self.bot.send_message(msg)
backend.set_message_read(backend.fill_thread(thread, ['root']).root)
def check_dlfp(self):
for msg in self.weboob.do('iter_unread_messages', backends=['dlfp']):
word = self.find_keywords(msg.content)
if word is not None:
url = msg.signature[msg.signature.find('https://linuxfr'):]
self.bot.send_message('[DLFP] %s talks about %s: %s' % (
msg.sender, word, url))
self.weboob[msg.backend].set_message_read(msg)
def check_board(self):
def iter_messages(backend):
with backend.browser:
return backend.browser.iter_new_board_messages()
for msg in self.weboob.do(iter_messages, backends=['dlfp']):
word = self.find_keywords(msg.message)
if word is not None and msg.login != 'moules':
message = msg.message.replace(word, '\002%s\002' % word)
self.bot.send_message('[DLFP] <%s> %s' % (msg.login, message))
def stop(self):
self.weboob.want_stop()
self.weboob.deinit()