-
Notifications
You must be signed in to change notification settings - Fork 33
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
Digikey v4 + Python3.12 + Digikey Localization #263
base: main
Are you sure you want to change the base?
Conversation
* add setuptools tool prevent incompabilities due to distutils not being available in python3.12 * replace digikey API with fork * bump flet to latest testet version 0.24.1 * bump multiple packages to latest available version
merge changes from main
@eeintech Some of the parameter names have changed for the v4 Digi-Key API causing old cached data to not be usable anymore. At least that's the only case where I can reproduce the errors in the integration tests, so I assume cached data is used there? Do you have a way to update it? |
@T0jan Yes you're right, all the cache data for test sample parts is in tests/files/results.tgz. |
@eeintech I don't really see a reason to support Digikey API v3 going forward. anyone with a user account can automatically use the v4 API and due to the different naming and structuring we would have to have two sets of code.
Just for user convenience I would leave it in as long as it's still supported. EOL is next year. |
@eeintech from my side only the documentation of the rolling release stuff is missing now. However I noticed the Application window can't be dragged across the screen anymore on Ubuntu. Any idea why this could be? |
@T0jan Great effort here, looks like all CI tests are passing too! Yeah it's my fault, I removed the top bar so now only the icon and text areas are draggable... I meant to make the full bar draggable with an extra container but got sidetracked, basically the green zone here is draggable: This can be updated here: Ki-nTree/kintree/gui/views/main.py Line 39 in 345304e
Stretching a container all the way to the settings and quit buttons? If you want to have a shot at it go ahead, else I'll correct that. I have pulled your PR, l hope to review it soon! |
@eeintech I extended the container somewhat hacky now, if you see a more elegant way, let me know. |
I'm still wondering why the inventree authentication fails so often in the tests. maybe some kind of delay is needed to make sure the server is up before it want's to connect 🤔 |
Oh I see you ran it 3 times, yeah I'm not sure either it's quite annoying...
As long as it works I'll be fine with it 😄 |
Bonus addition: Just realized the Settings view is missing the drag area and Close icon... not a big deal but we could add it too. |
AutomationDirectWorks well with parts that exists in their database: [MAIN] AutomationDirect search for PM-0112-020-0
[INFO] No pricing attribute "ordering_attributes" found for "PM-0112-020-0" But there is an KeyError exception thrown with other parts: [MAIN] AutomationDirect search for 1234567890
Future exception was never retrieved
future: <Future finished exception=KeyError('price')>
Traceback (most recent call last):
File "/usr/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/francois/development/Ki-nTree/.venv/lib/python3.12/site-packages/flet_core/page.py", line 944, in wrapper
handler(*args)
File "/home/francois/development/Ki-nTree/kintree/gui/views/main.py", line 454, in perform_pn_search
self.run_search(e)
File "/home/francois/development/Ki-nTree/kintree/gui/views/main.py", line 340, in run_search
part_supplier_info = inventree_interface.supplier_search(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/francois/development/Ki-nTree/kintree/database/inventree_interface.py", line 499, in supplier_search
part_info = automationdirect_api.fetch_part_info(part_number)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/francois/development/Ki-nTree/kintree/search/automationdirect_api.py", line 192, in fetch_part_info
price_per_unit = part[price_key]
~~~~^^^^^^^^^^^
KeyError: 'price' Digi-Key V4It can't find part data, but I know those parts exist: [MAIN] Digi-Key search for TL1105SF160Q
[INFO] Error: Failed to fetch data for "TL1105SF160Q"
[MAIN] Digi-Key search for RK73B1JTTD103J
[INFO] Error: Failed to fetch data for "RK73B1JTTD103J" LCSCAn AttributeError exception is thrown: [MAIN] LCSC search for C497902
[INFO] Warning: API data download failed (HTTP Error)
Future exception was never retrieved
future: <Future finished exception=AttributeError("'NoneType' object has no attribute 'get'")>
Traceback (most recent call last):
File "/usr/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/francois/development/Ki-nTree/.venv/lib/python3.12/site-packages/flet_core/page.py", line 944, in wrapper
handler(*args)
File "/home/francois/development/Ki-nTree/kintree/gui/views/main.py", line 454, in perform_pn_search
self.run_search(e)
File "/home/francois/development/Ki-nTree/kintree/gui/views/main.py", line 340, in run_search
part_supplier_info = inventree_interface.supplier_search(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/francois/development/Ki-nTree/kintree/database/inventree_interface.py", line 493, in supplier_search
part_info = lcsc_api.fetch_part_info(part_number)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/francois/development/Ki-nTree/kintree/search/lcsc_api.py", line 69, in fetch_part_info
part = part.get('result', None)
^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get' |
@T0jan For Digi-Key V4, I'm a little confused... the authentication works but then the part data received didn't match at all your changes in this PR... so I thought "it must be because it is getting data from the v3 API" so I created another app with only V4 enabled: But then I'm getting authentication issues now: Exception when calling product_details_with_http_info: (401)
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'Date': 'Fri, 25 Oct 2024 20:21:46 GMT', 'Content-Type': 'application/json', 'Content-Length': '228', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '', 'Access-Control-Allow-Headers': 'origin, x-requested-with, accept, content-type, authorization,x-digikey-client-id, x-digikey-locale-site, x-digikey-locale-language, x-digikey-locale-currency, x-digikey-locale-shiptocountry, x-digikey-customer-id', 'Access-Control-Max-Age': '3628800', 'Access-Control-Allow-Methods': 'GET, POST', 'X-DIGIKEY-REQUEST-ID': 'be3c5a7d-c37b-48e7-8396-949e6c6855c4', 'Set-Cookie': 'TS012a951d=01460246b6f4313327ce3b5f931acf991d9d2efa9c77187afad62dd17aed54331614c4e3a640a9ab1e40d01eed313591c46d4a0397; Path=/; Secure; HTTPOnly'})
HTTP response body: {"ErrorResponseVersion":"3.0.0.0","StatusCode": 401,"ErrorMessage":"Invalid Client-Id","ErrorDetails":"X-DIGIKEY-Client-Id invalid for requested resource","RequestId":"be3c5a7d-c37b-48e7-8396-949e6c6855c4","ValidationErrors":[]} This is the JSON data I get from a DK app with both V4 and V3 Product Information enabled: I have confirmed this format is V3 data, not V4. So I really need to see you app configuration, because I'm not able to test it out so far 😄 |
@eeintech have you updated the digikey-api to the 3.12 fork? On my setups I hadn't to change anything else for it to work basically out of the box. The other things seem easy to fix, but I probably will only get to it on Monday |
@T0jan This is what I installed: $ pip freeze | grep digikey
digikey-api @ git+https://github.com/hurricaneJoef/digikey-api.git@e4418f4aeb1c49c1e9b6c11f07e0b14567a43099 What do you have? |
@eeintech in my 3.12 venv:
interestingly the 3.10 venv reports it as the base version for some reason 🤔
So the only difference is you checked out a commit and I the branch, but that shouldn't make a difference. Have you tried to set up a new virtual environment and checked if it works there? edit: I also tested with the commit you used and the parts you mentioned not working above. Both works on my side... |
a delay doesn't help 😅 the two other crashes and the drag bar for the settings view is done, still no idea what the digikey issue is tho. It works for me on three different machines with two different tokens. |
@T0jan Not sure how you got there, this sha doesn't seem to exist in this repo? $ pip freeze | grep digikey
digikey-api @ git+https://github.com/hurricaneJoef/digikey-api.git@e4418f4aeb1c49c1e9b6c11f07e0b14567a43099 I pulled the latest changes and recreated an environment (btw you are still not including Python 3.12 and missing the I will continue testing more later when I get more time, great job so far 👍 |
@eeintech ha I knew I forgot one of the requirements, should be fixed now.
The sha could be user specific, I got this by just using the link to the master.zip which is also in the requirements file:
Maybe there is a different handling of the |
and some small bug fixes