diff --git a/kintree/common/tools.py b/kintree/common/tools.py index d28416de..13276f4e 100644 --- a/kintree/common/tools.py +++ b/kintree/common/tools.py @@ -184,5 +184,5 @@ def download_with_retry(url: str, full_path: str, silent=False, **kwargs) -> str if not file: return False - cprint('[INFO]\tSuccess: Part image downloaded', silent=silent) + cprint(f'[INFO]\tDownload success ({url=})', silent=silent) return True diff --git a/kintree/config/config_interface.py b/kintree/config/config_interface.py index 98492498..b507a04f 100644 --- a/kintree/config/config_interface.py +++ b/kintree/config/config_interface.py @@ -71,6 +71,14 @@ def load_config(path): user_settings = {**template_data, **user_data} else: user_settings = user_data + # Warn user about config data discrepancies with template data + template_vs_user = set(template_data) - set(user_data) + # user_vs_template = set(user_data) - set(template_data) + if template_vs_user: + print(f'[INFO]\tTEMPLATE "{filename}" configuration file contains the following keys which are NOT in your user settings: {template_vs_user}') + # if user_vs_template: + # cprint(f'[INFO]\tUSER SETTINGS {filename} configuration file contains the following keys which are NOT in the template: {user_vs_template}', silent=silent) + except (TypeError, AttributeError): cprint(f'[INFO]\tCreating new {filename} configuration file', silent=silent) # Config file does not exists diff --git a/kintree/config/settings.py b/kintree/config/settings.py index 81fdc07b..9b110434 100644 --- a/kintree/config/settings.py +++ b/kintree/config/settings.py @@ -145,18 +145,34 @@ def load_suppliers(): global CONFIG_SUPPLIERS global SUPPORTED_SUPPLIERS_API + update_supplier_config = {} SUPPORTED_SUPPLIERS_API = [] for supplier, data in CONFIG_SUPPLIERS.items(): - if data['enable']: - if data['name']: - supplier_name = data['name'].replace(' ', '') - SUPPORTED_SUPPLIERS_API.append(supplier_name) - else: - supplier_key = supplier.replace(' ', '') - SUPPORTED_SUPPLIERS_API.append(supplier_key) - - -load_suppliers() + try: + if data['enable']: + if data['name']: + supplier_name = data['name'].replace(' ', '') + SUPPORTED_SUPPLIERS_API.append(supplier_name) + else: + supplier_key = supplier.replace(' ', '') + SUPPORTED_SUPPLIERS_API.append(supplier_key) + except (TypeError, KeyError): + update_supplier_config[supplier] = { + 'enable': True, + 'name': supplier, + } + + # Update supplier configuration file + if update_supplier_config: + config_interface.dump_file({**CONFIG_SUPPLIERS, **update_supplier_config}, CONFIG_SUPPLIERS_PATH) + CONFIG_SUPPLIERS = config_interface.load_file(CONFIG_SUPPLIERS_PATH) + return False + return True + + +if not load_suppliers(): + # Re-load updated configuration file + load_suppliers() # Generic API user configuration CONFIG_SUPPLIER_PARAMETERS = os.path.join(CONFIG_USER_FILES, 'supplier_parameters.yaml') diff --git a/kintree/database/inventree_api.py b/kintree/database/inventree_api.py index 4ceb2671..13c3728f 100644 --- a/kintree/database/inventree_api.py +++ b/kintree/database/inventree_api.py @@ -439,7 +439,7 @@ def create_category(parent: str, name: str): return category_pk, is_new_category -def upload_part_image(image_url: str, part_id: int) -> bool: +def upload_part_image(image_url: str, part_id: int, silent=False) -> bool: ''' Upload InvenTree part thumbnail''' global inventree_api @@ -448,7 +448,7 @@ def upload_part_image(image_url: str, part_id: int) -> bool: image_location = settings.search_images + image_name # Download image (multiple attempts) - if not download_with_retry(image_url, image_location, filetype='Image'): + if not download_with_retry(image_url, image_location, filetype='Image', silent=silent): return False # Upload image to InvenTree @@ -462,7 +462,7 @@ def upload_part_image(image_url: str, part_id: int) -> bool: return False -def upload_part_datasheet(datasheet_url: str, part_ipn: int, part_pk: int) -> str: +def upload_part_datasheet(datasheet_url: str, part_ipn: int, part_pk: int, silent=False) -> str: ''' Upload InvenTree part attachment''' global inventree_api @@ -479,7 +479,8 @@ def upload_part_datasheet(datasheet_url: str, part_ipn: int, part_pk: int) -> st datasheet_url, datasheet_location, filetype='PDF', - timeout=10 + timeout=10, + silent=silent, ): return '' diff --git a/kintree/database/inventree_interface.py b/kintree/database/inventree_interface.py index 987aa3d2..aa4d01b7 100644 --- a/kintree/database/inventree_interface.py +++ b/kintree/database/inventree_interface.py @@ -557,7 +557,7 @@ def get_inventree_stock_location_id(stock_location_tree: list): return inventree_api.get_inventree_stock_location_id(stock_location_tree) -def inventree_create(part_info: dict, stock=None, kicad=False, symbol=None, footprint=None, show_progress=True, is_custom=False): +def inventree_create(part_info: dict, stock=None, kicad=False, symbol=None, footprint=None, show_progress=True, is_custom=False, enable_upload=False): ''' Create InvenTree part from supplier part data and categories ''' part_pk = 0 @@ -659,21 +659,24 @@ def inventree_create(part_info: dict, stock=None, kicad=False, symbol=None, foot part_pk, data={'existing_image': inventree_part['existing_image']}) elif inventree_part['image']: - # Add image - image_result = inventree_api.upload_part_image(inventree_part['image'], part_pk) - if not image_result: - cprint('[TREE]\tWarning: Failed to upload part image', silent=settings.SILENT) + if enable_upload: + # Add image + image_result = inventree_api.upload_part_image(inventree_part['image'], part_pk, silent=settings.SILENT) + if not image_result: + cprint('[TREE]\tWarning: Failed to upload part image', silent=settings.SILENT) if inventree_part['datasheet'] and settings.DATASHEET_UPLOAD: - # Upload datasheet - datasheet_link = inventree_api.upload_part_datasheet( - datasheet_url=inventree_part['datasheet'], - part_ipn=inventree_part['IPN'], - part_pk=part_pk, - ) - if not datasheet_link: - cprint('[TREE]\tWarning: Failed to upload part datasheet', silent=settings.SILENT) - else: - cprint('[TREE]\tSuccess: Uploaded part datasheet', silent=settings.SILENT) + if enable_upload: + # Upload datasheet + datasheet_link = inventree_api.upload_part_datasheet( + datasheet_url=inventree_part['datasheet'], + part_ipn=inventree_part['IPN'], + part_pk=part_pk, + silent=settings.SILENT, + ) + if not datasheet_link: + cprint('[TREE]\tWarning: Failed to upload part datasheet', silent=settings.SILENT) + else: + cprint('[TREE]\tSuccess: Uploaded part datasheet', silent=settings.SILENT) if kicad: try: @@ -845,7 +848,7 @@ def inventree_create_alternate(part_info: dict, part_id='', part_ipn='', show_pr inventree_api.update_part(pk=part_pk, data={'existing_image': existing_image}) elif image: - inventree_api.upload_part_image(image_url=image, part_id=part_pk) + inventree_api.upload_part_image(image_url=image, part_id=part_pk, silent=settings.SILENT) # create or update parameters if inventree_part.get('parameters', {}): @@ -866,6 +869,7 @@ def inventree_create_alternate(part_info: dict, part_id='', part_ipn='', show_pr datasheet_url=datasheet, part_ipn=part_ipn, part_pk=part_id, + silent=settings.SILENT, ) if not part_info['datasheet']: cprint('[TREE]\tWarning: Failed to upload part datasheet', silent=settings.SILENT) diff --git a/kintree/gui/gui.py b/kintree/gui/gui.py index 0ae31a10..cb6f7d1f 100644 --- a/kintree/gui/gui.py +++ b/kintree/gui/gui.py @@ -29,14 +29,6 @@ def init_gui(page: ft.Page): # to show the user that the app is busy doing something page.splash = ft.ProgressBar(visible=False) - # Init dialogs - page.snack_bar = ft.SnackBar( - content=None, - open=False, - ) - page.banner = ft.Banner() - page.dialog = ft.AlertDialog() - # Update page.update() diff --git a/kintree/gui/views/common.py b/kintree/gui/views/common.py index 04276a25..cf104351 100644 --- a/kintree/gui/views/common.py +++ b/kintree/gui/views/common.py @@ -169,8 +169,10 @@ def show_dialog( self._page.banner = self.dialog self._page.banner.open = open elif isinstance(self.dialog, ft.AlertDialog): - self._page.dialog = self.dialog - self._page.dialog.open = open + if open: + self._page.open(self.dialog) + else: + self._page.close(self.dialog) self._page.update() diff --git a/kintree/search/automationdirect_api.py b/kintree/search/automationdirect_api.py index 4d0a8de1..a3e44af9 100644 --- a/kintree/search/automationdirect_api.py +++ b/kintree/search/automationdirect_api.py @@ -59,7 +59,7 @@ def find_categories(part_details: str): return None, None -def fetch_part_info(part_number: str) -> dict: +def fetch_part_info(part_number: str, silent=False) -> dict: ''' Fetch part data from API ''' # Load Automation Direct settingss @@ -81,7 +81,7 @@ def search_timeout(timeout=10): part = part['solrResult']['response'] # extract the data for parts returned if part['numFound'] > 0: if part['numFound'] == 1: - cprint(f'[INFO]\tFound exactly one result for "{part_number}"', silent=False) + cprint(f'[INFO]\tFound exactly one result for "{part_number}"', silent=True) else: cprint(f'[INFO]\tFound {part["numFound"]} results for "{part_number}", selecting first result', silent=False) part = part['docs'][0] # choose the first part in the returned returned list @@ -212,7 +212,7 @@ def search_timeout(timeout=10): except KeyError as e: from ..common.tools import cprint - cprint(f'[INFO]\tNo pricing attribute "{e.args[0]}" found for "{part_number}"') + cprint(f'[INFO]\tNo pricing attribute "{e.args[0]}" found for "{part_number}"', silent=silent) part_info['pricing']['1'] = price_per_unit part_info['currency'] = 'USD' @@ -255,7 +255,7 @@ def test_api() -> bool: } } - test_part = fetch_part_info('BX-16ND3') + test_part = fetch_part_info('BX-16ND3', silent=True) if not test_part: test_success = False diff --git a/kintree/search/element14_api.py b/kintree/search/element14_api.py index b130f95f..d679efdb 100644 --- a/kintree/search/element14_api.py +++ b/kintree/search/element14_api.py @@ -161,14 +161,14 @@ def get_default_store_url(supplier: str) -> str: return STORES[supplier][default_store] -def build_api_url(part_number: str, supplier: str, store_url=None) -> str: +def build_api_url(part_number: str, supplier: str, store_url=None, silent=False) -> str: ''' Build API URL based on user settings ''' user_settings = config_interface.load_file(settings.CONFIG_ELEMENT14_API) api_key = user_settings.get('ELEMENT14_PRODUCT_SEARCH_API_KEY', '') if not api_key: from ..common.tools import cprint - cprint('[INFO]\tWarning: ELEMENT14_PRODUCT_SEARCH_API_KEY user value not configured', silent=False) + cprint('[INFO]\tWarning: ELEMENT14_PRODUCT_SEARCH_API_KEY user value not configured', silent=silent) import os api_key = os.environ.get('ELEMENT14_PART_API_KEY', None) @@ -213,13 +213,13 @@ def build_image_url(image_data: dict, supplier: str, store_url=None) -> str: return image_url -def fetch_part_info(part_number: str, supplier: str, store_url=None) -> dict: +def fetch_part_info(part_number: str, supplier: str, store_url=None, silent=False) -> dict: ''' Fetch part data from API ''' part_info = {} def search_timeout(timeout=10): - url = build_api_url(part_number, supplier, store_url) + url = build_api_url(part_number, supplier, store_url, silent) response = download(url, timeout=timeout) return response @@ -349,7 +349,7 @@ def test_api(store_url=None) -> bool: if store_url: # If store URL is specified, only check data is returned (eg. avoid discrepancies between stores) part_number = '1N4148' - test_part = fetch_part_info(part_number, '', store_url) + test_part = fetch_part_info(part_number, '', store_url, True) if not test_part: test_success = False else: @@ -357,7 +357,7 @@ def test_api(store_url=None) -> bool: if not test_success: break - test_part = fetch_part_info(item['part_number'], '', item['store_url']) + test_part = fetch_part_info(item['part_number'], '', item['store_url'], True) if not test_part: test_success = False diff --git a/kintree/search/mouser_api.py b/kintree/search/mouser_api.py index 6ae03d2b..e37e8075 100644 --- a/kintree/search/mouser_api.py +++ b/kintree/search/mouser_api.py @@ -157,7 +157,7 @@ def test_api() -> bool: test_success = True expected = { - 'Description': 'MOSFET P-channel 1.25W', + 'Description': 'MOSFETs P-channel 1.25W', 'MouserPartNumber': '621-DMP2066LSN-7', 'Manufacturer': 'Diodes Incorporated', 'ManufacturerPartNumber': 'DMP2066LSN-7', diff --git a/kintree/search/snapeda_api.py b/kintree/search/snapeda_api.py index 3b559596..57f87a71 100644 --- a/kintree/search/snapeda_api.py +++ b/kintree/search/snapeda_api.py @@ -62,7 +62,7 @@ def parse_snapeda_response(response: dict) -> dict: return data -def download_snapeda_images(snapeda_data: dict) -> dict: +def download_snapeda_images(snapeda_data: dict, silent=False) -> dict: ''' Download symbol and footprint images from SnapEDA's server ''' images = { @@ -83,7 +83,12 @@ def download_snapeda_images(snapeda_data: dict) -> dict: image_location = settings.search_images + image_name # Download symbol image - symbol = download_with_retry(snapeda_data['symbol_image'], image_location, filetype='Image') + symbol = download_with_retry( + url=snapeda_data['symbol_image'], + full_path=image_location, + filetype='Image', + silent=silent, + ) if symbol: images['symbol'] = image_location except KeyError: @@ -96,7 +101,12 @@ def download_snapeda_images(snapeda_data: dict) -> dict: image_location = settings.search_images + image_name # Download symbol image - footprint = download_with_retry(snapeda_data['footprint_image'], image_location, filetype='Image') + footprint = download_with_retry( + url=snapeda_data['footprint_image'], + full_path=image_location, + filetype='Image', + silent=silent, + ) if footprint: images['footprint'] = image_location except KeyError: @@ -113,7 +123,7 @@ def test_snapeda_api() -> bool: # Test single result response = fetch_snapeda_part_info('NTR06B2001CTRF') data = parse_snapeda_response(response) - images = download_snapeda_images(data) + images = download_snapeda_images(data, silent=True) if data['part_number'] and data['has_symbol'] and images['symbol']: result = True diff --git a/kintree/search/tme_api.py b/kintree/search/tme_api.py index 3dae8b39..f6df6ca4 100644 --- a/kintree/search/tme_api.py +++ b/kintree/search/tme_api.py @@ -5,8 +5,9 @@ import os import urllib.parse import urllib.request +import json -from ..common.tools import download +# from ..common.tools import download from ..config import config_interface, settings PRICING_MAP = [ @@ -90,6 +91,17 @@ def tme_api_request(endpoint, tme_api_settings, part_number, api_host='https://a return urllib.request.Request(url, data, headers) +def tme_api_query(request: urllib.request.Request) -> dict: + response = None + try: + data = urllib.request.urlopen(request).read().decode('utf8') + except urllib.error.HTTPError: + data = None + if data: + response = json.loads(data) + return response + + def fetch_part_info(part_number: str) -> dict: def search_product(response): @@ -103,7 +115,8 @@ def search_product(response): return found, index tme_api_settings = config_interface.load_file(settings.CONFIG_TME_API) - response = download(tme_api_request('/Products/GetProducts', tme_api_settings, part_number)) + response = tme_api_query(tme_api_request('/Products/GetProducts', tme_api_settings, part_number)) + if response is None or response['Status'] != 'OK': return {} # in the case if multiple parts returned @@ -125,7 +138,7 @@ def search_product(response): part_info['subcategory'] = None # query the parameters - response = download(tme_api_request('/Products/GetParameters', tme_api_settings, part_number)) + response = tme_api_query(tme_api_request('/Products/GetParameters', tme_api_settings, part_number)) # check if accidentally no data returned if response is None or response['Status'] != 'OK': return part_info @@ -140,7 +153,7 @@ def search_product(response): part_info['parameters'][param['ParameterName']] = param['ParameterValue'] # query the prices - response = download(tme_api_request('/Products/GetPrices', tme_api_settings, part_number, currency='USD')) + response = tme_api_query(tme_api_request('/Products/GetPrices', tme_api_settings, part_number, currency='USD')) # check if accidentally no data returned if response is None or response['Status'] != 'OK': return part_info @@ -162,7 +175,7 @@ def search_product(response): part_info['currency'] = response['Data'][currency_key] # Query the files associated to the product - response = download(tme_api_request('/Products/GetProductsFiles', tme_api_settings, part_number)) + response = tme_api_query(tme_api_request('/Products/GetProductsFiles', tme_api_settings, part_number)) # check if accidentally no products returned if response is None or response['Status'] != 'OK': return part_info diff --git a/poetry.lock b/poetry.lock index f568c99a..80b2b3c2 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. [[package]] name = "annotated-types" @@ -646,27 +646,27 @@ typing = ["typing-extensions (>=4.8)"] [[package]] name = "flet" -version = "0.22.1" +version = "0.23.2" description = "Flet for Python - easily build interactive multi-platform apps in Python" optional = false python-versions = "<4.0,>=3.8" files = [ - {file = "flet-0.22.1-py3-none-any.whl", hash = "sha256:50659c669b9bc9499a06ad88a4837610f1ccbab582d946302d091ce49baa47f0"}, - {file = "flet-0.22.1-py3-none-macosx_10_14_x86_64.whl", hash = "sha256:d4e6a2e7d656048b787ca613f2dba2a4658c4bc6695e7fc7f305e4de26db7cf5"}, - {file = "flet-0.22.1-py3-none-macosx_12_0_arm64.whl", hash = "sha256:71c0123ad820263188704ba8ae5cfc72a9bc92336f2e41e5eb36830bd4caff59"}, - {file = "flet-0.22.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b14039203087358ecbae1ddd176f874561df5d033460b54500138cc24cc41fc5"}, - {file = "flet-0.22.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e83f6d270706753eb673bac0770a7a29aa7648e03b42f5d546bf7992794d4a27"}, - {file = "flet-0.22.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7669745c397b0c051280b264d8a306e5deeeb2c39aaf4362add71b538f8d93b6"}, - {file = "flet-0.22.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:d1d3a32e0a0cccbfea79bc927e1f8fc5491f73f78729d3de9b67695c49decb2b"}, - {file = "flet-0.22.1-py3-none-win32.whl", hash = "sha256:e4cbb28c276dfaff09aa7e01c99dc7cfe3b8ca7527eb33802175ccc989557ec8"}, - {file = "flet-0.22.1-py3-none-win_amd64.whl", hash = "sha256:a4dce8443a0f1c3f276c9b5873a06e9f34cbae0360ac833e34d5be428cda68f4"}, - {file = "flet-0.22.1.tar.gz", hash = "sha256:10643d18b9550ccdab9f1c5c5fd6933720c546ecae10a217ad88732b09264237"}, + {file = "flet-0.23.2-py3-none-any.whl", hash = "sha256:2ed5f80df75b5bc123c84ea84ff79d30a15dd6ac985e4a9c06ace1702b251865"}, + {file = "flet-0.23.2-py3-none-macosx_10_14_x86_64.whl", hash = "sha256:cb7efbf8cb1e50654819724e746d883348877fddcd4f4d45c2b32772bef31c98"}, + {file = "flet-0.23.2-py3-none-macosx_12_0_arm64.whl", hash = "sha256:7f6db88095d9248f66253e00345faca5981a5c0729185ed022f718d94b7a1ebc"}, + {file = "flet-0.23.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d42a6ff1384d99e03a702d9660d0c4585064e580c9ea07e6bdf51a66599de388"}, + {file = "flet-0.23.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:b632be042004307f848bf1896d6cd7c9798cef6cf2a534dd7168393f5d871f3c"}, + {file = "flet-0.23.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:06cb02d3e580eceb9e6a2fae86ac3c6416ae9c1ec7c965f0c71739cb1ca2b92a"}, + {file = "flet-0.23.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:8d34a90881c48796198396e54672d3af36b372e1cc8748c8c47724f1df1956ec"}, + {file = "flet-0.23.2-py3-none-win32.whl", hash = "sha256:a71ba22dfe1f809bbe9b7fe0374ddca773683bbaee3aa3b87657d7bc627d312c"}, + {file = "flet-0.23.2-py3-none-win_amd64.whl", hash = "sha256:fca6b574256108ca0bcae8ce27dd1e09070dcdaed348cd8a02dd544b17f4ff64"}, + {file = "flet-0.23.2.tar.gz", hash = "sha256:fd4c6de79797f70b2e62f27e4386d3ed399b900d3598d7a0336d7b1d17c7ee96"}, ] [package.dependencies] cookiecutter = ">=2.6.0,<3.0.0" fastapi = ">=0,<1" -flet-runtime = "0.22.1" +flet-runtime = "0.23.2" packaging = ">=23.1,<24.0" qrcode = ">=7.4.2,<8.0.0" uvicorn = {version = ">=0,<1", extras = ["standard"]} @@ -674,13 +674,13 @@ watchdog = ">=4.0.0,<5.0.0" [[package]] name = "flet-core" -version = "0.22.1" +version = "0.23.2" description = "Flet core library" optional = false python-versions = "<4.0,>=3.8" files = [ - {file = "flet_core-0.22.1-py3-none-any.whl", hash = "sha256:cbc8e78c465cb0b12c8d163ddb48bd65852ea3e346332add5457f21e59dfd72f"}, - {file = "flet_core-0.22.1.tar.gz", hash = "sha256:071e629416fcdaf983354de4cbcf4ec2bfeb8892cd8662f8d9bec8ce05cb259c"}, + {file = "flet_core-0.23.2-py3-none-any.whl", hash = "sha256:fc3e2afbd48372bc768121b229768d9e10b404d358fc15a859a6dd060e70de43"}, + {file = "flet_core-0.23.2.tar.gz", hash = "sha256:6a4c713ba7b4cfe820227b41ce72094a5c7b1dddfdf0860110213977a181459b"}, ] [package.dependencies] @@ -688,17 +688,17 @@ repath = ">=0.9.0,<0.10.0" [[package]] name = "flet-runtime" -version = "0.22.1" +version = "0.23.2" description = "Flet Runtime - a base package for Flet desktop and Flet mobile." optional = false python-versions = "<4.0,>=3.8" files = [ - {file = "flet_runtime-0.22.1-py3-none-any.whl", hash = "sha256:b40cf67a48047dc656ffa23ab29f83357d4ce237e51e60662257a0878a044c03"}, - {file = "flet_runtime-0.22.1.tar.gz", hash = "sha256:b5941d6638d09b2856c5d30b97e38cf237fe313f8fbec8f7965efa3aaf630171"}, + {file = "flet_runtime-0.23.2-py3-none-any.whl", hash = "sha256:61cc9915cbb9809aae793f48b0ad8503f0fd5bb2651e84b529ceccc4b57f1ced"}, + {file = "flet_runtime-0.23.2.tar.gz", hash = "sha256:c0c0f2d57339dc77ed23b6f3546156d9a83dd4f36208b9e9f0a670219c0f43e2"}, ] [package.dependencies] -flet-core = "0.22.1" +flet-core = "0.23.2" httpx = ">=0,<1" oauthlib = ">=3.2.2,<4.0.0" @@ -830,13 +830,13 @@ files = [ [[package]] name = "inventree" -version = "0.13.5" +version = "0.14.0" description = "Python interface for InvenTree inventory management system" optional = false python-versions = ">=3.8" files = [ - {file = "inventree-0.13.5-py2.py3-none-any.whl", hash = "sha256:cccad460e5d44d338f633e5b41ef3cee2a91529871087556afef0ae7e626f064"}, - {file = "inventree-0.13.5.tar.gz", hash = "sha256:533fa40ee60ec89fde62875b14447d4b05499046d6bcf3ece41ed5f2bb96d1e4"}, + {file = "inventree-0.14.0-py2.py3-none-any.whl", hash = "sha256:7d10a6437970d8d07a417f12fb61b95fbc69bea4678d03477f136a8f4d0537e9"}, + {file = "inventree-0.14.0.tar.gz", hash = "sha256:b85662f263577a4dcc6c51176b3c2bbb36bb53c688c52bd2b8226f8370a21e9a"}, ] [package.dependencies] @@ -1413,7 +1413,6 @@ files = [ {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, - {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, @@ -1421,16 +1420,8 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, - {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, - {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, - {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, - {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, - {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, - {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, @@ -1447,7 +1438,6 @@ files = [ {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, - {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, @@ -1455,7 +1445,6 @@ files = [ {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, - {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, @@ -2224,4 +2213,4 @@ test = ["black", "codecov", "coloredlogs", "coverage", "flake8", "mypy", "pytest [metadata] lock-version = "2.0" python-versions = ">=3.9,<3.12" -content-hash = "92e7b6b967fa62dd8003db2c98e4c83f906799e0e5084baa87d46ceb7fcf11d8" +content-hash = "d837be7d7a4b3578dea1755a7ee43befa2455aa490a84120ab06369ce5b64945" diff --git a/pyproject.toml b/pyproject.toml index c1294325..2b2404cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,9 +13,10 @@ keywords = ["inventree", "kicad", "digikey", "mouser", "component", "part", "cre [tool.poetry.dependencies] python = ">=3.9,<3.12" digikey-api = "^1.0.0" -flet = "^0.22.0" +# digikey-api = { git = "https://github.com/hurricaneJoef/digikey-api.git", branch = "master" } +flet = "^0.23.0" thefuzz = "^0.19.0" -inventree = "^0.13.3" +inventree = "^0.14.0" kiutils = "^1.4.0" mouser = "^0.1.3" multiprocess = "^0.70.12" diff --git a/run_tests.py b/run_tests.py index 45703d9e..00afbe2e 100644 --- a/run_tests.py +++ b/run_tests.py @@ -6,8 +6,16 @@ from kintree.config import config_interface from kintree.database import inventree_api, inventree_interface from kintree.kicad import kicad_interface -from kintree.search import digikey_api, mouser_api, element14_api, lcsc_api, tme_api -from kintree.search.snapeda_api import test_snapeda_api +from kintree.search import ( + digikey_api, + mouser_api, + element14_api, + lcsc_api, + tme_api, + snapeda_api, + automationdirect_api, + jameco_api, +) from kintree.setup_inventree import setup_inventree @@ -129,9 +137,27 @@ def check_result(status: str, new_part: bool) -> bool: else: cprint('[ PASS ]') + # Test AutomationDirect API + if 'AutomationDirect' in settings.SUPPORTED_SUPPLIERS_API: + pretty_test_print('[MAIN]\tAutomationDirect API Test') + if not automationdirect_api.test_api(): + cprint('[ FAIL ]') + sys.exit(-1) + else: + cprint('[ PASS ]') + + # Test Jameco API + if 'Jameco' in settings.SUPPORTED_SUPPLIERS_API: + pretty_test_print('[MAIN]\tJameco API Test') + if not jameco_api.test_api(): + cprint('[ FAIL ]') + sys.exit(-1) + else: + cprint('[ PASS ]') + # Test SnapEDA API methods pretty_test_print('[MAIN]\tSnapEDA API Test') - if not test_snapeda_api(): + if not snapeda_api.test_snapeda_api(): cprint('[ FAIL ]') sys.exit(-1) else: @@ -217,6 +243,7 @@ def check_result(status: str, new_part: bool) -> bool: kicad=last_category, symbol=part_info['Symbol'], show_progress=False, + enable_upload=True if number == 'BSS84-7-F' else False, ) inventree_result = check_result(status, new_part)