Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: list index out of range #3

Open
si-hb opened this issue Jan 8, 2024 · 12 comments
Open

IndexError: list index out of range #3

si-hb opened this issue Jan 8, 2024 · 12 comments
Assignees
Labels
bug Something isn't working

Comments

@si-hb
Copy link

si-hb commented Jan 8, 2024

Appears to be caused by TME not returning any data for a part, therefore index [0] doesn't exit? I don't get the error if the TME part exists.

$ inventree-part-import DRV8837DSGR

searching for DRV8837DSGR ...
Traceback (most recent call last):

....

packages/inventree_part_import/suppliers/supplier_tme.py", line 23, in search
tme_stock = self.tme_api.get_prices_and_stocks([tme_part["Symbol"]])[0]
IndexError: list index out of range```

@30350n
Copy link
Owner

30350n commented Jan 8, 2024

Hm do you always get that error when trying to import that specific part?

I don't get the error if the TME part exists.

DRV8837DSGR exists at tme though. It also just works fine for me.

@30350n
Copy link
Owner

30350n commented Jan 8, 2024

Are you using an anonymous or private TME API token?

@si-hb
Copy link
Author

si-hb commented Jan 9, 2024

I believe private? I got it from here:
image

@si-hb
Copy link
Author

si-hb commented Jan 9, 2024

Hm do you always get that error when trying to import that specific part?

Tested again and appears so, yes.

@30350n
Copy link
Owner

30350n commented Jan 9, 2024

Oh, I got an idea! What's your language and location set to?

@si-hb
Copy link
Author

si-hb commented Jan 10, 2024

Oh, I got an idea! What's your language and location set to?

EN/CA

@30350n
Copy link
Owner

30350n commented Jan 10, 2024

Do you have your currency set to CAD by any chance?

@si-hb
Copy link
Author

si-hb commented Jan 10, 2024

Do you have your currency set to CAD by any chance?

Yes

@30350n
Copy link
Owner

30350n commented Jan 10, 2024

Ah! That's the problem! TME only supports EUR, USD and GBP. If you still want pricing information for tme you can overwrite the currency for TME only by specifying currency: USD (for example) under the TME section in your suppliers.yaml.

@30350n
Copy link
Owner

30350n commented Jan 10, 2024

I'll add a warning + actual fix for the error tomorrow.

@30350n 30350n self-assigned this Jan 10, 2024
@30350n 30350n added the bug Something isn't working label Jan 10, 2024
@30350n
Copy link
Owner

30350n commented Jan 10, 2024

Got a simple fix for the error for now, but I'd really like to have a warning/interactive resolving as well, but that's going to require some more refactoring ...

@30350n
Copy link
Owner

30350n commented Feb 24, 2024

You'll get an error now, but no interactive resolving. Going to leave this open, because I'll probably still have to do the refactoring eventually ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants