snowskeleton / ynam

Mint-to-YNAB translator
Apache License 2.0
38 stars 0 forks source link

Docker Container #7

Closed natescherer closed 1 year ago

natescherer commented 2 years ago

Hello! I'm looking at building this into a Docker container; was curious if you'd like me to contribute that back to this repo or if you'd rather I maintain it in my own. Either is fine for me. Thanks for the useful program!

snowskeleton commented 2 years ago

I'm glad you found this useful! I knew there must be dozens of us who have this issue.

I think having Docker info in the main repo is a good idea. I'd probably take advantage of it myself. At the moment I'm focusing on other projects, but I'd love to see what you come up with.

snowskeleton commented 2 years ago

I just got this built into a docker image here. Lemme know what you think if you have a chance to try it out.

natescherer commented 1 year ago

Finally got a chance to take the docker container for a spin, but I'm also running into the issue in #20:

2022-12-01T07:08:03.627611107Z Traceback (most recent call last):

2022-12-01T07:08:03.627662780Z   File "/usr/local/lib/python3.8/dist-packages/ynam/main.py", line 21, in main

2022-12-01T07:08:03.627680843Z     mints = mapi.getXtns()

2022-12-01T07:08:03.627690047Z   File "/usr/local/lib/python3.8/dist-packages/ynam/api.py", line 84, in getXtns

2022-12-01T07:08:03.627698173Z     client.authorize(self.cookies(), self.key())

2022-12-01T07:08:03.627711006Z   File "/usr/local/lib/python3.8/dist-packages/ynam/api.py", line 98, in cookies

2022-12-01T07:08:03.627719082Z     with open(self.cpath, 'r') as file:

2022-12-01T07:08:03.627730122Z FileNotFoundError: [Errno 2] No such file or directory: '/root/.ynam_mintapi_cookies'

2022-12-01T07:08:03.627741516Z 

2022-12-01T07:08:03.627750070Z During handling of the above exception, another exception occurred:

2022-12-01T07:08:03.627757898Z 

2022-12-01T07:08:03.627765532Z Traceback (most recent call last):

2022-12-01T07:08:03.627776205Z   File "/usr/local/bin/ynam", line 8, in <module>

2022-12-01T07:08:03.627785072Z     sys.exit(main())

2022-12-01T07:08:03.627792719Z   File "/usr/local/lib/python3.8/dist-packages/ynam/main.py", line 23, in main

2022-12-01T07:08:03.627836919Z     mapi.updateAuth()

2022-12-01T07:08:03.627845714Z   File "/usr/local/lib/python3.8/dist-packages/ynam/api.py", line 117, in updateAuth

2022-12-01T07:08:03.627854040Z     file.write(str(bowser._get_cookies()))

2022-12-01T07:08:03.627861814Z   File "/src/mintapi/mintapi/browser.py", line 214, in _get_cookies

2022-12-01T07:08:03.627872778Z     return self.driver.get_cookies()

2022-12-01T07:08:03.627883994Z AttributeError: 'NoneType' object has no attribute 'get_cookies'

2022-12-01T07:08:07.782375194Z Traceback (most recent call last):

2022-12-01T07:08:07.782410050Z   File "/usr/local/lib/python3.8/dist-packages/ynam/main.py", line 21, in main

2022-12-01T07:08:07.782422657Z     mints = mapi.getXtns()

2022-12-01T07:08:07.782434274Z   File "/usr/local/lib/python3.8/dist-packages/ynam/api.py", line 84, in getXtns

2022-12-01T07:08:07.782443005Z     client.authorize(self.cookies(), self.key())

2022-12-01T07:08:07.782450852Z   File "/usr/local/lib/python3.8/dist-packages/ynam/api.py", line 99, in cookies

2022-12-01T07:08:07.782458837Z     return ast.literal_eval(file.read())

2022-12-01T07:08:07.782466543Z   File "/usr/lib/python3.8/ast.py", line 59, in literal_eval

2022-12-01T07:08:07.782474328Z     node_or_string = parse(node_or_string, mode='eval')

2022-12-01T07:08:07.782485264Z   File "/usr/lib/python3.8/ast.py", line 47, in parse

2022-12-01T07:08:07.782496717Z     return compile(source, filename, mode, flags,

2022-12-01T07:08:07.782505523Z   File "<unknown>", line 0

2022-12-01T07:08:07.782513603Z     

2022-12-01T07:08:07.782542225Z     ^

2022-12-01T07:08:07.782563158Z SyntaxError: unexpected EOF while parsing
natescherer commented 1 year ago

Okay, I figured out the explanation for that, which I commented on in the other issue. However, with the container, I'm running into the same issue I am seeing when I try to run on any platform at the moment:

Traceback (most recent call last):

  File "/usr/local/bin/ynam", line 8, in <module>

    sys.exit(main())

  File "/usr/local/lib/python3.8/dist-packages/ynam/main.py", line 26, in main

    ydeez = [y.import_id for y in ynapi.getXtns()]

  File "/usr/local/lib/python3.8/dist-packages/ynam/api.py", line 179, in getXtns


    return [

  File "/usr/local/lib/python3.8/dist-packages/ynam/api.py", line 180, in <listcomp>

    YNABTransaction.from_dict(xt)

  File "/usr/local/lib/python3.8/dist-packages/ynam/api.py", line 67, in from_dict

    return cls(**{

  File "<string>", line 16, in __init__

  File "/usr/local/lib/python3.8/dist-packages/ynam/api.py", line 60, in __post_init__

    self.payee_name = self.payee_name[:100]

TypeError: 'NoneType' object is not subscriptable
snowskeleton commented 1 year ago

Can you check if the issue persists with the most recent update?

The issue you're having is usually because Mint returned bad data (often due to failure to login). I should probably add better error messages while I'm at it

Nick-Gatti commented 1 year ago

As an addition to this, any chance of adding to DockerHub once the kinks are smoothed out? I'm fine doing it manually, but it'd be nice to have Unraid update for me.

snowskeleton commented 1 year ago

@NGatti1997 there's an image in dockerhub now under snowskeleton/ynam. Lemme know how it works for you!

Nick-Gatti commented 1 year ago

How is the container taking the variables? Tried adding them and got this:

Traceback (most recent call last): File "/usr/local/bin/ynam", line 5, in <module> from ynam.main import main File "/usr/local/lib/python3.8/dist-packages/ynam/main.py", line 5, in <module> from .mint_api import MintAPI File "/usr/local/lib/python3.8/dist-packages/ynam/mint_api.py", line 9, in <module> from .ynab_api import YNABTransaction File "/usr/local/lib/python3.8/dist-packages/ynam/ynab_api.py", line 40, in <module> class YNABAPI(): File "/usr/local/lib/python3.8/dist-packages/ynam/ynab_api.py", line 406, in YNABAPI ) -> dict[list[YNABTransaction]]: TypeError: 'type' object is not subscriptable

Took a look at the image in DockerHub and it doesn't look like those get copied over.

snowskeleton commented 1 year ago

I just pushed a new image. The traceback you have is from an older version, so the new one should solve your issue.

To answer your question, take a look at line 22 of ynam's Dockerfile:

ENTRYPOINT ["sudo", "ynam", "--use-chromedriver-on-path"]

The ENTRYPOINT command acts as a prefix for any commands you pass on the commandline. For example, when you run

docker <docker arguments> run snowskeleton/ynam <some arguments>

internally docker runs

sudo ynam --user-chromedriver-on-path <some arguments>

This lets me as a developer set default arguments as well as gives the user the option to add whatever they'd like as well.

snowskeleton commented 1 year ago

Closing as complete because a Docker container now exists for ynam. Any issues with the container should be opened as separate issues