pytr-org / pytr

Use TradeRepublic in terminal and mass download all documents
https://pypi.org/project/pytr/
MIT License
422 stars 74 forks source link

UnboundLocalError: local variable 'subscription' referenced before assignment #108

Closed pgoodbread closed 3 months ago

pgoodbread commented 3 months ago

Description of the bug Timeout while trying to download documents dl_docs, b/c subscription variable was referenced before it's initialization

To Reproduce Steps to reproduce the behavior:

  1. Ran the command pytr dl_docs $FOLDER -n +49$NUMBER -p $PIN
  2. Wait for SMS Counter
  3. Request SMS Code
  4. Enter SMS Code
  5. See error after short Delay

Expected behavior I expect documents to be downloaded without error.

Error log

15:52:12 Logged in
15:52:12 Found 1370 lines in history file
15:52:12 Subscribing to #1 timeline transactions
15:52:12 Connecting to websocket ...
15:52:12 Connected to websocket ...
15:52:27 Received error message: '1 E {"errors":[{"errorCode":"UNKNOWN_ERROR","errorField":null,"errorMessage":"The timeout of 15000 ms has been exceeded when getting a connection to neon-backend-timeline.default.svc.cluster.local:80","meta":{"source":"MAPPER"}}]}'
15:52:27 ('1', {'type': 'timelineTransactions', 'after': None}, {'errors': [{'errorCode': 'UNKNOWN_ERROR', 'errorField': None, 'errorMessage': 'The timeout of 15000 ms has been exceeded when getting a connection to neon-backend-timeline.default.svc.cluster.local:80', 'meta': {'source': 'MAPPER'}}]})
Traceback (most recent call last):
  File "/Users/pgoodbread/Library/Python/3.9/bin/pytr", line 8, in <module>
    sys.exit(main())
  File "/Users/pgoodbread/Library/Python/3.9/lib/python/site-packages/pytr/main.py", line 211, in main
    asyncio.get_event_loop().run_until_complete(dl.dl_loop())
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/Users/pgoodbread/Library/Python/3.9/lib/python/site-packages/pytr/dl.py", line 77, in dl_loop
    if subscription['type'] == 'timelineTransactions':
UnboundLocalError: local variable 'subscription' referenced before assignment

Environment

Katzmann1983 commented 3 months ago

Cannot reproduce. I guess something with the network connection or traderepublic seervers might have been broken. Is this reproducible?

pgoodbread commented 3 months ago

I started pytr again today and it works without problems - so I guess you're right, that it was a problem with Trade Republic servers! Thanks!