sparkmicro / Ki-nTree

Fast part creation for KiCad and InvenTree
GNU General Public License v3.0
186 stars 33 forks source link

Add supplier jameco electronics #247

Closed hillsandales closed 4 months ago

hillsandales commented 4 months ago

I've added Jameco Electronics as a searchable supplier. I have a bunch of parts I bought from Jameco, and wanted to easily add them to the Inventree database. I've tested it with various part numbers and it seems to work okay. I managed to find the API URL that Jameco's search sends data to when searching on their site. I started with trying to scrape the site with bs4, but they run Cloudflare that protects against scraping. Looking at the request sent when searching a part on their site was the key and works much better. For image download, they also protect, so I used cloudscraper in that case, which gives a slight delay and also retries a few times every delay. It seems to work and downloads the image on the second attempt, if the first attempt times out.

Not sure if anyone buys parts from Jameco, but they offer project kits and parts for hobby projects, so perhaps it'll help someone else.

Let me know what you think. I tried running invoke test and it starts up, but then errors out with an error connecting to the Inventree server. I'm not sure why that is--the GUI works and creates parts on the InvenTree server fine.

eeintech commented 4 months ago

errors out with an error connecting to the Inventree server. I'm not sure why that is--the GUI works and creates parts on the InvenTree server fine.

That happens with testing on main too, @T0jan and I have no idea why this is happening, if one of the run passes for me it is good enough now to release a new version but it is currently a mystery...

eeintech commented 4 months ago

@hillsandales Check the CI, there is some kind of error loading the Jameco settings while launching the GUI

hillsandales commented 4 months ago

@hillsandales Check the CI, there is some kind of error loading the Jameco settings while launching the GUI

I found a few typos. I didn't find them earlier because those sections of the code weren't being run because I had a user config directory already created in $HOME.

I ran through my additions again and fixed the typos. I removed my $HOME config directory to let the program create a new directory and copy files in. Should be okay now, I hope.

I'll submit a separate pull request for both Automation Direct and Jameco suppliers having tested both at this point.