change vocabulary

s/module/backend
s/backend/configured_backend
s/frontend/application
This commit is contained in:
Christophe Benz 2010-07-12 03:07:10 +02:00
commit 5c2ab81e16
27 changed files with 347 additions and 347 deletions

View file

@ -35,7 +35,7 @@ class Boobank(ConsoleApplication):
COPYRIGHT = 'Copyright(C) 2010 Romain Bignon'
def main(self, argv):
self.load_backends(ICapBank)
self.load_configured_backends(ICapBank)
return self.process_command(*argv[1:])
@ConsoleApplication.command('List every available accounts')

View file

@ -32,7 +32,7 @@ class Chatoob(ConsoleApplication):
COPYRIGHT = 'Copyright(C) 2010 Christophe Benz'
def main(self, argv):
self.load_backends(ICapChat)
self.load_configured_backends(ICapChat)
#for backend, result in self.weboob.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:])

View file

@ -38,7 +38,7 @@ class HaveSex(PromptApplication):
def main(self, argv):
self.load_config()
self.load_backends(ICapDating, storage=self.create_storage(self.STORAGE_FILENAME))
self.load_configured_backends(ICapDating, storage=self.create_storage(self.STORAGE_FILENAME))
self.weboob.do('init_optimizations').wait()

View file

@ -233,7 +233,6 @@ class Masstransit(BaseApplication):
COPYRIGHT = 'Copyright(C) 2010 Julien Hébert'
def main(self, argv):
"main fonction"
self.load_modules(ICapTravel)
self.load_backends(ICapTravel)
MasstransitHildon(self.weboob)
gtk.main()

View file

@ -93,7 +93,7 @@ class Monboob(ConsoleApplication):
def main(self, argv):
self.load_config()
self.load_backends(ICapMessages, storage=self.create_storage())
self.load_configured_backends(ICapMessages, storage=self.create_storage())
return self.process_command(*argv[1:])

View file

@ -36,10 +36,10 @@ class MainWindow(QtMainWindow):
self.setCentralWidget(self.manager)
self.connect(self.ui.actionModules, SIGNAL("triggered()"), self.modulesConfig)
self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig)
self.connect(self.ui.actionRefresh, SIGNAL("triggered()"), self.refresh)
def modulesConfig(self):
def backendsConfig(self):
bckndcfg = BackendCfg(self.weboob, (ICapMessages,), self)
bckndcfg.show()

View file

@ -27,7 +27,7 @@ class QBoobMsg(QtApplication):
COPYRIGHT = 'Copyright(C) 2010 Romain Bignon'
def main(self, argv):
self.load_backends(ICapMessages, storage=self.create_storage())
self.load_configured_backends(ICapMessages, storage=self.create_storage())
self.main_window = MainWindow(self.config, self.weboob)
self.main_window.show()

View file

@ -29,7 +29,7 @@
<property name="title">
<string>File</string>
</property>
<addaction name="actionModules"/>
<addaction name="actionBackends"/>
<addaction name="actionRefresh"/>
<addaction name="separator"/>
<addaction name="actionQuit"/>
@ -47,12 +47,12 @@
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionModules"/>
<addaction name="actionBackends"/>
<addaction name="actionRefresh"/>
</widget>
<action name="actionModules">
<action name="actionBackends">
<property name="text">
<string>Modules</string>
<string>Backends</string>
</property>
</action>
<action name="actionQuit">

View file

@ -44,10 +44,10 @@ class MainWindow(QtMainWindow):
self.ui.tabWidget.addTab(ContactsWidget(self.weboob), self.tr('Contacts'))
self.ui.tabWidget.addTab(QWidget(), self.tr('Calendar'))
self.connect(self.ui.actionModules, SIGNAL("triggered()"), self.modulesConfig)
self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig)
self.connect(self.ui.tabWidget, SIGNAL('currentChanged(int)'), self.tabChanged)
def modulesConfig(self):
def backendsConfig(self):
bckndcfg = BackendCfg(self.weboob, (ICapDating,), self)
bckndcfg.show()

View file

@ -28,7 +28,7 @@ class QHaveSex(QtApplication):
STORAGE_FILENAME = 'dating.storage'
def main(self, argv):
self.load_backends(ICapDating, storage=self.create_storage())
self.load_configured_backends(ICapDating, storage=self.create_storage())
self.main_window = MainWindow(self.config, self.weboob)
self.main_window.show()

View file

@ -37,7 +37,7 @@
<property name="title">
<string>File</string>
</property>
<addaction name="actionModules"/>
<addaction name="actionBackends"/>
<addaction name="separator"/>
<addaction name="actionQuit"/>
</widget>
@ -54,11 +54,11 @@
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionModules"/>
<addaction name="actionBackends"/>
</widget>
<action name="actionModules">
<action name="actionBackends">
<property name="text">
<string>Modules</string>
<string>Backends</string>
</property>
</action>
<action name="actionQuit">

View file

@ -32,7 +32,7 @@ class QVideoob(QtApplication):
}
}
def main(self, argv):
self.load_modules(ICapVideo)
self.load_backends(ICapVideo)
self.load_config()
self.main_window = MainWindow(self.config, self.weboob)

View file

@ -27,7 +27,7 @@ class QWeboobCfg(QtApplication):
COPYRIGHT = 'Copyright(C) 2010 Romain Bignon'
def main(self, argv):
self.load_backends()
self.load_configured_backends()
self.dlg = BackendCfg(self.weboob)
self.dlg.show()

View file

@ -29,8 +29,7 @@ class Travel(ConsoleApplication):
COPYRIGHT = 'Copyright(C) 2010 Romain Bignon'
def main(self, argv):
self.load_modules(ICapTravel)
self.load_backends(ICapTravel)
return self.process_command(*argv[1:])
@ConsoleApplication.command('Search stations')

View file

@ -41,7 +41,7 @@ class Videoob(ConsoleApplication):
def command_info(self, _id):
_id, backend_name = self.parse_id(_id)
names = (backend_name,) if backend_name is not None else None
self.load_modules(ICapVideo, names=names)
self.load_backends(ICapVideo, names=names)
for backend, video in self.weboob.do('get_video', _id):
if video is None:
continue
@ -49,7 +49,7 @@ class Videoob(ConsoleApplication):
@ConsoleApplication.command('Search for videos')
def command_search(self, pattern=None):
self.load_modules(ICapVideo)
self.load_backends(ICapVideo)
self.set_formatter_header(u'Search pattern: %s' % pattern if pattern else u'Last videos')
for backend, video in self.do('iter_search_results', pattern=pattern, nsfw=self.options.nsfw):
self.format(video, backend.name)

View file

@ -72,7 +72,7 @@ class VideoobWeb(BaseApplication):
def main(self, argv):
self.load_config()
self.weboob.load_modules(ICapVideo)
self.weboob.load_backends(ICapVideo)
print 'Web server created. Listening on http://%s:%s' % (
self.config.get('host'), int(self.config.get('port')))
srv = make_server(self.config.get('host'), int(self.config.get('port')), self.make_app)

View file

@ -44,65 +44,10 @@ class WeboobCfg(ConsoleApplication):
return False
return True
@ConsoleApplication.command('List backends')
def command_backends(self, *caps):
self.set_default_formatter('table')
self.weboob.modules_loader.load()
for name, backend in self.weboob.modules_loader.modules.iteritems():
if caps and not self.caps_included(backend.iter_caps(), caps):
continue
row = OrderedDict([('Name', name),
('Capabilities', ', '.join(cap.__name__ for cap in backend.iter_caps())),
('Description', backend.get_description()),
])
self.format(row)
@ConsoleApplication.command('List applications')
def command_applications(self, *caps):
applications = set()
import weboob.applications
for path in weboob.applications.__path__:
regexp = re.compile('^%s/([\w\d_]+)$' % path)
for root, dirs, files in os.walk(path):
m = regexp.match(root)
if m and '__init__.py' in files:
applications.add(m.group(1))
print ' '.join(sorted(applications)).encode('utf-8')
@ConsoleApplication.command('Display information about a backend')
def command_info(self, name):
try:
backend = self.weboob.modules_loader.get_or_load_module(name)
except KeyError:
logging.error('No such backend: "%s"' % name)
return 1
print '.------------------------------------------------------------------------------.'
print '| Backend %-68s |' % backend.get_name()
print "+-----------------.------------------------------------------------------------'"
print '| Version | %s' % backend.get_version()
print '| Maintainer | %s' % backend.get_maintainer()
print '| License | %s' % backend.get_license()
print '| Description | %s' % backend.get_description()
print '| Capabilities | %s' % ', '.join([cap.__name__ for cap in backend.iter_caps()])
first = True
for key, field in backend.get_config().iteritems():
value = field.description
if not field.default is None:
value += ' (default: %s)' % field.default
if first:
print '| | '
print '| Configuration | %s: %s' % (key, value)
first = False
else:
print '| | %s: %s' % (key, value)
print "'-----------------'"
@ConsoleApplication.command('Add a configured backend')
def command_add(self, name, *options):
self.weboob.modules_loader.load()
if name not in [module_name for module_name, module in self.weboob.modules_loader.modules.iteritems()]:
self.weboob.backends_loader.load_all()
if name not in [name for name, backend in self.weboob.backends_loader.loaded.iteritems()]:
logging.error(u'Backend "%s" does not exist.' % name)
return 1
@ -116,9 +61,9 @@ class WeboobCfg(ConsoleApplication):
return 1
params[key] = value
# ask for params non-specified on command-line arguments
module = self.weboob.modules_loader.get_or_load_module(name)
backend = self.weboob.backends_loader.get_or_load_backend(name)
asked_config = False
for key, value in module.get_config().iteritems():
for key, value in backend.config.iteritems():
if not asked_config:
asked_config = True
print u'Configuration of backend'
@ -155,16 +100,74 @@ class WeboobCfg(ConsoleApplication):
except ConfigParser.DuplicateSectionError:
print u'Instance "%s" already exists for backend "%s".' % (new_name, name)
@ConsoleApplication.command('List configured backends')
@ConsoleApplication.command('Show applications')
def command_applications(self, *caps):
applications = set()
import weboob.applications
for path in weboob.applications.__path__:
regexp = re.compile('^%s/([\w\d_]+)$' % path)
for root, dirs, files in os.walk(path):
m = regexp.match(root)
if m and '__init__.py' in files:
applications.add(m.group(1))
print ' '.join(sorted(applications)).encode('utf-8')
@ConsoleApplication.command('Show available backends')
def command_backends(self, *caps):
self.set_default_formatter('table')
self.weboob.backends_loader.load_all()
for name, backend in sorted(self.weboob.backends_loader.loaded.iteritems()):
if caps and not self.caps_included(backend.iter_caps(), caps):
continue
row = OrderedDict([('Name', name),
('Capabilities', ', '.join(cap.__name__ for cap in backend.iter_caps())),
('Description', backend.description),
])
self.format(row)
@ConsoleApplication.command('Show configured backends')
def command_configured(self):
self.set_default_formatter('table')
for instance_name, name, params in self.weboob.backends_config.iter_backends():
for instance_name, name, params in sorted(self.weboob.backends_config.iter_backends()):
row = OrderedDict([('Instance name', instance_name),
('Backend name', name),
('Configuration', ', '.join('%s=%s' % (key, value) for key, value in params.iteritems())),
])
self.format(row)
@ConsoleApplication.command('Edit configuration file')
def command_edit(self):
subprocess.call([os.environ.get('EDITOR', 'vi'), self.weboob.backends_config.confpath])
@ConsoleApplication.command('Display information about a backend')
def command_info(self, name):
try:
backend = self.weboob.backends_loader.get_or_load_backend(name)
except KeyError:
logging.error('No such backend: "%s"' % name)
return 1
print '.------------------------------------------------------------------------------.'
print '| Backend %-68s |' % backend.name
print "+-----------------.------------------------------------------------------------'"
print '| Version | %s' % backend.version
print '| Maintainer | %s' % backend.maintainer
print '| License | %s' % backend.license
print '| Description | %s' % backend.description
print '| Capabilities | %s' % ', '.join([cap.__name__ for cap in backend.iter_caps()])
first = True
for key, field in backend.config.iteritems():
value = field.description
if not field.default is None:
value += ' (default: %s)' % field.default
if first:
print '| | '
print '| Configuration | %s: %s' % (key, value)
first = False
else:
print '| | %s: %s' % (key, value)
print "'-----------------'"
@ConsoleApplication.command('Remove a configured backend')
def command_remove(self, instance_name):
try:
@ -172,7 +175,3 @@ class WeboobCfg(ConsoleApplication):
except ConfigParser.NoSectionError:
logging.error('Backend instance "%s" does not exist' % instance_name)
return 1
@ConsoleApplication.command('Edit configuration file')
def command_edit(self):
subprocess.call([os.environ.get('EDITOR', 'vi'), self.weboob.backends_config.confpath])

View file

@ -32,14 +32,14 @@ class WeboobDebug(ConsoleApplication):
@ConsoleApplication.command('Debug backend')
def command_shell(self, backend_name):
try:
backend = self.weboob.load_modules(names=[backend_name])[backend_name]
backend = self.weboob.load_backends(names=[backend_name])[backend_name]
except KeyError:
logging.error(u'Unable to load backend "%s"' % backend_name)
return 1
browser = backend.browser
from IPython.Shell import IPShellEmbed
shell = IPShellEmbed(argv=[])
locs = dict(backend=backend, browser=browser, frontend=self, weboob=self.weboob)
locs = dict(backend=backend, browser=browser, application=self, weboob=self.weboob)
banner = 'Weboob debug shell\nBackend "%s" loaded.\nAvailable variables: %s' % (backend_name, locs)
shell.set_banner(shell.IP.BANNER + '\n\n' + banner)
shell(local_ns=locs, global_ns={})

View file

@ -15,6 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
from nose import run
from weboob.tools.application.console import ConsoleApplication
@ -32,13 +33,13 @@ class WeboobTests(ConsoleApplication):
@ConsoleApplication.command('Run tests')
def command_run(self):
self.load_modules()
self.load_backends()
self.load_configured_backends()
suite = []
for backend in self.weboob.iter_backends():
t = backend.get_test()
if t:
suite.append(t)
test = backend.get_test()
if test:
suite.append(test)
return run(suite=suite)

View file

@ -33,7 +33,7 @@ class Weboorrents(ConsoleApplication):
CONFIG = {}
def main(self, argv):
self.load_backends(ICapTorrent)
self.load_configured_backends(ICapTorrent)
return self.process_command(*argv[1:])
@ConsoleApplication.command('Get information about a torrent')

View file

@ -32,7 +32,7 @@ class WetBoobs(ConsoleApplication):
COPYRIGHT = 'Copyright(C) 2010 Romain Bignon'
def main(self, argv):
self.load_modules(ICapWeather)
self.load_backends(ICapWeather)
return self.process_command(*argv[1:])