def register_backend(self, name, ask_add=True): try: backend = self.weboob.modules_loader.get_or_load_module(name) except ModuleLoadError as e: backend = None if not backend: print('Backend "%s" does not exist.' % name, file=sys.stderr) return 1 if not backend.has_caps(ICapAccount) or backend.klass.ACCOUNT_REGISTER_PROPERTIES is None: print("You can't register a new account with %s" % name, file=sys.stderr) return 1 account = Account() account.properties = {} if backend.website: website = "on website %s" % backend.website else: website = "with backend %s" % backend.name while True: asked_config = False for key, prop in backend.klass.ACCOUNT_REGISTER_PROPERTIES.iteritems(): if not asked_config: asked_config = True print("Configuration of new account %s" % website) print("-----------------------------%s" % ("-" * len(website))) p = copy(prop) p.set( self.ask( prop, default=account.properties[key].get() if (key in account.properties) else prop.default ) ) account.properties[key] = p if asked_config: print("-----------------------------%s" % ("-" * len(website))) try: backend.klass.register_account(account) except AccountRegisterError as e: print(u"%s" % e) if self.ask("Do you want to try again?", default=True): continue else: return None else: break backend_config = {} for key, value in account.properties.iteritems(): if key in backend.config: backend_config[key] = value.get() if ask_add and self.ask("Do you want to add the new register account?", default=True): return self.add_backend(name, backend_config, ask_register=False) return backend_config
def register_backend(self, name, ask_add=True): try: backend = self.weboob.modules_loader.get_or_load_module(name) except ModuleLoadError as e: backend = None if not backend: print('Backend "%s" does not exist.' % name, file=self.stderr) return 1 if not backend.has_caps(CapAccount) or backend.klass.ACCOUNT_REGISTER_PROPERTIES is None: print('You can\'t register a new account with %s' % name, file=self.stderr) return 1 account = Account() account.properties = {} if backend.website: website = 'on website %s' % backend.website else: website = 'with backend %s' % backend.name while True: asked_config = False for key, prop in backend.klass.ACCOUNT_REGISTER_PROPERTIES.iteritems(): if not asked_config: asked_config = True print('Configuration of new account %s' % website) print('-----------------------------%s' % ('-' * len(website))) p = copy(prop) p.set(self.ask(prop, default=account.properties[key].get() if (key in account.properties) else prop.default)) account.properties[key] = p if asked_config: print('-----------------------------%s' % ('-' * len(website))) try: backend.klass.register_account(account) except AccountRegisterError as e: print(u'%s' % e) if self.ask('Do you want to try again?', default=True): continue else: return None else: break backend_config = {} for key, value in account.properties.iteritems(): if key in backend.config: backend_config[key] = value.get() if ask_add and self.ask('Do you want to add the new register account?', default=True): return self.add_backend(name, backend_config, ask_register=False) return backend_config
def registerEvent(self): selection = self.ui.modulesList.selectedItems() if not selection: return try: module = self.weboob.modules_loader.get_or_load_module( selection[0].text().lower()) except ModuleLoadError: module = None if not module: return dialog = QDialog(self) vbox = QVBoxLayout(dialog) if module.website: website = 'on the website <b>%s</b>' % module.website else: website = 'with the module <b>%s</b>' % module.name vbox.addWidget( QLabel( 'To create an account %s, please provide this information:' % website)) formlayout = QFormLayout() props_widgets = OrderedDict() for key, prop in module.klass.ACCOUNT_REGISTER_PROPERTIES.iteritems(): widget = QtValue(prop) formlayout.addRow(QLabel(u'%s:' % prop.label), widget) props_widgets[prop.id] = widget vbox.addLayout(formlayout) buttonBox = QDialogButtonBox(dialog) buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) buttonBox.accepted.connect(dialog.accept) buttonBox.rejected.connect(dialog.reject) vbox.addWidget(buttonBox) end = False while not end: end = True if dialog.exec_(): account = Account() account.properties = {} for key, widget in props_widgets.iteritems(): try: v = widget.get_value() except ValueError as e: QMessageBox.critical( self, self.tr('Invalid value'), self. tr('Invalid value for field "%s":<br /><br />%s') % (key, e)) end = False break else: account.properties[key] = v if end: try: module.klass.register_account(account) except AccountRegisterError as e: QMessageBox.critical( self, self.tr('Error during register'), self.tr( 'Unable to register account %s:<br /><br />%s') % (website, e)) end = False else: for key, value in account.properties.iteritems(): if key in self.config_widgets: self.config_widgets[key][1].set_value(value)
def registerEvent(self): selection = self.ui.modulesList.selectedItems() if not selection: return try: module = self.weboob.modules_loader.get_or_load_module(unicode(selection[0].text()).lower()) except ModuleLoadError: module = None if not module: return dialog = QDialog(self) vbox = QVBoxLayout(dialog) if module.website: website = 'on the website <b>%s</b>' % module.website else: website = 'with the module <b>%s</b>' % module.name vbox.addWidget(QLabel('To create an account %s, please provide this information:' % website)) formlayout = QFormLayout() props_widgets = OrderedDict() for key, prop in module.klass.ACCOUNT_REGISTER_PROPERTIES.iteritems(): widget = QtValue(prop) formlayout.addRow(QLabel(u'%s:' % prop.label), widget) props_widgets[prop.id] = widget vbox.addLayout(formlayout) buttonBox = QDialogButtonBox(dialog) buttonBox.setStandardButtons(QDialogButtonBox.Ok|QDialogButtonBox.Cancel) self.connect(buttonBox, SIGNAL("accepted()"), dialog.accept) self.connect(buttonBox, SIGNAL("rejected()"), dialog.reject) vbox.addWidget(buttonBox) end = False while not end: end = True if dialog.exec_(): account = Account() account.properties = {} for key, widget in props_widgets.iteritems(): try: v = widget.get_value() except ValueError as e: QMessageBox.critical(self, self.tr('Invalid value'), unicode(self.tr('Invalid value for field "%s":<br /><br />%s')) % (key, e)) end = False break else: account.properties[key] = v if end: try: module.klass.register_account(account) except AccountRegisterError as e: QMessageBox.critical(self, self.tr('Error during register'), unicode(self.tr('Unable to register account %s:<br /><br />%s')) % (website, e)) end = False else: for key, value in account.properties.iteritems(): if key in self.config_widgets: self.config_widgets[key][1].set_value(value)
def register_backend(self, name, ask_add=True): try: backend = self.weboob.modules_loader.get_or_load_module(name) except ModuleLoadError, e: backend = None if not backend: print >>sys.stderr, 'Backend "%s" does not exist.' % name return 1 if not backend.has_caps(ICapAccount) or backend.klass.ACCOUNT_REGISTER_PROPERTIES is None: print >>sys.stderr, 'You can\'t register a new account with %s' % name return 1 account = Account() account.properties = {} if backend.website: website = 'on website %s' % backend.website else: website = 'with backend %s' % backend.name while 1: asked_config = False for key, prop in backend.klass.ACCOUNT_REGISTER_PROPERTIES.iteritems(): if not asked_config: asked_config = True print 'Configuration of new account %s' % website print '-----------------------------%s' % ('-' * len(website)) p = copy(prop) p.set(self.ask(prop, default=account.properties[key].get() if (key in account.properties) else prop.default)) account.properties[key] = p
try: backend = self.weboob.modules_loader.get_or_load_module(name) except ModuleLoadError, e: backend = None if not backend: print >> sys.stderr, 'Backend "%s" does not exist.' % name return 1 if not backend.has_caps( ICapAccount ) or backend.klass.ACCOUNT_REGISTER_PROPERTIES is None: print >> sys.stderr, 'You can\'t register a new account with %s' % name return 1 account = Account() account.properties = {} if backend.website: website = 'on website %s' % backend.website else: website = 'with backend %s' % backend.name while 1: asked_config = False for key, prop in backend.klass.ACCOUNT_REGISTER_PROPERTIES.iteritems( ): if not asked_config: asked_config = True print 'Configuration of new account %s' % website print '-----------------------------%s' % ('-' * len(website)) p = copy(prop)