From 6b47fa3ecb1e416b13e4c6685d603ad681a4c686 Mon Sep 17 00:00:00 2001 From: brentru Date: Fri, 26 Feb 2021 10:21:39 -0500 Subject: [PATCH 1/2] add a log statement for non-ssl errors, toss in new cookicutter files --- .github/workflows/build.yml | 10 +++++----- .pre-commit-config.yaml | 15 +++++++++++++++ adafruit_minimqtt/adafruit_minimqtt.py | 5 +++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 221659e1..fd99feee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,11 +50,6 @@ jobs: - name: Pre-commit hooks run: | pre-commit run --all-files - - name: PyLint - run: | - pylint $( find . -path './adafruit*.py' ) - ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace $( find . -path "./examples/*.py" )) - ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace $( find . -path "./examples/*/*.py" )) - name: Build assets run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location . - name: Archive bundles @@ -62,7 +57,12 @@ jobs: with: name: bundles path: ${{ github.workspace }}/bundles/ + - name: Check For docs folder + id: need-docs + run: | + echo ::set-output name=docs::$( find . -wholename './docs' ) - name: Build docs + if: contains(steps.need-docs.outputs.docs, 'docs') working-directory: docs run: sphinx-build -E -W -b html . _build/html - name: Check For setup.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 07f886c0..354c7618 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,3 +17,18 @@ repos: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace +- repo: https://github.com/pycqa/pylint + rev: pylint-2.7.1 + hooks: + - id: pylint + name: pylint (library code) + types: [python] + exclude: "^(docs/|examples/|setup.py$)" +- repo: local + hooks: + - id: pylint_examples + name: pylint (examples code) + description: Run pylint rules on "examples/*.py" files + entry: /usr/bin/env bash -c + args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name $example; done)'] + language: system diff --git a/adafruit_minimqtt/adafruit_minimqtt.py b/adafruit_minimqtt/adafruit_minimqtt.py index bb45d554..eca9e143 100755 --- a/adafruit_minimqtt/adafruit_minimqtt.py +++ b/adafruit_minimqtt/adafruit_minimqtt.py @@ -227,6 +227,11 @@ def _get_connect_socket(self, host, port, *, timeout=1): "ssl_context must be set before using adafruit_mqtt for secure MQTT." ) + if self.logger and port == MQTT_TLS_PORT: + self.logger.info("Establishing a SECURE SSL connection to {0}:{1}".format(host, port)) + else: + self.logger.info("Establishing an INSECURE connection to {0}:{1}".format(host, port)) + addr_info = self._socket_pool.getaddrinfo( host, port, 0, self._socket_pool.SOCK_STREAM )[0] From 8333935a51bc80db319d9a347de93fad14e5f60e Mon Sep 17 00:00:00 2001 From: brentru Date: Fri, 26 Feb 2021 10:23:03 -0500 Subject: [PATCH 2/2] black --- adafruit_minimqtt/adafruit_minimqtt.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/adafruit_minimqtt/adafruit_minimqtt.py b/adafruit_minimqtt/adafruit_minimqtt.py index eca9e143..9aff97e0 100755 --- a/adafruit_minimqtt/adafruit_minimqtt.py +++ b/adafruit_minimqtt/adafruit_minimqtt.py @@ -228,9 +228,13 @@ def _get_connect_socket(self, host, port, *, timeout=1): ) if self.logger and port == MQTT_TLS_PORT: - self.logger.info("Establishing a SECURE SSL connection to {0}:{1}".format(host, port)) + self.logger.info( + "Establishing a SECURE SSL connection to {0}:{1}".format(host, port) + ) else: - self.logger.info("Establishing an INSECURE connection to {0}:{1}".format(host, port)) + self.logger.info( + "Establishing an INSECURE connection to {0}:{1}".format(host, port) + ) addr_info = self._socket_pool.getaddrinfo( host, port, 0, self._socket_pool.SOCK_STREAM