Giter VIP home page Giter VIP logo

ki-ntree's People

Contributors

ad1217 avatar cdwilson avatar eeintech avatar konkers avatar martonmiklos avatar randrej avatar shxshxshxshx avatar spike77453 avatar t0jan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ki-ntree's Issues

Actions for pushing to PyPI

We should set up Github Actions for pushing to PyPI. I propose we set up the actions in the following way:

  1. The tests and style check are run
  2. The package is pushed to Test PyPI
  3. The package is pushed to actual PyPI

We need to decide on a source of truth for the package version. By default, Poetry expects the version to be in the pyproject.toml file. This can conflict with the version from the git tag.

In the near future, when poetry 1.2.0 drops, we can switch to poetry-version-plugin, which uses the version from the latest git tag.

Currently, we can do one of the following things:

Automatically set the version from git tag

This is similar to poetry-version-plugin. In the Github action that runs on tag, we use sed to replace the version variable in the pyproject.toml file before building. This guarantees that the version built is always correct when we push the git tag. The downside is that, when you want to build the package locally, you need to manually specify the version. This package won't usually be built locally though, and every version on PyPI will be deployed by Github Actions, but it adds another step to local building. Who may want to build the package locally, anyway? A couple of us contributors, and maybe some Linux package maintainers. I think this is a sane trade-off.

Check if the tag version and pyproject.toml version match

We can also expect that the version in pyproject.toml is always correct, and if it mismatches the tag version - an error is thrown and the package isn't pushed to PyPI. The downside to this is that if you, for example, have v0.4.13 in pyproject.toml, but you tagged the project with v0.5.0, the process fails and you can't fix the issue without force-pushing which is poor form. You'd have to post the fix as v0.5.1 or do that force push.

I vote for the first option.

PyPI and test PyPI

I think the easiest way to do this is if I set the actions up on my own fork, and test on 'Test PyPI', with my own tokens. Maybe even test the first version on PyPI.

When I'm certain everything works properly, I'll transfer over the packages on PyPI and Test PyPI to you to maintain and own. You need to create accounts on PyPI and Test PyPI, and also to generate API tokens for pushing afterwards. If you plan on maintaining more packages, you should have one API key per package. You need to give me your PyPI username so that I can transfer the packages when I'm done.

Symbol and footprint upload to KiCad fails

I'm facing an issue I'm not 100% sure if it is related to my lack of understandig data transfer from Ki-nTree to Kicad, some misconfiguration or simply a bug. Error message looks like:

[MAIN] Adding part to KiCad←[0m
[KCAD] library_path: C:/Program Files/KiCad/share/kicad/library\Transistor_Array.lib
[KCAD] Number of parts in library Transistor_Array.lib: 20
←[91m[INFO] Error: Failed to add part to KiCad (incomplete InvenTree data)←[0m

My path variables are:
Symbol libraries path folder: C:\Program Files\KiCad\share\kicad\library
Footprint libraries folder: C:\Program Files\KiCad\share\kicad\modules
Symbol templates folder: C:\Users\user\AppData\Roaming\Python\Python39\site-packages\kintree\kicad\templates\

My kicad.yaml is untouched, not representing these changes set in GUI settings.

I tried with different part numbers and different suppliers and attached the complete console output:
Part: C20917 Supplier: LCSC
Part: C9667 Supplier: LCSC
880-1096-ND Supplier: DigiKey
296-39101-1-ND Supplier: DigiKey
493-13632-1-ND Supplier: DigiKey

Many thanks

debug_log.txt
s!

[Feature Request] Automatically create missing sub-category

To ease organising at component creation in Inventree, it would be beneficial to have Ki-nTree automatically create a new sub-category (or category even) if it's not found in Inventree. This would be useful for times when the existing categories does not match, and one has not been created in Inventree yet.

Turning this into a Python package?

If I were to try turning this into a Python package that can be pushed to PyPI or at least installed via pip, would this be a welcome changeset? I'd make a pyproject.toml and setup.py.

How would we benefit from this? I could then make a package in Arch Linux's AUR, other people could package it for other distros, a large number of people could even just do a pip install and the package would run.

Error: Symbol libraries were not found

I'm trying to get Ki-nTree working for the first time, but I'm getting the following error when I click "Submit":

image

image

Here is my user_files/kicad.yaml:

KICAD_ENABLE: true
KICAD_FOOTPRINTS_PATH: /Users/chris/KiCad/Ki-nTree/footprints/
KICAD_SYMBOLS_PATH: /Users/chris/KiCad/Ki-nTree/symbols/
KICAD_TEMPLATES_PATH: /Users/chris/KiCad/Ki-nTree/templates/

These folders exist on my system:

$ ls /Users/chris/KiCad/Ki-nTree/
footprints symbols    templates

Any suggestions for how to figure out what's going wrong?

AttributeError: 'NoneType' object has no attribute 'pk'

Installed in pipenv because the aur package depends on packages i cant seem to find, python-inventree?

Full traceback:

❯ kintree

[MAIN]  Connecting to Inventree server
[TREE]  Successfully connected to InvenTree server (ENV=TESTING)

--------------------

[MAIN]  Using Digi-Key cached data for 2616-VZH100M1CTR-0406S-ND

[MAIN]  Creating part in Inventree
[INFO]  Category: "Capacitors"
[INFO]  Subcategory: "Aluminium"
[INFO]  User Category: "Capacitors"
[INFO]  User Subcategory: "Aluminium"
[INFO]  Warning: Parameter "Temperature Coefficient" not found in supplier data
Traceback (most recent call last):
  File "/home/joe/.local/share/virtualenvs/joe-xljV_iqz/bin/kintree", line 8, in <module>
    sys.exit(main())
  File "/home/joe/.local/share/virtualenvs/joe-xljV_iqz/lib/python3.8/site-packages/kintree/kintree_gui.py", line 1164, in main
    new_part, part_pk, part_data = inventree_interface.inventree_create(part_info=part_info,
  File "/home/joe/.local/share/virtualenvs/joe-xljV_iqz/lib/python3.8/site-packages/kintree/database/inventree_interface.py", line 372, in inventree_create
    subcategory_pk = inventree_api.get_inventree_category_id(category_name=subcategory_name,
  File "/home/joe/.local/share/virtualenvs/joe-xljV_iqz/lib/python3.8/site-packages/kintree/database/inventree_api.py", line 53, in get_inventree_category_id
    cprint(f'[TREE]\t{item.getParentCategory().pk} ?= {parent_category_id}', silent=settings.HIDE_DEBUG)
AttributeError: 'NoneType' object has no attribute 'pk'

Not exactly sure if its an issue with just this part or others, thank you for making this software though! this should automate a lot!

Add Supplier Link field

Now that inventree/InvenTree#1417 has been merged and InvenTree supports ManufacturerParts, I'm wondering if you would be open to adding a separate "Supplier Link" field which uses product_url as the default value:

image

This would map to the existing Supplier Link field in InvenTree:

image

The other requested change would be to change the existing Datasheet field to map to the new ManufacturerPart Link in InvenTree:

image

image

What do you think?

Add multiple paths to KiCAD templates and dropdown in KiCad window

Thanks for a really great tool! I've managed to get this working but not without a couple of minor hiccups I thought it might be helpful to share. I've done a system-wide install on macOS Big Sur 11.6. The processor is an M1, which may be important to this issue because I've found there's very little support for installing certain common python packages like numpy and scipy on M1 machines. But I don't have any concrete reason why it would cause the issues I've had...

Anyway, to the issues I found:

  1. I had to use pip3 install -U kintree rather than pip install -U kintree. That may just be because of the way I have python and pip installed on my machine. Probably not your problem but I mention it for completeness.
  2. tkinter was not installed so I had to brew install that. From what I gather that should have been included in the python3.9 installation but for some reason was not. Again, probably not your problem.
  3. When I first ran the kintree command, it told me it couldn't find the 'images/logo.png' file called in line 913 of kintree_gui.py. I went looking to see where this file might be but I couldn't see a directory called images or a file called logo.png anywhere nearby. I figured it was probably just decorative so I just commented it out. The GUI then launched nicely.
  4. I put in my newly acquired Mouser and DigiKey API keys and successfully searched for some parts on each service. However, they wouldn't add to the KiCAD library I had specified. The error in Terminal was that it couldn't find the KiCAD templates files. I had seen these back in the homebrew directory in /opt/homebrew/lib/python3.9/site-packages/kintree/kicad/templates/ so I found the kicad.yaml file in my User folder and put in the fully resolved path. It now successfully adds these parts to my KiCAD library and I'm very happy with this!

I don't know if I'm doing anything wrong but at the moment if there is a unique footprint associated with the part, I presume I have to download that file separately and tell kintree where it is so they can be associated. I've used Library Loader on Windows before and it fetches the footprint and 3D model (if they're available) alongside the symbol. Am I missing something in kintree? Or would this information not be quite so straightforward for kintree to obtain alongside the rest of the product information?

Thanks for your time!

Automatically creating categories and parameters in InvenTree

When I add a new new part type in Ki-nTree, I get the following errors if the category and parameters don't already exist in InvenTree:

[MAIN]  Creating part in Inventree
[INFO]  Category: "Mechanicals"
[INFO]  Subcategory: "Switch"
[INFO]  User Category: "Mechanicals"
[INFO]  User Subcategory: "Switch"
[INFO]  Warning: Parameter "Between Board Height" not found in supplier data
[INFO]  Warning: Parameter "Screw, Thread Size" not found in supplier data

[TREE]  Warning: Subcategory "Switch" does not exist
[ERROR] Categories (Mechanicals - Switch) does not exist in InvenTree
[MAIN]  Creating parameters
[TREE]  Error: Parameter template "Interface Type" does not exist
[TREE]  Error: Parameter template "Locking" does not exist
[TREE]  Error: Parameter template "Mating Height" does not exist
[TREE]  Error: Parameter template "Mounting Type" does not exist
[TREE]  Error: Parameter template "Number of Contacts" does not exist
[TREE]  Error: Parameter template "Number of Rows" does not exist
[TREE]  Error: Parameter template "Package Height" does not exist
[TREE]  Error: Parameter template "Pitch" does not exist
[TREE]  Error: Parameter template "Temperature Range" does not exist
[TREE]  Error: Parameter template "Value" does not exist
[TREE]  Error: Parameter template "Frequency" does not exist
[TREE]  Error: Parameter template "Orientation" does not exist
[TREE]  Error: Parameter template "Polarity" does not exist
[TREE]  Error: Parameter template "Shielding" does not exist
[TREE]  Error: Parameter template "Symbol" does not exist
[TREE]  Error: Parameter template "Footprint" does not exist
[TREE]  Warning: The following parameters were skipped:
--->    Interface Type
--->    Locking
--->    Mating Height
--->    Mounting Type
--->    Number of Contacts
--->    Number of Rows
--->    Package Height
--->    Pitch
--->    Temperature Range
--->    Value
--->    Frequency
--->    Orientation
--->    Polarity
--->    Shielding
--->    Symbol
--->    Footprint

I can create these manually in InvenTree (which is what I've been doing for Category), but I'm wondering if there is a more "automatic" way to populate these parameters into InvenTree so that I don't have to add them manually each time I add a new part type.

Make the program work when your inventree instance has a self-signed cert

The Python Inventree module, used here to communicate with Inventree, uses requests for communication. Requests uses python-provided CA certificates by default, which means your self-signed cert won't work even if you installed it with trust anchor <cert>.crt. The solution is to export the env variable REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt before importing the inventree package, which tells requests to use Linux system CA certs instead. This should be done on Linux only, ignored for other platforms.

Do you agree? Shall I implement this?

Method is_new_part returns wrong part PK when checking if there is a new manufacturer part

  • The method iterates through all the part in the list of parts

  • inside the loop, when no match is found between parameters or between name and description, the method checks if there is a new manufacturer part.
    image

  • In the case that the MPN already exist in the database, compare is set to true and the loop breaks, returning the pk of the first element in the part_list.
    image

Expected behavior:

  • The method should return the pk of the part with the matching manufacturing part number

Crash when clicking "Check SnapEDA" button

image

Traceback (most recent call last):
  File "/Users/chris/Projects/Ki-nTree/kintree_gui.py", line 1128, in <module>
    main()
  File "/Users/chris/Projects/Ki-nTree/kintree_gui.py", line 959, in main
    symbol, template, footprint = user_defined_symbol_template_footprint(categories, part_info['manufacturer_part_number'])
  File "/Users/chris/Projects/Ki-nTree/kintree_gui.py", line 704, in user_defined_symbol_template_footprint
    snapeda_window(part_number)
  File "/Users/chris/Projects/Ki-nTree/kintree_gui.py", line 263, in snapeda_window
    snapeda_event, snapeda_values = snapeda_window.read()
  File "/Users/chris/.anyenv/envs/pyenv/versions/inventree/lib/python3.9/site-packages/PySimpleGUI/PySimpleGUI.py", line 8200, in read
    results = self._read(timeout=timeout, timeout_key=timeout_key)
  File "/Users/chris/.anyenv/envs/pyenv/versions/inventree/lib/python3.9/site-packages/PySimpleGUI/PySimpleGUI.py", line 8266, in _read
    self._Show()
  File "/Users/chris/.anyenv/envs/pyenv/versions/inventree/lib/python3.9/site-packages/PySimpleGUI/PySimpleGUI.py", line 8027, in _Show
    StartupTK(self)
  File "/Users/chris/.anyenv/envs/pyenv/versions/inventree/lib/python3.9/site-packages/PySimpleGUI/PySimpleGUI.py", line 13704, in StartupTK
    _convert_window_to_tk(window)
  File "/Users/chris/.anyenv/envs/pyenv/versions/inventree/lib/python3.9/site-packages/PySimpleGUI/PySimpleGUI.py", line 13576, in _convert_window_to_tk
    PackFormIntoFrame(window, master, window)
  File "/Users/chris/.anyenv/envs/pyenv/versions/inventree/lib/python3.9/site-packages/PySimpleGUI/PySimpleGUI.py", line 12917, in PackFormIntoFrame
    photo = tk.PhotoImage(file=element.Filename)
  File "/Users/chris/.anyenv/envs/pyenv/versions/3.9.1/lib/python3.9/tkinter/__init__.py", line 4062, in __init__
    Image.__init__(self, 'photo', name, cnf, master, **kw)
  File "/Users/chris/.anyenv/envs/pyenv/versions/3.9.1/lib/python3.9/tkinter/__init__.py", line 4007, in __init__
    self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize data in image file "/Users/chris/Projects/Ki-nTree/search/images/rc0402fr-07330rl_symbol.png"

Building kintree_gui on macOS

Just documenting some issues I ran into for anybody else trying to run invoke build on macOS.

First issue:

$ invoke build
[MAIN]  Cleaning project directory
[MAIN]  Building Ki-nTree into "dist" directory
Encountered a bad command exit code!

Command: 'pyinstaller --clean --onefile -p search/digikey_api/ -p kicad/ -p database/inventree-python/ kintree_gui.py'

Exit code: 1

Stdout:



Stderr:

    raise IOError(msg)
OSError: Python library not found: Python3, libpython3.9.dylib, libpython3.9m.dylib, Python, .Python
    This would mean your Python installation doesn't come with proper library files.
    This usually happens by missing development package, or unsuitable build parameters of Python installation.

    * On Debian/Ubuntu, you would need to install Python development packages
      * apt-get install python3-dev
      * apt-get install python-dev
    * If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)

I was able to fix this by rebuilding python with PYTHON_CONFIGURE_OPTS="--enable-framework". I'm using pyenv to install python, so in my case, the full command to build python with a working tkinter was:

brew install tcl-tk
env \
  PATH="$(brew --prefix tcl-tk)/bin:$PATH" \
  LDFLAGS="-L$(brew --prefix tcl-tk)/lib" \
  CPPFLAGS="-I$(brew --prefix tcl-tk)/include" \
  PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" \
  CFLAGS="-I$(brew --prefix tcl-tk)/include" \
  PYTHON_CONFIGURE_OPTS="--enable-framework --with-tcltk-includes='-I$(brew --prefix tcl-tk)/include' --with-tcltk-libs='-L$(brew --prefix tcl-tk)/lib -ltcl8.6 -ltk8.6'" \
  pyenv install 3.9.1

Second issue:

$ dist/kintree_gui 
Python path configuration:
  PYTHONHOME = '/var/folders/sl/lkpnkgr9321dcq8rnd9mkc4m0000gn/T/_MEIuVbya9'
  PYTHONPATH = (not set)
  program name = '/Users/chris/Projects/Ki-nTree/dist/kintree_gui'
  isolated = 0
  environment = 0
  user site = 0
  import site = 0
  sys._base_executable = '/Users/chris/Projects/Ki-nTree/dist/kintree_gui'
  sys.base_prefix = ''
  sys.base_exec_prefix = ''
  sys.platlibdir = 'lib'
  sys.executable = '/Users/chris/Projects/Ki-nTree/dist/kintree_gui'
  sys.prefix = ''
  sys.exec_prefix = ''
  sys.path = [
    '/var/folders/sl/lkpnkgr9321dcq8rnd9mkc4m0000gn/T/_MEIuVbya9/base_library.zip',
    '/var/folders/sl/lkpnkgr9321dcq8rnd9mkc4m0000gn/T/_MEIuVbya9',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
LookupError: unknown encoding: utf-8

Current thread 0x000000011ae64e00 (most recent call first):
<no Python frame>

This looks to be an issue caused by the typing package being installed:

pip uninstall typing
invoke clean
invoke build

Third issue:

$ dist/kintree_gui 
[INFO]  Warning: Failed to load Digi-Key configuration
[INFO]  Warning: Failed to load InvenTree configuration
[INFO]  Warning: Failed to load KiCad configuration
[ERROR] File /Users/chris/Projects/Ki-nTree/dist/config/user_files/kicad.yaml does not exists!
[INFO]  Warning: Failed to load Digi-Key configuration
[INFO]  Warning: Failed to load InvenTree configuration
[INFO]  Warning: Failed to load KiCad configuration

[ERROR] Some Ki-nTree configuration files seem to be missing

dist/config seemed to have a different structure than config:

$ ls dist/config
categories.yaml         digikey_categories.yaml inventree_dev.yaml      inventree_test.yaml     kicad_map.yaml          parameters_filters.yaml version.yaml
digikey_api.yaml        digikey_parameters.yaml inventree_prod.yaml     kicad.yaml              parameters.yaml         user_files
$ ls config
config_interface.py digikey             inventree           kicad               settings.py         templates           user_files          version.yaml

Overwriting the dist/config with the config directory fixed the issues for me.

Crash when retrieving certain LCSC part numbers

Have just started to use Inventree (and Ki-nTree) to populate my inventory system, and have come across a crash on a few of the LCSC parts. It looks like it just needs a type check before calling len against it.

[MAIN] LCSC search for C480516
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\Python39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "D:\Projects\env-kintree\Scripts\kintree.exe_main
.py", line 7, in
File "d:\projects\env-kintree\lib\site-packages\kintree\kintree_gui.py", line 980, in main
part_supplier_info = inventree_interface.supplier_search(values['supplier'], values['part_number'])
File "d:\projects\env-kintree\lib\site-packages\kintree\database\inventree_interface.py", line 336, in supplier_search
part_info = lcsc_api.fetch_part_info(part_number)
File "d:\projects\env-kintree\lib\site-packages\kintree\search\lcsc_api.py", line 87, in fetch_part_info
for parameter in range(len(part[parameter_key])):
TypeError: object of type 'NoneType' has no len()
(env-kintree)

Configuration options for part data

@eeintech just wanted to let you know about a couple minor changes I've hacked into my local copy of to Ki-nTree to tailor it for my own usage, and see if you'd be interested in a PR to make them into configuration options in the settings.

  1. For part description, I use the detailed_description from Digi-Key instead of product_description
  2. For keywords, I use the product_description instead of inventree_part['description']
  3. For datasheet, I use the product_url since this ends up being the URL on the SupplierPart page in InvenTree.

image

Also, once inventree/InvenTree#1417 gets merged in, I'd like to add the ability for Ki-nTree to push both the primary_datasheet into the ManufacturerPart and the product_url into the SupplierPart.

It would be ideal if the ManufacturerPart in InvenTree eventually supports separate URLs for the Manufacturer's product page vs. the datasheet so that we can have both links available on the MPN. For example, if we look at 497-11767-ND:

ManufacturerPart

SupplierPart

ConnectionResetError: [Errno 104] Connection reset by peer

Hi,

I have been able to setup an InvenTree server on AWS and able to connect to it through Ki-ntree (V.0.3.2). I am also able to use Digikey's API ID. InvenTree details are given below:

screen

The problem is ... once in a while I am able to create parts using Ki-nTree ... but "most of the times" when I try to create a part through Ki-nTree, I am getting the below error (sorry for the lengthy error message):

`ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/zinka/Dropbox/HCS/Enginering/Ki-nTree/env-kintree/lib/python3.8/site-packages/requests/models.py", line 753, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "/home/zinka/Dropbox/HCS/Enginering/Ki-nTree/env-kintree/lib/python3.8/site-packages/urllib3/response.py", line 576, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/home/zinka/Dropbox/HCS/Enginering/Ki-nTree/env-kintree/lib/python3.8/site-packages/urllib3/response.py", line 541, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/usr/lib/python3.8/contextlib.py", line 131, in exit
self.gen.throw(type, value, traceback)
File "/home/zinka/Dropbox/HCS/Enginering/Ki-nTree/env-kintree/lib/python3.8/site-packages/urllib3/response.py", line 455, in _error_catcher
raise ProtocolError("Connection broken: %r" % e, e)
urllib3.exceptions.ProtocolError: ("Connection broken: ConnectionResetError(104, 'Connection reset by peer')", ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/zinka/Dropbox/HCS/Enginering/Ki-nTree/kintree_gui.py", line 1106, in
main()
File "/home/zinka/Dropbox/HCS/Enginering/Ki-nTree/kintree_gui.py", line 951, in main
new_part, part_pk, part_data = inventree_interface.inventree_create(part_info=part_info,
File "/home/zinka/Dropbox/HCS/Enginering/Ki-nTree/database/inventree_interface.py", line 306, in inventree_create
subcategory_pk = inventree_api.get_inventree_category_id(category_name=subcategory_name,
File "/home/zinka/Dropbox/HCS/Enginering/Ki-nTree/database/inventree_api.py", line 36, in get_inventree_category_id
part_categories = PartCategory.list(inventree_api)
File "/home/zinka/Dropbox/HCS/Enginering/Ki-nTree/database/inventree-python/inventree/base.py", line 69, in list
response = api.get(cls.URL, params=params, **kwargs)
File "/home/zinka/Dropbox/HCS/Enginering/Ki-nTree/database/inventree-python/inventree/api.py", line 348, in get
response = self.request(url, method='get', **kwargs)
File "/home/zinka/Dropbox/HCS/Enginering/Ki-nTree/database/inventree-python/inventree/api.py", line 202, in request
response = methods[method](
File "/home/zinka/Dropbox/HCS/Enginering/Ki-nTree/env-kintree/lib/python3.8/site-packages/requests/api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "/home/zinka/Dropbox/HCS/Enginering/Ki-nTree/env-kintree/lib/python3.8/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/home/zinka/Dropbox/HCS/Enginering/Ki-nTree/env-kintree/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/home/zinka/Dropbox/HCS/Enginering/Ki-nTree/env-kintree/lib/python3.8/site-packages/requests/sessions.py", line 697, in send
r.content
File "/home/zinka/Dropbox/HCS/Enginering/Ki-nTree/env-kintree/lib/python3.8/site-packages/requests/models.py", line 831, in content
self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''
File "/home/zinka/Dropbox/HCS/Enginering/Ki-nTree/env-kintree/lib/python3.8/site-packages/requests/models.py", line 756, in generate
raise ChunkedEncodingError(e)
requests.exceptions.ChunkedEncodingError: ("Connection broken: ConnectionResetError(104, 'Connection reset by peer')", ConnectionResetError(104, 'Connection reset by peer'))`

Could you please let me know if it possible to rectify this issue? Apart from Ki-nTree, don't have any issues in using InvenTree itself through a browser.

Can't get LCSC parts

Hello,
I can't get any LCSC part. Error is too generic, so I tried to debug:

@timeout(dec_timeout=30)
def search_timeout():
url = 'https://wwwapi.lcsc.com/v1/products/detail?product_code=' + part_number
response = requests.get(url)
return response.json()

The request.get(url) is hitting a 404 :-(, however if paste the same url string in a browser I can get the full page.

Maybe they don't like anymore our user agent?

Thanks for your wonderful piece of software

Missing Instruction

I could not find the step telling me to run kintree_setup_inventree prior to being able to import parts to InvenTree.
I ran through a lot of "category does not exist" problems before I started combing through code.
It would be very helpful to have this step outlined in the setup directions.

Option to not open InvenTree

An option to disable InvenTree opening after adding a new part would be helpful when entering a large volume of parts at a time.

Mouser import to InvenTree missing parameter data.

When I am importing data for a part from mouser into InvenTree, it seems as if Ki-nTree fetches Parameter data but it does not insert it (properly) into InvenTree.

From the log it looks like it found (some of) the matching parameters and also populates them:

[MAIN]  Creating parameters
[INFO]  Success: The following parameters were created:
--->    Value
--->    Frequency
--->    Interface Type
--->    Locking
--->    Mating Height
--->    Mounting Type
--->    Number of Contacts
--->    Number of Rows
--->    Orientation
--->    Package Height
--->    Pitch
--->    Polarity
--->    Shielding
--->    Temperature Range

But when I look at the InvenTree page of the created part, all of them are empty (= having a dash '-' as value).
image

When I run the same exact part through the Digi-Key importer, (some of) the parameters get populated:
image

I Also get some [INFO] Warning: Failed to compare part with database - I don't know if that is related or not.

Let me know if I can provide more info.

I am running Ki-nTree from the GIT repo (most recent commit)

commit ef1dd4649c760b311bc58bd63687069be36df850 (HEAD -> main, tag: 0.4.8, origin/main, origin/HEAD)
Merge: ea93ccb 8fcd85c
Author: Francois <[email protected]>
Date:   Fri Nov 26 15:35:37 2021 -0500

FR Price breaks

Would it not be useful to import pricing information from mouser, lcsc and digikey into InvenTree?

I do know InvenTree's pricing system is currently being overhauled, so this would possibly be a FR for when 0.9 releases.

Support hierarchical categories

Ki-nTree is designed with the idea of a top level parent category, and then a subcategory. This is a little restrictive and doesn't match how my categories are set up in Inventree.

I've prepared a patch to implement hierarchical categories for the setup function and the user category select screen, but before proposing a PR I thought I'd open an Issue for discussion.

I don't understand why Digikey's categories are merged with the user's category list in this screen, nor the rationale behind integration of categories with Kicad. I think there are a few valid options for how these could be handled, so if you are open to adding this feature could you let me know how you'd like it integrated best?

Thanks.

Migrating to improved GUI framework

This may be an unpopular idea, and I'm fully aware why. I'm not even sure it does make sense at this point, but still, it's worth considering.

I saw that you considered migrating the project to PySimpleGUIQt. This does make sense, but that project is really in its infancy. Since the GUI part of this project isn't too complex, it would make sense to port the whole thing into raw PySide2.

The benefits?

It's a much more polished library, with fewer bugs, and is a thin layer over Qt which is pretty solid. If you decide to add some more advanced functionality to this program, it's going to be much easier to do in PySide2/Qt than in a PySimpleGUI derivative. It's not too much work to port the app (because it's small), and it's not much harder to use generally, while allowing for improved functionality.

Actual issues solved

Input field behavior on the current version (with PySimpleGUI) is abysmal: if you select text and paste, the selected text doesn't get overwritten. Ctrl + A doesn't work. All this works beautifully in PySide2.

License for generated parts

Ki-nTree is licensed under the GPL-3.0 License, including the KiCad templates as far as I can tell. I'm not a lawyer, but I think this means that any symbols created from these templates also must be published under GPL-3.0 License.

From the GPL FAQ:

More generally, when a program translates its input into some other form, the copyright status of the output inherits that of the input it was generated from.

I think this means that it's not possible to redistribute the generated symbols under a different license.

If this was not intentional, would you consider changing the license for the included KiCad templates and any other "inputs" so that the outputs from Ki-nTree can be redistributed under any license?

[Bug] Crash during invenTree part creation, only halfway created parts

I'm trying to create parts in invenTree from digikey. Unfortunately I get a crash during part creation, which leaves me with parts that are successfully created and have basic info like name, image, description and keywords but are missing any parameters, supplier information, etc.

Here's a log of a part creation:

[MAIN]  Connecting to Inventree server←[0m
←[92m[TREE]     Successfully connected to InvenTree server (ENV=TESTING)←[0m

--------------------
←[95m
[MAIN]  Using Digi-Key cached data for STS4DNFS30L←[0m
←[95m
[MAIN]  Creating part in Inventree←[0m
[INFO]  Category: "Transistors"
[INFO]  Subcategory: "Semiconductors"
[INFO]  User Category: "Active Components"
[INFO]  User Subcategory: "Semiconductors"
←[93m[INFO]     Warning: Parameter map for "Active Components" does not exist or is empty←[0m
←[95m
[MAIN]  Generating Internal Part Number←[0m
[INFO]  Internal Part Number = TRA-000008-00
←[92m[INFO]     Success: Added new part to InvenTree←[0m
Traceback (most recent call last):
  File "c:\program files\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\program files\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python38\Scripts\kintree.exe\__main__.py", line 7, in <module>
  File "c:\program files\python38\lib\site-packages\kintree\kintree_gui.py", line 1164, in main
    new_part, part_pk, part_data = inventree_interface.inventree_create(part_info=part_info,
  File "c:\program files\python38\lib\site-packages\kintree\database\inventree_interface.py", line 471, in inventree_create
    category_parameters = inventree_api.get_category_parameters(category_select)
  File "c:\program files\python38\lib\site-packages\kintree\database\inventree_api.py", line 74, in get_category_parameters
    category_templates = category.get_category_parameter_templates(fetch_parent=True)
  File "c:\program files\python38\lib\site-packages\inventree\part.py", line 39, in get_category_parameter_templates
    return self.list(self._api,
  File "c:\program files\python38\lib\site-packages\inventree\base.py", line 139, in list
    if isinstance(response, dict) and response['results'] is not None:
KeyError: 'results'

It seems to fail when getting no or the wrong response while fetching parameter templates from invenTree.
Here's the log of the invenTree nginx proxy container:
https://pastebin.com/9Du8xfHh

I checked the last accessed URL (GET /api/part/category/6/parameters/?fetch_parent=True) in my browser and get a full response by the django API.

Steps to reproduce

  1. install Ki-nTree via pip
  2. run the setup (python3 -m kintree.setup_inventree)
    Note that I get a few errors here during parameter creation, see below
  3. Configure and verify both invenTree connection and digikey API connection within Ki-nTree
  4. Try to add a part

Version information

Ki-nTree: 0.5.3
InvenTree-Version: 0.7.7
python version: 3.8.5

Errors during setup

[MAIN]  Loading Parameters←[0m
ERROR:inventree:POST request failed at 'http://192.168.0.15:5555/api/part/parameter/template/' - 400
ERROR:inventree:{"name":["Illegal character in template name (()"]}
ERROR:inventree:Error creating new object
←[93m[TREE]     Warning: Parameter "(Min) Output Voltage" already exists←[0m
←[92m[TREE]     Success: Parameter "Antenna Type" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "B Constant" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Breakdown Voltage" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Capacitance" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Clamping Voltage" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Collector Gate Voltage" was added to InvenTree←[0m
ERROR:inventree:POST request failed at 'http://192.168.0.15:5555/api/part/parameter/template/' - 400
ERROR:inventree:{"name":["Illegal character in template name (-)"]}
ERROR:inventree:Error creating new object
←[93m[TREE]     Warning: Parameter "Collector-Gate Voltage" already exists←[0m
←[92m[TREE]     Success: Parameter "DC Resistance" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "ESR" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Footprint" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Forward Voltage" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Frequency" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Frequency Stability" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Frequency Tolerance" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Function Type" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Interface Type" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "LED Color" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Load Capacitance" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Locking" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Mating Height" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Max Input Voltage" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Max Output Voltage" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Maximum Gate Voltage" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Memory Size" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Min Input Voltage" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Min Output Voltage" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Mounting Type" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Number of Channels" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Number of Contacts" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Number of Elements" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Number of Rows" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Orientation" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Output Current" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Output Type" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Package Height" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Package Size" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Package Type" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Pitch" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Polarity" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Quiescent Current" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "RDS On Resistance" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "RDS On Voltage" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Rated Current" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Rated Power" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Rated Voltage" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Saturation Current" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Shielding" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Standoff Voltage" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Symbol" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Temperature Grade" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Temperature Range" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Tolerance" was added to InvenTree←[0m
←[92m[TREE]     Success: Parameter "Value" was added to InvenTree←[0m

Progress Bar Error

Have installed Ki-nTree, (Along with functioning Inventree) and all good until near end where an error
"
File "kintree_gui.py", line 804, in main
new_part, part_pk, part_data = inventree_interface.inventree_create(part_info=part_info,
TypeError: inventree_create() got an unexpected keyword argument 'progress_window'
"

is thrown.

Looking at Python, the function call below is mismatched to the implementation, a simple change to the call made it work just fine! - Not sure which file is 'old' or 'new' so not prepared to muck with your github - maybe I just caught it mid change... 😀

(Parameter commented out & substituted about line 810 in kintree_gui.py)
new_part, part_pk, part_data = inventree_interface.inventree_create(part_info=part_info,
categories=categories,
kicad=settings.ENABLE_KICAD,
symbol=symbol,
footprint=footprint,
#progress_window=progressbar)
show_progress=True)

Working now - and in total awe of functionality - thankyou so much for this!!

Digi-Key API can not connect

I have followed the instructions as outlined at https://github.com/sparkmicro/Ki-nTree/#get-digi-key-api-token.
I even found a similar issue #19 and tried the setting in chrome without success.

When I enter the settings for the Digi-Key API and press the test button, it takes me to the Digi-key site and has me log in and then returns this or similar "https://localhost:8139/digikey_callback?code=yne1bSDp&scope=" This looks correct from what I am seeing online.

Chrome retunes at the site can't be reached, it is like the localhost is not working.

image

Any suggestions on what to try next? I am a little lost. Thanks for your help and Ideas.
SparkeyinVA

Mouser image download does not work

When trying to import a part via Mouser, the import/download of the image fails every time.
Is there anything (besides the Mouser Part API Key) that I need to consider?

See the following log output:

[MAIN]  Generating Internal Part Number
[INFO]  Internal Part Number = CON-000090-00
[INFO]  Success: Added new part to InvenTree
[INFO]  Warning: Image download timed out (3s)
[INFO]  Warning: Image download timed out (3s)
[INFO]  Warning: Image download timed out (3s)
[TREE]  Warning: Failed to upload part image

The link to the image that is presented in the Update Part Data window does work when I copy-paste it into my browser. So the data received via the API looks to be fine.
image

If I run the same exact part number via the Digi-Key import, the image appears just fine.

Let me know when you need more info from me. :)

Edit: Sorry, I should have mentioned that I only use it to create InvenTree parts. I have not used/tried the KiCAD import.

I am running Ki-nTree from the GIT repo (most recent commit)

commit ef1dd4649c760b311bc58bd63687069be36df850 (HEAD -> main, tag: 0.4.8, origin/main, origin/HEAD)
Merge: ea93ccb 8fcd85c
Author: Francois <[email protected]>
Date:   Fri Nov 26 15:35:37 2021 -0500

kintree_setup_inventree.exe not working on Windows system

Hello and many thanks for creating this tool.

Setting up a new environment with Kicad and inventree, I was not able to initialize the inventree databases. Adding new parts with kintree fails with
←[93m[INFO] Warning: Parameter "Between Board Height" not found in supplier data←[0m
←[93m[INFO] Warning: Parameter "Screw, Thread Size" not found in supplier data←[0m
←[93m[TREE] Warning: Subcategory "Switch" does not exist←[0m
←[91m[ERROR] Categories (Mechanicals - Switch) does not exist in InvenTree←[0m

As documentation is missing any hints I came to use kintree_setup_inventree.exe to initialize inventree but it fails with

C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_xxx\LocalCache\local-packages\Python39\Scripts> .\kintree_setup_inventree.exe
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64__xxx\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64__xxx\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\philipp\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\kintree_setup_inventree.exe_main
.py", line 7, in
AttributeError: module 'kintree.setup_inventree' has no attribute 'main'

I used Python = 3.9 and pip = 21.3.1 for compiling.

Many thanks for any hints of what I'm doing wrong.

Documentation Addition

The minimum permissions required for a parts-creation user are as shown:
image

I'm not sure if the View/Change perms are required.
It is good practice to limit automated tools to the bare minimum permission set they need, and I think it would be ideal to have these defined in documentation.

Fake user agent error

Hello I tried to launch Ki-nTree on my MacBook Pro. After done the installation step I tried to test the connection with Digi-Key. Unfortunately it doesn't work and I get this errors. I received in my browser Auth code.
Second Warning appear after I clicked Allow in my browse.

2021-01-26 11:49:05,373 - digikey.oauth.oauth2 -  WARNING: Oauth2 token storage does not exist or malformed, creating new.
WARNING:digikey.oauth.oauth2:Oauth2 token storage does not exist or malformed, creating new.
WARNING:fake_useragent:Error occurred during loading data. Trying to use cache server https://fake-useragent.herokuapp.com/browsers/0.1.11
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1319, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1422, in connect
    server_hostname=server_hostname)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 423, in wrap_socket
    session=session
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 870, in _create
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1139, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1076)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/pawel/magazyn/Ki-nTree/env-kintree/lib/python3.7/site-packages/fake_useragent/utils.py", line 67, in get
    context=context,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1362, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1321, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1076)>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/pawel/magazyn/Ki-nTree/env-kintree/lib/python3.7/site-packages/fake_useragent/utils.py", line 154, in load
    for item in get_browsers(verify_ssl=verify_ssl):
  File "/Users/pawel/magazyn/Ki-nTree/env-kintree/lib/python3.7/site-packages/fake_useragent/utils.py", line 97, in get_browsers
    html = get(settings.BROWSERS_STATS_PAGE, verify_ssl=verify_ssl)
  File "/Users/pawel/magazyn/Ki-nTree/env-kintree/lib/python3.7/site-packages/fake_useragent/utils.py", line 84, in get
    raise FakeUserAgentError('Maximum amount of retries reached')
fake_useragent.errors.FakeUserAgentError: Maximum amount of retries reached

I've also problem with executable version. It's only gave me this errors.

[INFO]  Warning: Failed to load Digi-Key configuration
[INFO]  Warning: Failed to load InvenTree configuration
[INFO]  Warning: Failed to load KiCad configuration
[ERROR] File /Users/pawel/magazyn/Ki-nTree/dist/config/user_files/kicad.yaml does not exists!
[INFO]  Warning: Failed to load Digi-Key configuration
[INFO]  Warning: Failed to load InvenTree configuration
[INFO]  Warning: Failed to load KiCad configuration

[ERROR] Some Ki-nTree configuration files seem to be missing

If any additional information are needed I will send all necessary information. Hope that information make your app better.

SnapEDA search crashes when MPN contains space

MPN - PTS830GM140 SMTR LFS

Error/Traceback -

[MAIN]	Creating part in Inventree
[INFO]	Category: "Mechanicals"
[INFO]	Subcategory: "Switch"
[INFO]	User Category: "Mechanicals"
[INFO]	User Subcategory: "Switch"
Traceback (most recent call last):
  File "/home/francois/Desktop/kicad/Ki-nTree/.venv/bin/kintree", line 8, in <module>
    sys.exit(kintree_gui.main())
  File "/home/francois/Desktop/kicad/Ki-nTree/.venv/lib/python3.8/site-packages/kintree/kintree_gui.py", line 1147, in main
    symbol, template, footprint = user_defined_symbol_template_footprint(categories, part_info['manufacturer_part_number'])
  File "/home/francois/Desktop/kicad/Ki-nTree/.venv/lib/python3.8/site-packages/kintree/kintree_gui.py", line 838, in user_defined_symbol_template_footprint
    snapeda_window(part_number)
  File "/home/francois/Desktop/kicad/Ki-nTree/.venv/lib/python3.8/site-packages/kintree/kintree_gui.py", line 343, in snapeda_window
    response = snapeda_api.fetch_snapeda_part_info(part_number)
  File "/home/francois/Desktop/kicad/Ki-nTree/.venv/lib/python3.8/site-packages/kintree/search/snapeda_api.py", line 18, in fetch_snapeda_part_info
    with urlopen(request, timeout=20) as response:
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/lib/python3.8/urllib/request.py", line 542, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 1397, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/usr/lib/python3.8/urllib/request.py", line 1354, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/usr/lib/python3.8/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1263, in _send_request
    self.putrequest(method, url, **skips)
  File "/usr/lib/python3.8/http/client.py", line 1097, in putrequest
    self._validate_path(url)
  File "/usr/lib/python3.8/http/client.py", line 1197, in _validate_path
    raise InvalidURL(f"URL can't contain control characters. {url!r} "
http.client.InvalidURL: URL can't contain control characters. '/snapeda?q=PTS830GM140 SMTR LFS' (found at least ' ')

Whitespace handling in search string

Description
When i copy an article number from the mouser site and copy it to the search field, e.g.
"614-SMTU2032-LF", it copies the trailing \n with the article number.
This creates an error when searching.

Error message
Traceback (most recent call last):
File "c:\users\username\appdata\local\programs\python\python37-32\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "c:\users\username\appdata\local\programs\python\python37-32\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users\Username\AppData\Local\Programs\Python\Python37-32\Scripts\kintree.exe_main
.py", line 7, in
File "c:\users\username\appdata\local\programs\python\python37-32\lib\site-packages\kintree\kintree_gui.py", line 1046, in main
part_supplier_info = inventree_interface.supplier_search(values['supplier'], values['part_number'])
File "c:\users\username\appdata\local\programs\python\python37-32\lib\site-packages\kintree\database\inventree_interface.py", line 326, in supplier_search
part_info = search_api.load_from_file(search_filename, test_mode)
File "c:\users\username\appdata\local\programs\python\python37-32\lib\site-packages\kintree\search\search_api.py", line 14, in load_from_file
part_data = config_interface.load_file(search_file)
File "c:\users\username\appdata\local\programs\python\python37-32\lib\site-packages\kintree\config\config_interface.py", line 14, in load_file
with open(file_path, 'r') as file:
OSError: [Errno 22] Invalid argument: 'C:/Users/username/[..somepath...]/KinTree/cache\search\Mouser_614-SMTU2032-LF\n.yaml'

Expected Behaviour
Trim whitespaces in search field.

invoke build on Windows

Hi,
I build Ki-nTree under Linux and Windows. However, on Windows I was struggeling:

$ invoke build

1st) xargs not found --> I had to add C:\Program Files\Git\usr\bin to PATH

2nd) wrong syntax

 ←[95m[MAIN]     Cleaning project directory←[0m
FIND: Parameter format not correct
rm: missing operand

by commenting a line in tasks.py, I got a quick workaround for me (see git diff at the bottom).

3rd) python error:
AttributeError: type object 'Callable' has no attribute '_abc_registry'
uninstalling typing did the job.
pip uninstall typing

With those fixes, it did work for me.
(Sorry, if I am inexact/on the wrong place here; it's my first open source bug report).

Hope that information may help you or someone.
Thanks for sharing the Ki-nTree!
Markus

diff --git a/tasks.py b/tasks.py
index 926ac2b..7af5e94 100644
--- a/tasks.py
+++ b/tasks.py
@@ -30,7 +30,7 @@ def update(c):
 @task
 def clean(c):
        cprint('[MAIN]\tCleaning project directory')
-       c.run('find . -name __pycache__ | xargs rm -r')
+       #c.run('find . -name __pycache__ | xargs rm -r')
        try:
                c.run('rm .coverage', hide='err')
        except UnexpectedExit:

Demo

Create a demo platform (web server / virtual machine image) for easier start. Just leaving this as low priority to do here 🙂

ImportError: cannot import name 'Iterable' from 'collections' (possible python 3.10 issues on aur package?)

When i run kintree i get the following:

❯ kintree
Traceback (most recent call last):
  File "/usr/bin/kintree", line 33, in <module>
    sys.exit(load_entry_point('kintree==0.5.3', 'console_scripts', 'kintree')())
  File "/usr/bin/kintree", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3.10/site-packages/kintree/kintree_gui.py", line 15, in <module>
    from .search import digikey_api as digikey_api
  File "/usr/lib/python3.10/site-packages/kintree/search/digikey_api.py", line 3, in <module>
    import digikey
  File "/usr/lib/python3.10/site-packages/digikey/__init__.py", line 2, in <module>
    from digikey.v2.api import (search, part)
  File "/usr/lib/python3.10/site-packages/digikey/v2/api.py", line 7, in <module>
    from digikey.v2 import models
  File "/usr/lib/python3.10/site-packages/digikey/v2/models.py", line 8, in <module>
    from schematics.exceptions import ConversionError, DataError, ValidationError
  File "/usr/lib/python3.10/site-packages/schematics/__init__.py", line 6, in <module>
    from . import deprecated
  File "/usr/lib/python3.10/site-packages/schematics/deprecated.py", line 8, in <module>
    from .types.serializable import Serializable
  File "/usr/lib/python3.10/site-packages/schematics/types/__init__.py", line 2, in <module>
    from .base import *
  File "/usr/lib/python3.10/site-packages/schematics/types/base.py", line 19, in <module>
    from collections import Iterable, OrderedDict
ImportError: cannot import name 'Iterable' from 'collections' (/usr/lib/python3.10/collections/__init__.py)

Python 3.10 migration issues?

❯ pacman -Q python-kintree
python-kintree 0.5.3-1

Let me know if theres anything more i can provide!

Expand Digi-Key Integration with more categories and ability to set InvenTree default options/field mapping?

Just two small suggestion that I can across when using the tool today (absolutely love it btw!)

  • Would it be possible to expand the categories to cover things like thermal management and fans? Would love to see the tool pick up things like fan size, voltage, rpm and noise level from the Digi-Key listing.

  • I would also love to see the option to choose to have the manufacturer's part number as default on the InvenTree Part Details for either the Part name or Description record, not just on Part Parameters (default options/field mapping).

Digikey error clientid

Hey all,

Are there any known problems with the linking of the program with the digikey-API? The installation succeeded on my PC, but when i enter the client and secret i get from following the video posted about the digikey API, i get an error (401) saying the clientID is invalid...
Does anyone know how to fix this?

Kind regards

[Feature Request] Add ability items from Mouser and LCSC part numbers.

It would be great to expand the functionality to take Mouser and LCSC part numbers.

I've thrown together a quick version (For LCSC) of this myself, modifying the digikey_search function and the snapeda example. It simply checks if the part_number begins with a 'C' and is between 5 and 7 digits letters long. Then it calls the https://wwwapi.lcsc.com/v1/products/detail?product_code={} endpoint to get the part data.

Mouser would be a bit trickier, but at least they have an official API at https://www.mouser.com/api-hub/

Digikey localization

When adding a part using the Digikey API the link to the part is "digikey.com....." while I would like it to be "digikey.be...".

Is that something that could be tweaked in Ki-nTree or is this specific to Digikey.

Code formatting, linting

I propose adopting black to format the source code in the project. This is a bit controversial, because the first commit after doing so would likely change every line in the project since the project uses tabs for indentation, contrary to pep8.

I also propose adding configs for mypy and flake8, and gradually adding types to the code. We could then use pre-commit to run all these tools and make sure the code is formatted and linted before committing. Here's one of my packages as an example: srtools.

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.