use self.do instead of self.weboob.do in console apps

This commit is contained in:
Christophe Benz 2010-08-12 16:44:42 +02:00
commit 7df5136b5f
10 changed files with 21 additions and 21 deletions

View file

@ -41,7 +41,7 @@ class Boobank(ConsoleApplication):
@ConsoleApplication.command('List every available accounts')
def command_list(self):
try:
for backend, account in self.weboob.do('iter_accounts'):
for backend, account in self.do('iter_accounts'):
self.format(account, backend.name)
except weboob.core.CallErrors, errors:
for backend, error, backtrace in errors:
@ -59,7 +59,7 @@ class Boobank(ConsoleApplication):
return backend.iter_operations(account)
try:
for backend, operation in self.weboob.do(do):
for backend, operation in self.do(do):
self.format(operation, backend.name)
total += operation.amount
except weboob.core.CallErrors, errors:

View file

@ -33,7 +33,7 @@ class Chatoob(ConsoleApplication):
def main(self, argv):
self.load_configured_backends(ICapChat)
#for backend, result in self.weboob.do('start_chat_polling', self.on_new_chat_message):
#for backend, result in self.do('start_chat_polling', self.on_new_chat_message):
#logging.info(u'Polling chat messages for backend %s' % backend)
return self.process_command(*argv[1:])
@ -46,16 +46,16 @@ class Chatoob(ConsoleApplication):
@ConsoleApplication.command('list online contacts')
def command_list(self):
for backend, contact in self.weboob.do('iter_contacts', status=Contact.STATUS_ONLINE, caps=ICapContact):
for backend, contact in self.do('iter_contacts', status=Contact.STATUS_ONLINE, caps=ICapContact):
self.format(contact, backend.name)
@ConsoleApplication.command('get messages')
def command_messages(self):
for backend, message in self.weboob.do('iter_chat_messages'):
for backend, message in self.do('iter_chat_messages'):
self.format(message, backend.name)
@ConsoleApplication.command('send message to contact')
def command_send(self, _id, message):
for backend, result in self.weboob.do('send_chat_message', _id, message):
for backend, result in self.do('send_chat_message', _id, message):
if not result:
logging.error(u'Failed to send message to contact id="%s" on backend "%s"' % (_id, backend.name))

View file

@ -36,7 +36,7 @@ class Geolooc(ConsoleApplication):
return 1
self.load_configured_backends(ICapGeolocIp)
for backend, location in self.weboob.do('get_location', argv[1]):
for backend, location in self.do('get_location', argv[1]):
self.format(location, backend.name)
return 0

View file

@ -40,7 +40,7 @@ class HaveSex(PromptApplication):
self.load_config()
self.load_configured_backends(ICapDating, storage=self.create_storage(self.STORAGE_FILENAME))
self.weboob.do('init_optimizations').wait()
self.do('init_optimizations').wait()
optimizations = self.config.get('optimizations')
if optimizations:
@ -72,7 +72,7 @@ class HaveSex(PromptApplication):
print '\t' * level + '%-20s %s' % (node.label + ':', value)
found = 0
for backend, contact in self.weboob.do('get_contact', _id, backends=backend_name):
for backend, contact in self.do('get_contact', _id, backends=backend_name):
if contact:
print 'Nickname:', contact.name
if contact.status & contact.STATUS_ONLINE:
@ -101,7 +101,7 @@ class HaveSex(PromptApplication):
def service(self, action, function, *params):
sys.stdout.write('%s:' % action)
for backend, result in self.weboob.do(function, *params):
for backend, result in self.do(function, *params):
if result:
sys.stdout.write(' ' + backend.name)
sys.stdout.flush()

View file

@ -183,7 +183,7 @@ class Monboob(ConsoleApplication):
self.weboob.loop()
def process(self):
for backend, message in self.weboob.do('iter_new_messages'):
for backend, message in self.do('iter_new_messages'):
self.send_email(backend, message)
def send_email(self, backend, mail):

View file

@ -36,7 +36,7 @@ class Traveloob(ConsoleApplication):
@ConsoleApplication.command('Search stations')
def command_stations(self, pattern):
self.load_backends(ICapTravel)
for backend, station in self.weboob.do('iter_station_search', pattern):
for backend, station in self.do('iter_station_search', pattern):
self.format(station, backend.name)
@ConsoleApplication.command('List all departures for a given station')
@ -58,5 +58,5 @@ class Traveloob(ConsoleApplication):
backends = None
self.load_backends(ICapTravel, names=backends)
for backend, departure in self.weboob.do('iter_station_departures', station_id, arrival_id):
for backend, departure in self.do('iter_station_departures', station_id, arrival_id):
self.format(departure, backend.name)

View file

@ -42,7 +42,7 @@ class Videoob(ConsoleApplication):
_id, backend_name = self.parse_id(_id)
names = (backend_name,) if backend_name is not None else None
self.load_backends(ICapVideo, names=names)
for backend, video in self.weboob.do('get_video', _id):
for backend, video in self.do('get_video', _id):
if video is None:
continue
self.format(video, backend.name)

View file

@ -46,7 +46,7 @@ class WeboobCli(ConsoleApplication):
else:
self.load_backends(cap_s)
for backend, obj in self.weboob.do(cmd, *args):
for backend, obj in self.do(cmd, *args):
self.format(obj, backend.name)
return 0

View file

@ -40,7 +40,7 @@ class Weboorrents(ConsoleApplication):
_id, backend_name = self.parse_id(id)
found = 0
for backend, torrent in self.weboob.do('get_torrent', _id, backends=backend_name):
for backend, torrent in self.do('get_torrent', _id, backends=backend_name):
if torrent:
self.format(torrent, backend.name)
found = 1
@ -52,7 +52,7 @@ class Weboorrents(ConsoleApplication):
def command_getfile(self, id, dest):
_id, backend_name = self.parse_id(id)
for backend, buf in self.weboob.do('get_torrent_file', _id, backends=backend_name):
for backend, buf in self.do('get_torrent_file', _id, backends=backend_name):
if buf:
if dest == '-':
print buf
@ -66,5 +66,5 @@ class Weboorrents(ConsoleApplication):
@ConsoleApplication.command('Search torrents')
def command_search(self, pattern=None):
self.set_formatter_header(u'Search pattern: %s' % pattern if pattern else u'Latest torrents')
for backend, torrent in self.weboob.do('iter_torrents', pattern=pattern):
for backend, torrent in self.do('iter_torrents', pattern=pattern):
self.format(torrent, backend.name)

View file

@ -38,13 +38,13 @@ class WetBoobs(ConsoleApplication):
@ConsoleApplication.command('search cities')
def command_search(self, pattern):
for backend, city in self.weboob.do('iter_city_search', pattern):
for backend, city in self.do('iter_city_search', pattern):
self.format(city, backend.name)
@ConsoleApplication.command('get current weather')
def command_current(self, city):
try:
for backend, current in self.weboob.do('get_current', city):
for backend, current in self.do('get_current', city):
self.format(current, backend.name)
except CallErrors, e:
for error in e:
@ -56,7 +56,7 @@ class WetBoobs(ConsoleApplication):
@ConsoleApplication.command('get forecasts')
def command_forecasts(self, city):
try:
for backend, forecast in self.weboob.do('iter_forecast', city):
for backend, forecast in self.do('iter_forecast', city):
self.format(forecast, backend.name)
except CallErrors, e:
for error in e: