Commit 7231858c authored by Romain Bignon's avatar Romain Bignon

store website login and password in configuration file

parent 4038cc9b
...@@ -20,7 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -20,7 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import re import re
from nucentral.backend import tr, Component, NuCentralError from nucentral.backend import Component, NuCentralError
from nucentral.backend.exceptions import ConfigError
from bnporc.browser import BNPorc from bnporc.browser import BNPorc
class BNProut(Component): class BNProut(Component):
...@@ -28,16 +29,32 @@ class BNProut(Component): ...@@ -28,16 +29,32 @@ class BNProut(Component):
NAME = "bnporc" NAME = "bnporc"
VERSION = "1.0" VERSION = "1.0"
API_VERSION = 1 API_VERSION = 1
#ROLES = {'bnporc_read': set(('table', 'stream', 'table_list', 'table_filters')), ROLES = {'bnporc_read': set(('bnp_accounts', 'bnp_coming')),
# } }
LOGIN = ''
PASSWORD = ''
def init(self, core): def init(self, core):
self.core = core self.core = core
self.bnp = BNPorc() self.bnp = BNPorc()
self.bnp.login(self.LOGIN, self.PASSWORD) try:
self.bnp.login(self.core.config_manager.get('bnporc', 'login'),
self.core.config_manager.get('bnporc', 'password'))
except ConfigError, err:
pass
def service_setConfig(self, context, login, password):
cm = self.core.config_manager.begin()
try:
cm.set('bnporc', 'login', login)
cm.set('bnporc', 'password', password)
except ConfigError, e:
cm.revert()
raise NuCentralError(tr('Unable to set value for key \'%s\': %s'), key, unicode(e))
cm.commit("BNPorc configuration changed")
self.core.config_manager.apply()
# Reloging
self.bnp.login(login, password)
def service_bnp_accounts(self, context, args, getargs=False): def service_bnp_accounts(self, context, args, getargs=False):
if getargs: if getargs:
...@@ -69,7 +86,6 @@ class BNProut(Component): ...@@ -69,7 +86,6 @@ class BNProut(Component):
count += operation.amount count += operation.amount
label = operation.label.replace(u'\xa0', u' ') label = operation.label.replace(u'\xa0', u' ')
m = re.match('FACTURE CARTE DU (\d\d)(\d\d)(\d\d) (.*)', label) m = re.match('FACTURE CARTE DU (\d\d)(\d\d)(\d\d) (.*)', label)
self.debug('%r' % label)
if m: if m:
label = '%s/%s/%s %s' % (m.group(1), m.group(2), m.group(3), m.group(4)) label = '%s/%s/%s %s' % (m.group(1), m.group(2), m.group(3), m.group(4))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment