captin411 / ofxclient

Bank transaction downloader and python OFX client libraries
MIT License
264 stars 89 forks source link

Crash from configparser #31

Open Kodiologist opened 8 years ago

Kodiologist commented 8 years ago

I download Wells Fargo transactions with the command ofxclient -a [...] -d - -c ~/.config/ofxclient.ini. This has worked fine for a while, but today, I got TypeError: get() got an unexpected keyword argument 'raw'. I upgraded from 2.0.2 to 93d2924, which is the current tip of master, but I got the same error. I'm on Ubuntu 16.04.1. Here's the stack trace:

Traceback (most recent call last):
  File "/usr/local/bin/ofxclient", line 11, in <module>
    load_entry_point('ofxclient==2.0.2', 'console_scripts', 'ofxclient')()
  File "/usr/local/lib/python2.7/dist-packages/ofxclient/cli.py", line 40, in run
    accounts = GlobalConfig.accounts()
  File "/usr/local/lib/python2.7/dist-packages/ofxclient/config.py", line 216, in accounts
    for s in self.parser.sections()]
  File "/usr/local/lib/python2.7/dist-packages/ofxclient/config.py", line 301, in _section_to_account
    section_items = dict(self.parser.items(section))
  File "/usr/local/lib/python2.7/dist-packages/ofxclient/config.py", line 100, in items
    for k, v in ConfigParser.items(self, section):
  File "/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", line 878, in items
    return [(option, value_getter(option)) for option in d.keys()]
  File "/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", line 875, in <lambda>
    section, option, d[option], d)
  File "/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", line 384, in before_get
    self._interpolate_some(parser, option, L, value, section, defaults, 1)
  File "/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", line 397, in _interpolate_some
    rawval = parser.get(section, option, raw=True, fallback=rest)
TypeError: get() got an unexpected keyword argument 'raw'
Kodiologist commented 8 years ago

I got the above with Python 2.7.12. With 3.5.2, the bug doesn't arise.

sneilan commented 7 years ago

I get this error with Python 2.7.9

apowell656 commented 7 years ago

I am receiving a similar error: Traceback (most recent call last): File "/usr/local/bin/ofxclient", line 9, in <module> load_entry_point('ofxclient==2.0.3', 'console_scripts', 'ofxclient')() File "/usr/local/lib/python2.7/dist-packages/ofxclient/cli.py", line 63, in run main_menu(args) File "/usr/local/lib/python2.7/dist-packages/ofxclient/cli.py", line 83, in main_menu add_account_menu(args) File "/usr/local/lib/python2.7/dist-packages/ofxclient/cli.py", line 130, in add_account_menu if login_check_menu(bank, args): File "/usr/local/lib/python2.7/dist-packages/ofxclient/cli.py", line 219, in login_check_menu GlobalConfig.add_account(a) File "/usr/local/lib/python2.7/dist-packages/ofxclient/config.py", line 244, in add_account self.parser.set(section_id, key, section_items[key]) File "/usr/local/lib/python2.7/dist-packages/ofxclient/config.py", line 122, in set ConfigParser.set(self, section, option, value) File "/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", line 1238, in set _, option, value = self._validate_value_types(option=option, value=value) File "/usr/local/lib/python2.7/dist-packages/backports/configparser/__init__.py", line 1221, in _validate_value_types raise TypeError("option values must be strings") TypeError: option values must be strings

Kodiologist commented 7 years ago

For what it's worth, I'm no longer seeing this as of 2.0.3, but I did have to make some other changes to the code to get Wells Fargo (and Discover Card) to work.

Wells Fargo needs DEFAULT_OFX_VERSION bumped to 103, and possibly also DEFAULT_APP_VERSION bumped to 2600.

Discover needs a time.sleep(5) in login_check_menu after i.authenticate() but before i.accounts().

And I needed to change section_items[key] in OfxConfig.add_account to str(section_items[key]), at least for Python 3.6.

flash3780 commented 6 years ago

I get the following error from configparser. It's complaining about inputs not being strings. Note that my bank uses my account number for the login... so perhaps that's where it's barfing.

+----------------------------------
Main
Edit /home/chris/ofxclient.ini to
change descriptions or ofx options
+----------------------------------
(A) Add an account
(Q) Quit
choice> a
+----------------------------------
Add account
+----------------------------------
------
Notice
------
You are about to search for bank connection information
on a third party website.  This means you are trusting
http://ofxhome.com and their security policies.

You will be sending your bank name to this website.
------
bank name eg. "express" (enter to exit)> fifth third
(0) Fifth Third Bancorp
choice> 0
------
Notice
------
You are about to test to make sure your username and password
are correct.  This means you will be sending it to the URL below.
If the URL does not appear to belong to your bank then you should
exit this program by hitting CTRL-C.
  bank name: Fifth Third Bancorp
  bank url:  https://banking.53.com/ofx/OFXServlet
------
username> ****************                                                               
password> 
Traceback (most recent call last):
  File "/usr/bin/ofxclient", line 11, in <module>
    sys.exit(run())
  File "/usr/lib/python3.5/site-packages/ofxclient/cli.py", line 63, in run
    main_menu(args)
  File "/usr/lib/python3.5/site-packages/ofxclient/cli.py", line 83, in main_menu
    add_account_menu(args)
  File "/usr/lib/python3.5/site-packages/ofxclient/cli.py", line 130, in add_account_menu
    if login_check_menu(bank, args):
  File "/usr/lib/python3.5/site-packages/ofxclient/cli.py", line 219, in login_check_menu
    GlobalConfig.add_account(a)
  File "/usr/lib/python3.5/site-packages/ofxclient/config.py", line 244, in add_account
    self.parser.set(section_id, key, section_items[key])
  File "/usr/lib/python3.5/site-packages/ofxclient/config.py", line 122, in set
    ConfigParser.set(self, section, option, value)
  File "/usr/lib64/python3.5/configparser.py", line 1189, in set
    self._validate_value_types(option=option, value=value)
  File "/usr/lib64/python3.5/configparser.py", line 1174, in _validate_value_types
    raise TypeError("option values must be strings")
TypeError: option values must be strings

Maybe changing the type of "value" to a string prior to passing it to ConfigParser would fix it?

118  def set(self, section, option, value):
119      """Set an option value. Knows how to set options properly marked
120      as secure."""
121      if value is False:
122          value = '!!False!!'
123      if self.is_secure_option(section, option):
124          self.set_secure(section, option, value)
125      else:
126          ConfigParser.set(self, section, option, str(value))
flash3780 commented 6 years ago

I confirmed that forcing the value coming into ConfigParser to be a string fixes the problem, but I can't figure out how to make the test suite work... otherwise I'd send a pull request.

Nonetheless, please see the snippet above.

jackkamm commented 5 years ago

Just a note that the version of ofxclient on PyPi is a version behind and still has this problem. Installing the latest version from github fixes it.