Giter Club home page Giter Club logo

digikey-inventree-integration's Introduction

Digikey-Inventree-Integration

Test Results PyPI version

A CLI to ease importing Digikey parts into an Inventree instance.

Setup

Installation

Install from Pypi

pip install inventree_digikey_integration

Install from source

  1. Install poetry
  2. Clone the repo git clone [email protected]:EUdds/digikey-inventree-integration.git
  3. cd digikey-inventree-integration
  4. poetry install

Configuration

Create a config.ini file according to the template and specify it's location with the -c <path> flag

[DIGIKEY_API]
CLIENT_ID=
CLIENT_SECRET=

[INVENTREE_API]
URL=<URL to the inventree instance>
USER=
PASSWORD=

Usage

Invoke the cli by running import_digikey_parts

usage: import_digikey_parts [-h] [-y] [-c CONFIG] query_numbers [query_numbers ...]

Import Digikey part numbers into InvenTree

positional arguments:
  query_numbers         Part number(s) to import

optional arguments:
  -h, --help            show this help message and exit
  -y, --yes             Bypass user prompts and assume "yes"
  -c CONFIG, --config CONFIG
                        Path to config file

Testing

Run the test suite by running poetry run pytest

digikey-inventree-integration's People

Contributors

benpayne avatar doesnotcompete avatar eudds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

digikey-inventree-integration's Issues

Failure to download image from Digikey

I have recently setup inventree and found this very helpful tool. Been playing with it today and all is working great, except downloading of images from digikey. I see the following error, but on inspection I see that it's failing to download the image. It's getting a 403 error code. I have downloaded the image from a browser with no issues. I thought maybe I had some cached authentication in the browser cache. So I tried a browser that I've not used to log into digikey and it also downloaded just fine. So a bit puzzled why the script would fail with a 403.

Trying URL https://mm.digikey.com/Volume0/opasdata/d220001/medias/images/5565/MFG_PI_5_HERO.jpg
<Response [403]>
ERROR: Request code is 403
Traceback (most recent call last):
  File "/usr/local/Cellar/[email protected]/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/[email protected]/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/bpayne/wip/inventory/Digikey-Inventree-Integration/inventree_digikey/__main__.py", line 23, in <module>
    add_digikey_part(dkpart)
  File "/Users/bpayne/wip/inventory/Digikey-Inventree-Integration/inventree_digikey/Inventree.py", line 27, in add_digikey_part
    inv_part = create_inventree_part(dkpart)
  File "/Users/bpayne/wip/inventory/Digikey-Inventree-Integration/inventree_digikey/Inventree.py", line 81, in create_inventree_part
    upload_picture(dkpart, part)
  File "/Users/bpayne/wip/inventory/Digikey-Inventree-Integration/inventree_digikey/Inventree.py", line 121, in upload_picture
    invPart.uploadImage(img_file)
  File "/Users/bpayne/wip/inventory/venv/lib/python3.9/site-packages/inventree/base.py", line 543, in uploadImage
    raise TypeError(f"uploadImage called with invalid image: '{image}'")
TypeError: uploadImage called with invalid image: '-1'

Can't import parts

Python 3.11.8

PS C:\Users\jacob> import_digikey_parts -c config.ini AS3935-BQFTCT-ND
Found AS3935-BQFT - Would you like to use this name (y/n)
> y
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\jacob\AppData\Local\Programs\Python\Python311\Scripts\import_digikey_parts.exe\__main__.py", line 7, in <module>
  File "C:\Users\jacob\AppData\Local\Programs\Python\Python311\Lib\site-packages\inventree_digikey_integration\__main__.py", line 54, in main
    num_parts = import_parts(args)
                ^^^^^^^^^^^^^^^^^^
  File "C:\Users\jacob\AppData\Local\Programs\Python\Python311\Lib\site-packages\inventree_digikey_integration\__main__.py", line 48, in import_parts
    import_digikey_part(num, config, not args.yes)
  File "C:\Users\jacob\AppData\Local\Programs\Python\Python311\Lib\site-packages\inventree_digikey_integration\Inventree.py", line 13, in import_digikey_part
    return add_digikey_part(dkpart, config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jacob\AppData\Local\Programs\Python\Python311\Lib\site-packages\inventree_digikey_integration\Inventree.py", line 17, in add_digikey_part
    dk = get_digikey_supplier(config)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jacob\AppData\Local\Programs\Python\Python311\Lib\site-packages\inventree_digikey_integration\Inventree.py", line 50, in get_digikey_supplier
    dk = Company.create(
         ^^^^^^^^^^^^^^^
  File "C:\Users\jacob\AppData\Local\Programs\Python\Python311\Lib\site-packages\inventree\base.py", line 172, in create
    return cls(api, data=response)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jacob\AppData\Local\Programs\Python\Python311\Lib\site-packages\inventree\base.py", line 47, in __init__
    pk = data.get('pk', None)
         ^^^^^^^^
AttributeError: 'list' object has no attribute 'get'

query_number no present ?

Hi
i just install yout plugin. Thanks for this work.
But i have this issue :
`$ import_digikey_parts.exe -c config.ini 4116R-1-151LF
Traceback (most recent call last):

File "c:\users...\appdata\local\programs\python\python39\lib\site-packages\inventree_digikey_integration_main_.py", line 44, in main
if len(args.query_number) == 1:
`
an idea for resolve it ?
Bests

How to install with Docker

I have been trying for three weeks to get this running w/ the inventree production docker-compose (https://github.com/inventree/InvenTree/blob/master/docker/production/docker-compose.yml) and have been failing miserably, the plugins page of Inventree indicates that it can't find the 'inventree' package or some other ones.

I'm dying here.

Any chance I could get some idiot-proof instructions on how to get this working w/ the docker-compose?
Where should this plugin reside?
What about it's requirements.txt file?
What URL should I put in the config.ini file? localhost:1337? or localhost:8000? or something else?

invPart.uploadImage(img_file) not working, seems a function is missing

Hi,

in your function:

def upload_picture(dkpart: DigiPart, invPart):
    if dkpart.picture is not None:
        img_file = ImageManager.get_image(dkpart.picture)
        invPart.uploadImage(img_file)
        ImageManager.clean_cache()

the invPart.uploadImage(img_file) is not working. do you have any hints?

Br Martijn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.