Using proteus to automate import of bank statement

I’m trying to use proteus to automate importation of bank statements on a nightly basis.
Looks that I need some hint, how to analyze the following problem.

While looking at the conversation between native client and backend i’ve timbered the following script:

from proteus import config, Model, Wizard, Report
import base64

conf = config.set_xmlrpc('http://<Username>:<Password>@<Hostname>:<Port>/<Database>/')

## Open Statement Import Wizard
stmt_wiz = Wizard('account.statement.import')

## Load OFX
data = open("/<path>/<to>/<file>/2021-03-01.DExxyyyyyyyyzzzzzzzz00.camt.booked.ofx", "r").read()
encoded = base64.b64encode(data.encode())
stmt_wiz.form.file_ = encoded

## Set file format
stmt_wiz.form.file_format = 'ofx'

##      Start import
r = stmt_wiz.execute('import_')

which is leading to the following error:

Traceback (most recent call last):
  File "/srv/tryton/", line 32, in <module>
    r = stmt_wiz.execute('import_')
  File "/srv/tryton/", line 1234, in execute
  File "/usr/lib/python3.7/xmlrpc/", line 1112, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python3.7/xmlrpc/", line 1452, in __request
  File "/usr/lib/python3.7/xmlrpc/", line 1154, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python3.7/xmlrpc/", line 1170, in single_request
    return self.parse_response(resp)
  File "/usr/lib/python3.7/xmlrpc/", line 1342, in parse_response
    return u.close()
  File "/usr/lib/python3.7/xmlrpc/", line 656, in close
    raise Fault(**self._stack[0])
xmlrpc.client.Fault: <**Fault 255: 'not enough values to unpack (expected 2, got 1)**'>

I am helpless to determine, which value I am missing.
Any help is appreciated


Hi, take a look to the scenario test of the module, maybe it helps:
Best Udo

Bad way to load the ofx.

Works so much better when doing this way:
statement_import.form.file_ =’////2021-03-01.DExxyyyyyyyyzzzzzzzz00.camt.booked.ofx’, ‘rb’, encoding=None).read()

Perfect! Thank you @udono!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.