From d6f2b44fd27bf07a6a77d496eeed985d5d6c22b9 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 9 Dec 2024 20:36:30 +0100 Subject: [PATCH] Correct style errors found by flake --- .github/workflows/ci.yml | 2 +- inventree_supplier_sync/mouser.py | 9 +++------ inventree_supplier_sync/request_wrappers.py | 11 ++--------- inventree_supplier_sync/supplier_sync.py | 2 +- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 01a47fa..64549b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest environment: name: release - url: https://pypi.org/p/inventree-supplier-panel + url: https://pypi.org/p/inventree-supplier-sync permissions: id-token: write diff --git a/inventree_supplier_sync/mouser.py b/inventree_supplier_sync/mouser.py index 20c90d8..ba683f9 100644 --- a/inventree_supplier_sync/mouser.py +++ b/inventree_supplier_sync/mouser.py @@ -46,10 +46,7 @@ ], 'SearchResults': None} """ -from common.models import InvenTreeSetting - from .request_wrappers import Wrappers -from .meta_access import MetaAccess import re import json @@ -78,14 +75,14 @@ def get_mouser_partdata(self, sku, options): # If we are here, Mouser responded. Lets look for errors. Some # errors do not come in the Errors array, but in a Message. # Lets check those first - try: - part_data['error_status'] = response['Message'] + try: + part_data['error_status'] = response['Message'] return part_data except Exception: pass # Then we evaluate the Errors array. there are some known errors - # and the rest. + # and the rest. if response['Errors'] != []: if response['Errors'][0]['Code'] == 'InvalidCharacters': part_data['error_status'] = 'InvalidCharacters' diff --git a/inventree_supplier_sync/request_wrappers.py b/inventree_supplier_sync/request_wrappers.py index 36c4f54..c88bbbf 100644 --- a/inventree_supplier_sync/request_wrappers.py +++ b/inventree_supplier_sync/request_wrappers.py @@ -22,7 +22,7 @@ def post_request(self, post_data, path, headers): timeout=5, headers=headers) except Exception as e: - return e.args + return (e.args) return (response) def get_request(self, path, headers): @@ -40,12 +40,5 @@ def get_request(self, path, headers): timeout=5, headers=headers) except Exception as e: - self.status_code = e.args - raise ConnectionError - if response.status_code != 200: - self.status_code = response.status_code - self.message = response.content - return (response) - self.status_code = response.status_code - self.message = 'OK' + return (e.args) return (response) diff --git a/inventree_supplier_sync/supplier_sync.py b/inventree_supplier_sync/supplier_sync.py index a0710bf..dd5570c 100644 --- a/inventree_supplier_sync/supplier_sync.py +++ b/inventree_supplier_sync/supplier_sync.py @@ -40,7 +40,7 @@ class SupplierSyncPlugin(AppMixin, ScheduleMixin, SettingsMixin, PanelMixin, Inv 'member': { 'func': 'update_part', 'schedule': 'I', - 'minutes': 3, + 'minutes': 1, } }