rienafairefr / pynYNAB

a python client for the new YNAB
MIT License
138 stars 12 forks source link

cmd client is not able to parse arguments correctly #46

Open chbndrhnns opened 7 years ago

chbndrhnns commented 7 years ago

Here is the next issue:

1) pynynab ofximport --email bla --password bla --budgetname bla (no ofx file given)

seem to use ofximport as file name:

Traceback (most recent call last):
  File "/Users/jo/.virtualenvs/m2ynab/bin/pynynab", line 11, in <module>
    load_entry_point('pynYNAB===dev', 'console_scripts', 'pynynab')()
  File "/Users/jo/.virtualenvs/m2ynab/lib/python2.7/site-packages/pynYNAB-dev-py2.7.egg/pynYNAB/__main__.py", line 127, in main
    MainCommands()
  File "/Users/jo/.virtualenvs/m2ynab/lib/python2.7/site-packages/pynYNAB-dev-py2.7.egg/pynYNAB/__main__.py", line 62, in __init__
    getattr(self, args.command)()
  File "/Users/jo/.virtualenvs/m2ynab/lib/python2.7/site-packages/pynYNAB-dev-py2.7.egg/pynYNAB/__main__.py", line 110, in ofximport
    delta = do_ofximport(args,client)
  File "/Users/jo/.virtualenvs/m2ynab/lib/python2.7/site-packages/pynYNAB-dev-py2.7.egg/pynYNAB/scripts/ofximport.py", line 17, in do_ofximport
    tree.parse(args.ofxfile,codec='cp1252')
  File "/Users/jo/.virtualenvs/m2ynab/lib/python2.7/site-packages/ofxtools-0.5-py2.7.egg/ofxtools/Parser.py", line 31, in parse
    source = self._read(source, codec)  # Now it's a string
  File "/Users/jo/.virtualenvs/m2ynab/lib/python2.7/site-packages/ofxtools-0.5-py2.7.egg/ofxtools/Parser.py", line 68, in _read
    source = open(source, 'rb')
IOError: [Errno 2] No such file or directory: 'ofximport'

2) pynynab ofximport --email bla --password bla --budgetname bla sample.ofx

fails with

pynYNAB OFX import
usage: pynynab [-h] [--email Email] [--password Password]
               [--budgetname BudgetName]
               OFXPath
pynynab: error: unrecognized arguments: sample.ofx

3) My ynab.conf in the working directory is ignored.

rienafairefr commented 7 years ago

Thanks for the detailed info. I really need to revise the interface.

chbndrhnns commented 7 years ago

yeah, I am trying to incorporate your module into my own module.

rienafairefr commented 7 years ago

if you're building in python, it's probably easier to directly import the do_ofximport/do_csvimport functions instead of using the CLI interface I think. just pass it an object with email,password,budgetname attributes

rienafairefr commented 7 years ago

OK I think I found the problem, just pushed 3d3c305f988a786406aba79190b11c5ba54b0386 , there was a missing sys.argv.pop to remove the command (ofximport or csvimport).

chbndrhnns commented 7 years ago

No, not yet. I needed to add to ofximport.py

import logging
logging.basicConfig()

to get the error messages working on cmd. After that, i still get the following message:

pynynab ofximport --email a --password b --budgetname c sample.ofx
pynYNAB OFX import
usage: pynynab [-h] [--email Email] [--password Password]
               [--budgetname BudgetName]
               OFXPath
pynynab: error: unrecognized arguments: sample.ofx
rienafairefr commented 7 years ago

Logging, logging.basicConfig() in main added in the latest changes

This case pynynab ofximport --email a --password b --budgetname c sample.ofx should be covered by the test_scripts, test_command_do_ofximport. Are you sure about which version is set up in your env/virtualenv or whatever ?

chbndrhnns commented 7 years ago

Logging is indeed fixed, but the second error in https://github.com/rienafairefr/pynYNAB/issues/46#issuecomment-315670703 still exists with 1a5894311928676207a952517c77e6e33e7366d5.

rienafairefr commented 7 years ago

which python version ?

chbndrhnns commented 7 years ago

2.7.13 and 3.6

rienafairefr commented 7 years ago

how did you install pynynab and its entrypoint ?

chbndrhnns commented 7 years ago

I uninstalled all pip version of pynynab, cloned the repo, created a virtual environment using mkvirtualenv, did python setup.py build; python setup.py install and verified via which pynynab that the correct version (in the virtual environment) is called.

Is something wrong with doing it that way?