diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 827258f..59baa53 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries +# +# SPDX-License-Identifier: MIT + name: Build CI on: [pull_request, push] @@ -38,20 +42,36 @@ jobs: # (e.g. - apt-get: gettext, etc; pip: circuitpython-build-tools, requirements.txt; etc.) run: | source actions-ci/install.sh - - name: Pip install pylint, black, & Sphinx + - name: Pip install pylint, Sphinx, pre-commit run: | - pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme + pip install --force-reinstall pylint Sphinx sphinx-rtd-theme pre-commit - name: Library version run: git describe --dirty --always --tags - - name: Check formatting + - name: Pre-commit hooks run: | - black --check --target-version=py35 --line-length=140 . + pre-commit run --all-files - name: PyLint run: | - pylint $( find . -path './adafruit_azureiot/*.py' ) - ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace,wrong-import-position $( find . -path "./examples/*.py" )) + pylint $( find . -path './adafruit*.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 + uses: actions/upload-artifact@v2 + with: + name: bundles + path: ${{ github.workspace }}/bundles/ - name: Build docs working-directory: docs run: sphinx-build -E -W -b html . _build/html + - name: Check For setup.py + id: need-pypi + run: | + echo ::set-output name=setup-py::$( find . -wholename './setup.py' ) + - name: Build Python package + if: contains(steps.need-pypi.outputs.setup-py, 'setup.py') + run: | + pip install --upgrade setuptools wheel twine readme_renderer testresources + python setup.py sdist + python setup.py bdist_wheel --universal + twine check dist/* diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 18efb9c..6d0015a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries +# +# SPDX-License-Identifier: MIT + name: Release Actions on: diff --git a/.gitignore b/.gitignore index df3a832..5a26e76 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# +# SPDX-License-Identifier: Unlicense + *.mpy .idea __pycache__ diff --git a/.pylintrc b/.pylintrc index 7eb328d..c391552 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# +# SPDX-License-Identifier: Unlicense + [MASTER] # A comma-separated list of package or module names from where C extensions may diff --git a/.readthedocs.yml b/.readthedocs.yml index f4243ad..ffa84c4 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# +# SPDX-License-Identifier: Unlicense + python: version: 3 requirements_file: requirements.txt diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 134d510..8a55c07 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,3 +1,9 @@ + + # Adafruit Community Code of Conduct ## Our Pledge @@ -43,7 +49,7 @@ Examples of unacceptable behavior by participants include: The goal of the standards and moderation guidelines outlined here is to build and maintain a respectful community. We ask that you don’t just aim to be -"technically unimpeachable", but rather try to be your best self. +"technically unimpeachable", but rather try to be your best self. We value many things beyond technical expertise, including collaboration and supporting others within our community. Providing a positive experience for @@ -74,9 +80,9 @@ You may report in the following ways: In any situation, you may send an email to . On the Adafruit Discord, you may send an open message from any channel -to all Community Moderators by tagging @community moderators. You may -also send an open message from any channel, or a direct message to -@kattni#1507, @tannewt#4653, @Dan Halbert#1614, @cater#2442, +to all Community Moderators by tagging @community moderators. You may +also send an open message from any channel, or a direct message to +@kattni#1507, @tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, @Mr. Certainly#0472 or @Andon#8175. Email and direct message reports will be kept confidential. diff --git a/LICENSES/CC-BY-4.0.txt b/LICENSES/CC-BY-4.0.txt new file mode 100644 index 0000000..3f92dfc --- /dev/null +++ b/LICENSES/CC-BY-4.0.txt @@ -0,0 +1,324 @@ +Creative Commons Attribution 4.0 International Creative Commons Corporation +("Creative Commons") is not a law firm and does not provide legal services +or legal advice. Distribution of Creative Commons public licenses does not +create a lawyer-client or other relationship. Creative Commons makes its licenses +and related information available on an "as-is" basis. Creative Commons gives +no warranties regarding its licenses, any material licensed under their terms +and conditions, or any related information. Creative Commons disclaims all +liability for damages resulting from their use to the fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and conditions +that creators and other rights holders may use to share original works of +authorship and other material subject to copyright and certain other rights +specified in the public license below. The following considerations are for +informational purposes only, are not exhaustive, and do not form part of our +licenses. + +Considerations for licensors: Our public licenses are intended for use by +those authorized to give the public permission to use material in ways otherwise +restricted by copyright and certain other rights. Our licenses are irrevocable. +Licensors should read and understand the terms and conditions of the license +they choose before applying it. Licensors should also secure all rights necessary +before applying our licenses so that the public can reuse the material as +expected. Licensors should clearly mark any material not subject to the license. +This includes other CC-licensed material, or material used under an exception +or limitation to copyright. More considerations for licensors : wiki.creativecommons.org/Considerations_for_licensors + +Considerations for the public: By using one of our public licenses, a licensor +grants the public permission to use the licensed material under specified +terms and conditions. If the licensor's permission is not necessary for any +reason–for example, because of any applicable exception or limitation to copyright–then +that use is not regulated by the license. Our licenses grant only permissions +under copyright and certain other rights that a licensor has authority to +grant. Use of the licensed material may still be restricted for other reasons, +including because others have copyright or other rights in the material. A +licensor may make special requests, such as asking that all changes be marked +or described. Although not required by our licenses, you are encouraged to +respect those requests where reasonable. More considerations for the public +: wiki.creativecommons.org/Considerations_for_licensees Creative Commons Attribution +4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree to +be bound by the terms and conditions of this Creative Commons Attribution +4.0 International Public License ("Public License"). To the extent this Public +License may be interpreted as a contract, You are granted the Licensed Rights +in consideration of Your acceptance of these terms and conditions, and the +Licensor grants You such rights in consideration of benefits the Licensor +receives from making the Licensed Material available under these terms and +conditions. + +Section 1 – Definitions. + +a. Adapted Material means material subject to Copyright and Similar Rights +that is derived from or based upon the Licensed Material and in which the +Licensed Material is translated, altered, arranged, transformed, or otherwise +modified in a manner requiring permission under the Copyright and Similar +Rights held by the Licensor. For purposes of this Public License, where the +Licensed Material is a musical work, performance, or sound recording, Adapted +Material is always produced where the Licensed Material is synched in timed +relation with a moving image. + +b. Adapter's License means the license You apply to Your Copyright and Similar +Rights in Your contributions to Adapted Material in accordance with the terms +and conditions of this Public License. + +c. Copyright and Similar Rights means copyright and/or similar rights closely +related to copyright including, without limitation, performance, broadcast, +sound recording, and Sui Generis Database Rights, without regard to how the +rights are labeled or categorized. For purposes of this Public License, the +rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. + +d. Effective Technological Measures means those measures that, in the absence +of proper authority, may not be circumvented under laws fulfilling obligations +under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, +and/or similar international agreements. + +e. Exceptions and Limitations means fair use, fair dealing, and/or any other +exception or limitation to Copyright and Similar Rights that applies to Your +use of the Licensed Material. + +f. Licensed Material means the artistic or literary work, database, or other +material to which the Licensor applied this Public License. + +g. Licensed Rights means the rights granted to You subject to the terms and +conditions of this Public License, which are limited to all Copyright and +Similar Rights that apply to Your use of the Licensed Material and that the +Licensor has authority to license. + +h. Licensor means the individual(s) or entity(ies) granting rights under this +Public License. + +i. Share means to provide material to the public by any means or process that +requires permission under the Licensed Rights, such as reproduction, public +display, public performance, distribution, dissemination, communication, or +importation, and to make material available to the public including in ways +that members of the public may access the material from a place and at a time +individually chosen by them. + +j. Sui Generis Database Rights means rights other than copyright resulting +from Directive 96/9/EC of the European Parliament and of the Council of 11 +March 1996 on the legal protection of databases, as amended and/or succeeded, +as well as other essentially equivalent rights anywhere in the world. + +k. You means the individual or entity exercising the Licensed Rights under +this Public License. Your has a corresponding meaning. + +Section 2 – Scope. + + a. License grant. + +1. Subject to the terms and conditions of this Public License, the Licensor +hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, +irrevocable license to exercise the Licensed Rights in the Licensed Material +to: + + A. reproduce and Share the Licensed Material, in whole or in part; and + + B. produce, reproduce, and Share Adapted Material. + +2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions +and Limitations apply to Your use, this Public License does not apply, and +You do not need to comply with its terms and conditions. + + 3. Term. The term of this Public License is specified in Section 6(a). + +4. Media and formats; technical modifications allowed. The Licensor authorizes +You to exercise the Licensed Rights in all media and formats whether now known +or hereafter created, and to make technical modifications necessary to do +so. The Licensor waives and/or agrees not to assert any right or authority +to forbid You from making technical modifications necessary to exercise the +Licensed Rights, including technical modifications necessary to circumvent +Effective Technological Measures. For purposes of this Public License, simply +making modifications authorized by this Section 2(a)(4) never produces Adapted +Material. + + 5. Downstream recipients. + +A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed +Material automatically receives an offer from the Licensor to exercise the +Licensed Rights under the terms and conditions of this Public License. + +B. No downstream restrictions. You may not offer or impose any additional +or different terms or conditions on, or apply any Effective Technological +Measures to, the Licensed Material if doing so restricts exercise of the Licensed +Rights by any recipient of the Licensed Material. + +6. No endorsement. Nothing in this Public License constitutes or may be construed +as permission to assert or imply that You are, or that Your use of the Licensed +Material is, connected with, or sponsored, endorsed, or granted official status +by, the Licensor or others designated to receive attribution as provided in +Section 3(a)(1)(A)(i). + + b. Other rights. + +1. Moral rights, such as the right of integrity, are not licensed under this +Public License, nor are publicity, privacy, and/or other similar personality +rights; however, to the extent possible, the Licensor waives and/or agrees +not to assert any such rights held by the Licensor to the limited extent necessary +to allow You to exercise the Licensed Rights, but not otherwise. + +2. Patent and trademark rights are not licensed under this Public License. + +3. To the extent possible, the Licensor waives any right to collect royalties +from You for the exercise of the Licensed Rights, whether directly or through +a collecting society under any voluntary or waivable statutory or compulsory +licensing scheme. In all other cases the Licensor expressly reserves any right +to collect such royalties. + +Section 3 – License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the following +conditions. + + a. Attribution. + +1. If You Share the Licensed Material (including in modified form), You must: + +A. retain the following if it is supplied by the Licensor with the Licensed +Material: + +i. identification of the creator(s) of the Licensed Material and any others +designated to receive attribution, in any reasonable manner requested by the +Licensor (including by pseudonym if designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of warranties; + +v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; + +B. indicate if You modified the Licensed Material and retain an indication +of any previous modifications; and + +C. indicate the Licensed Material is licensed under this Public License, and +include the text of, or the URI or hyperlink to, this Public License. + +2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner +based on the medium, means, and context in which You Share the Licensed Material. +For example, it may be reasonable to satisfy the conditions by providing a +URI or hyperlink to a resource that includes the required information. + +3. If requested by the Licensor, You must remove any of the information required +by Section 3(a)(1)(A) to the extent reasonably practicable. + +4. If You Share Adapted Material You produce, the Adapter's License You apply +must not prevent recipients of the Adapted Material from complying with this +Public License. + +Section 4 – Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that apply to +Your use of the Licensed Material: + +a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, +reuse, reproduce, and Share all or a substantial portion of the contents of +the database; + +b. if You include all or a substantial portion of the database contents in +a database in which You have Sui Generis Database Rights, then the database +in which You have Sui Generis Database Rights (but not its individual contents) +is Adapted Material; and + +c. You must comply with the conditions in Section 3(a) if You Share all or +a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not replace +Your obligations under this Public License where the Licensed Rights include +other Copyright and Similar Rights. + +Section 5 – Disclaimer of Warranties and Limitation of Liability. + +a. Unless otherwise separately undertaken by the Licensor, to the extent possible, +the Licensor offers the Licensed Material as-is and as-available, and makes +no representations or warranties of any kind concerning the Licensed Material, +whether express, implied, statutory, or other. This includes, without limitation, +warranties of title, merchantability, fitness for a particular purpose, non-infringement, +absence of latent or other defects, accuracy, or the presence or absence of +errors, whether or not known or discoverable. Where disclaimers of warranties +are not allowed in full or in part, this disclaimer may not apply to You. + +b. To the extent possible, in no event will the Licensor be liable to You +on any legal theory (including, without limitation, negligence) or otherwise +for any direct, special, indirect, incidental, consequential, punitive, exemplary, +or other losses, costs, expenses, or damages arising out of this Public License +or use of the Licensed Material, even if the Licensor has been advised of +the possibility of such losses, costs, expenses, or damages. Where a limitation +of liability is not allowed in full or in part, this limitation may not apply +to You. + +c. The disclaimer of warranties and limitation of liability provided above +shall be interpreted in a manner that, to the extent possible, most closely +approximates an absolute disclaimer and waiver of all liability. + +Section 6 – Term and Termination. + +a. This Public License applies for the term of the Copyright and Similar Rights +licensed here. However, if You fail to comply with this Public License, then +Your rights under this Public License terminate automatically. + +b. Where Your right to use the Licensed Material has terminated under Section +6(a), it reinstates: + +1. automatically as of the date the violation is cured, provided it is cured +within 30 days of Your discovery of the violation; or + + 2. upon express reinstatement by the Licensor. + +c. For the avoidance of doubt, this Section 6(b) does not affect any right +the Licensor may have to seek remedies for Your violations of this Public +License. + +d. For the avoidance of doubt, the Licensor may also offer the Licensed Material +under separate terms or conditions or stop distributing the Licensed Material +at any time; however, doing so will not terminate this Public License. + + e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. + +Section 7 – Other Terms and Conditions. + +a. The Licensor shall not be bound by any additional or different terms or +conditions communicated by You unless expressly agreed. + +b. Any arrangements, understandings, or agreements regarding the Licensed +Material not stated herein are separate from and independent of the terms +and conditions of this Public License. + +Section 8 – Interpretation. + +a. For the avoidance of doubt, this Public License does not, and shall not +be interpreted to, reduce, limit, restrict, or impose conditions on any use +of the Licensed Material that could lawfully be made without permission under +this Public License. + +b. To the extent possible, if any provision of this Public License is deemed +unenforceable, it shall be automatically reformed to the minimum extent necessary +to make it enforceable. If the provision cannot be reformed, it shall be severed +from this Public License without affecting the enforceability of the remaining +terms and conditions. + +c. No term or condition of this Public License will be waived and no failure +to comply consented to unless expressly agreed to by the Licensor. + +d. Nothing in this Public License constitutes or may be interpreted as a limitation +upon, or waiver of, any privileges and immunities that apply to the Licensor +or You, including from the legal processes of any jurisdiction or authority. + +Creative Commons is not a party to its public licenses. Notwithstanding, Creative +Commons may elect to apply one of its public licenses to material it publishes +and in those instances will be considered the "Licensor." The text of the +Creative Commons public licenses is dedicated to the public domain under the +CC0 Public Domain Dedication. Except for the limited purpose of indicating +that material is shared under a Creative Commons public license or as otherwise +permitted by the Creative Commons policies published at creativecommons.org/policies, +Creative Commons does not authorize the use of the trademark "Creative Commons" +or any other trademark or logo of Creative Commons without its prior written +consent including, without limitation, in connection with any unauthorized +modifications to any of its public licenses or any other arrangements, understandings, +or agreements concerning use of licensed material. For the avoidance of doubt, +this paragraph does not form part of the public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/LICENSES/CC-BY-SA-4.0.txt b/LICENSES/CC-BY-SA-4.0.txt new file mode 100644 index 0000000..8a0f891 --- /dev/null +++ b/LICENSES/CC-BY-SA-4.0.txt @@ -0,0 +1,108 @@ +Text +Creative Commons Attribution-ShareAlike 4.0 International + +Creative Commons Corporation ("Creative Commons") is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an "as-is" basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. + +Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors : wiki.creativecommons.org/Considerations_for_licensors + +Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor's permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. + +Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public : wiki.creativecommons.org/Considerations_for_licensees + +Creative Commons Attribution-ShareAlike 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. + +Section 1 – Definitions. + +a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. +b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. +c. BY-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License. +d. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. +e. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. +f. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. +g. License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike. +h. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. +i. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. +j. Licensor means the individual(s) or entity(ies) granting rights under this Public License. +k. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. +l. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. +m. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. +Section 2 – Scope. + +a. License grant. +1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: +A. reproduce and Share the Licensed Material, in whole or in part; and +B. produce, reproduce, and Share Adapted Material. +2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. +3. Term. The term of this Public License is specified in Section 6(a). +4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. +5. Downstream recipients. +A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. +B. Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter's License You apply. +C. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. +6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). +b. Other rights. +1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. +2. Patent and trademark rights are not licensed under this Public License. +3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties. +Section 3 – License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the following conditions. + +a. Attribution. +1. If You Share the Licensed Material (including in modified form), You must: +A. retain the following if it is supplied by the Licensor with the Licensed Material: +i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); +ii. a copyright notice; +iii. a notice that refers to this Public License; +iv. a notice that refers to the disclaimer of warranties; +v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; + +B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and +C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. +2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. +3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. +b. ShareAlike.In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply. +1. The Adapter's License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License. +2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material. +3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply. +Section 4 – Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: + +a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database; +b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and +c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. +For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. +Section 5 – Disclaimer of Warranties and Limitation of Liability. + +a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. +b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. +c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. +Section 6 – Term and Termination. + +a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. +b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: +1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or +2. upon express reinstatement by the Licensor. +c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. +d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. +e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. +Section 7 – Other Terms and Conditions. + +a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. +b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. +Section 8 – Interpretation. + +a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. +b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. +c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. +d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. +Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the "Licensor." The text of the Creative Commons public licenses is dedicated to the public domain under the CC0 Public Domain Dedication. Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark "Creative Commons" or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt new file mode 100644 index 0000000..204b93d --- /dev/null +++ b/LICENSES/MIT.txt @@ -0,0 +1,19 @@ +MIT License Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/LICENSES/Unlicense.txt b/LICENSES/Unlicense.txt new file mode 100644 index 0000000..24a8f90 --- /dev/null +++ b/LICENSES/Unlicense.txt @@ -0,0 +1,20 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or distribute +this software, either in source code form or as a compiled binary, for any +purpose, commercial or non-commercial, and by any means. + +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and +to the detriment of our heirs and successors. We intend this dedication to +be an overt act of relinquishment in perpetuity of all present and future +rights to this software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH +THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, +please refer to diff --git a/README.rst b/README.rst index 6e5f951..1ac29a3 100644 --- a/README.rst +++ b/README.rst @@ -79,7 +79,7 @@ Azure IoT Hub To interact with Azure IoT Hub, you will need to create a hub, and a register a device inside that hub. There is a free tier available, and this free tier allows up to 8,000 messages a day, so try not to send messages too often if you are using this tier. -- Open the `Azure Portal `_. +- Open the `Azure Portal `_. - Follow the instructions in `Microsoft Docs `_ to create an Azure IoT Hub and register a device. - Copy the devices Primary or secondary connection string, and add this to your ``secrets.py`` file. @@ -169,7 +169,7 @@ Azure IoT Central To use Azure IoT Central, you will need to create an Azure IoT Central app, create a device template and register a device against the template. -- Head to `Azure IoT Central `__ +- Head to `Azure IoT Central `__ - Follow the instructions in the `Microsoft Docs `__ to create an application. Every tier is free for up to 2 devices. - Follow the instructions in the `Microsoft Docs `__ to create a device template. - Create a device based off the template, and select **Connect** to get the device connection details. Store the ID Scope, Device ID and either the Primary or secondary Key in your ``secrets.py`` file. diff --git a/README.rst.license b/README.rst.license new file mode 100644 index 0000000..11cd75d --- /dev/null +++ b/README.rst.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries + +SPDX-License-Identifier: MIT diff --git a/adafruit_azureiot/__init__.py b/adafruit_azureiot/__init__.py index 7ef6597..1fd6b11 100644 --- a/adafruit_azureiot/__init__.py +++ b/adafruit_azureiot/__init__.py @@ -1,24 +1,8 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: 2020 Jim Bennet for Adafruit Industries +# SPDX-FileCopyrightText: 2020 Elena Horton for Adafruit Industries # -# Copyright (c) 2020 Jim Bennett -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT + """ `adafruit_azureiot` ================================================================================ diff --git a/adafruit_azureiot/base64.py b/adafruit_azureiot/base64.py index ab74bec..5f7f70e 100644 --- a/adafruit_azureiot/base64.py +++ b/adafruit_azureiot/base64.py @@ -1,24 +1,7 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: 2020 Jim Bennet for Adafruit Industries # -# Copyright (c) 2020 Jim Bennett -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT + """ `base64` ================================================================================ @@ -47,7 +30,9 @@ def _bytes_from_decode_data(data: str): try: return data.encode("ascii") except Exception as exc: - raise ValueError("string argument should contain only ASCII characters") from exc + raise ValueError( + "string argument should contain only ASCII characters" + ) from exc def b64encode(toencode: bytes) -> bytes: diff --git a/adafruit_azureiot/constants.py b/adafruit_azureiot/constants.py index 5770342..f6da145 100644 --- a/adafruit_azureiot/constants.py +++ b/adafruit_azureiot/constants.py @@ -1,24 +1,8 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: 2020 Jim Bennet for Adafruit Industries +# SPDX-FileCopyrightText: 2020 Elena Horton for Adafruit Industries # -# Copyright (c) 2020 Jim Bennett -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT + """ `constants` ================================================================================ diff --git a/adafruit_azureiot/device_registration.py b/adafruit_azureiot/device_registration.py index 15f85df..7fbea17 100644 --- a/adafruit_azureiot/device_registration.py +++ b/adafruit_azureiot/device_registration.py @@ -1,24 +1,8 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: 2020 Jim Bennet for Adafruit Industries +# SPDX-FileCopyrightText: 2020 Elena Horton for Adafruit Industries # -# Copyright (c) 2020 Jim Bennett -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT + """ `device_registration` ===================== @@ -70,9 +54,13 @@ def _parse_http_status(status_code: int, status_reason: str) -> None: """ for error in AZURE_HTTP_ERROR_CODES: if error == status_code: - raise DeviceRegistrationError("Error {0}: {1}".format(status_code, status_reason)) + raise DeviceRegistrationError( + "Error {0}: {1}".format(status_code, status_reason) + ) - def __init__(self, socket, id_scope: str, device_id: str, key: str, logger: Logger = None): + def __init__( + self, socket, id_scope: str, device_id: str, key: str, logger: Logger = None + ): """Creates an instance of the device registration service :param socket: The network socket :param str id_scope: The ID scope of the device to register @@ -141,7 +129,10 @@ def _run_put_request_with_retry(self, url, body, headers): self._logger.debug("Sent!") break except RuntimeError as runtime_error: - self._logger.info("Could not send data, retrying after 0.5 seconds: " + str(runtime_error)) + self._logger.info( + "Could not send data, retrying after 0.5 seconds: " + + str(runtime_error) + ) retry = retry + 1 if retry >= 10: @@ -166,7 +157,10 @@ def _run_get_request_with_retry(self, url, headers): self._logger.debug("Sent!") break except RuntimeError as runtime_error: - self._logger.info("Could not send data, retrying after 0.5 seconds: " + str(runtime_error)) + self._logger.info( + "Could not send data, retrying after 0.5 seconds: " + + str(runtime_error) + ) retry = retry + 1 if retry >= 10: @@ -191,9 +185,19 @@ def register_device(self, expiry: int) -> str: """ # pylint: disable=C0103 sr = self._id_scope + "%2Fregistrations%2F" + self._device_id - sig_no_encode = compute_derived_symmetric_key(self._key, sr + "\n" + str(expiry)) + sig_no_encode = compute_derived_symmetric_key( + self._key, sr + "\n" + str(expiry) + ) sig_encoded = quote(sig_no_encode, "~()*!.'") - auth_string = "SharedAccessSignature sr=" + sr + "&sig=" + sig_encoded + "&se=" + str(expiry) + "&skn=registration" + auth_string = ( + "SharedAccessSignature sr=" + + sr + + "&sig=" + + sig_encoded + + "&se=" + + str(expiry) + + "&skn=registration" + ) headers = { "content-type": "application/json; charset=utf-8", @@ -223,7 +227,14 @@ def register_device(self, expiry: int) -> str: try: data = response.json() except ValueError as error: - err = "ERROR: non JSON is received from " + constants.DPS_END_POINT + " => " + str(response) + " .. message : " + str(error) + err = ( + "ERROR: non JSON is received from " + + constants.DPS_END_POINT + + " => " + + str(response) + + " .. message : " + + str(error) + ) self._logger.error(err) raise DeviceRegistrationError(err) from error diff --git a/adafruit_azureiot/hmac.py b/adafruit_azureiot/hmac.py index ec9737f..e0c931c 100644 --- a/adafruit_azureiot/hmac.py +++ b/adafruit_azureiot/hmac.py @@ -1,24 +1,7 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: 2020 Jim Bennet for Adafruit Industries # -# Copyright (c) 2020 Jim Bennett -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT + """ `HMAC` ================================================================================ @@ -77,7 +60,9 @@ def sha_init(): return sha_info -ROR = lambda x, y: (((x & 0xFFFFFFFF) >> (y & 31)) | (x << (32 - (y & 31)))) & 0xFFFFFFFF +ROR = ( + lambda x, y: (((x & 0xFFFFFFFF) >> (y & 31)) | (x << (32 - (y & 31)))) & 0xFFFFFFFF +) Ch = lambda x, y, z: (z ^ (x & (y ^ z))) Maj = lambda x, y, z: (((x | y) & z) | (x & y)) S = lambda x, n: ROR(x, n) @@ -93,10 +78,14 @@ def sha_transform(sha_info): d = sha_info["data"] for i in range(0, 16): - W.append((d[4 * i] << 24) + (d[4 * i + 1] << 16) + (d[4 * i + 2] << 8) + d[4 * i + 3]) + W.append( + (d[4 * i] << 24) + (d[4 * i + 1] << 16) + (d[4 * i + 2] << 8) + d[4 * i + 3] + ) for i in range(16, 64): - W.append((Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16]) & 0xFFFFFFFF) + W.append( + (Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16]) & 0xFFFFFFFF + ) ss = sha_info["digest"][:] @@ -109,70 +98,198 @@ def RND(a, b, c, d, e, f, g, h, i, ki): h = t0 + t1 return d & 0xFFFFFFFF, h & 0xFFFFFFFF - ss[3], ss[7] = RND(ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], 0, 0x428A2F98) - ss[2], ss[6] = RND(ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], 1, 0x71374491) - ss[1], ss[5] = RND(ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], 2, 0xB5C0FBCF) - ss[0], ss[4] = RND(ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], 3, 0xE9B5DBA5) - ss[7], ss[3] = RND(ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], 4, 0x3956C25B) - ss[6], ss[2] = RND(ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], 5, 0x59F111F1) - ss[5], ss[1] = RND(ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], 6, 0x923F82A4) - ss[4], ss[0] = RND(ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], 7, 0xAB1C5ED5) - ss[3], ss[7] = RND(ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], 8, 0xD807AA98) - ss[2], ss[6] = RND(ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], 9, 0x12835B01) - ss[1], ss[5] = RND(ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], 10, 0x243185BE) - ss[0], ss[4] = RND(ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], 11, 0x550C7DC3) - ss[7], ss[3] = RND(ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], 12, 0x72BE5D74) - ss[6], ss[2] = RND(ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], 13, 0x80DEB1FE) - ss[5], ss[1] = RND(ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], 14, 0x9BDC06A7) - ss[4], ss[0] = RND(ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], 15, 0xC19BF174) - ss[3], ss[7] = RND(ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], 16, 0xE49B69C1) - ss[2], ss[6] = RND(ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], 17, 0xEFBE4786) - ss[1], ss[5] = RND(ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], 18, 0x0FC19DC6) - ss[0], ss[4] = RND(ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], 19, 0x240CA1CC) - ss[7], ss[3] = RND(ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], 20, 0x2DE92C6F) - ss[6], ss[2] = RND(ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], 21, 0x4A7484AA) - ss[5], ss[1] = RND(ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], 22, 0x5CB0A9DC) - ss[4], ss[0] = RND(ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], 23, 0x76F988DA) - ss[3], ss[7] = RND(ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], 24, 0x983E5152) - ss[2], ss[6] = RND(ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], 25, 0xA831C66D) - ss[1], ss[5] = RND(ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], 26, 0xB00327C8) - ss[0], ss[4] = RND(ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], 27, 0xBF597FC7) - ss[7], ss[3] = RND(ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], 28, 0xC6E00BF3) - ss[6], ss[2] = RND(ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], 29, 0xD5A79147) - ss[5], ss[1] = RND(ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], 30, 0x06CA6351) - ss[4], ss[0] = RND(ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], 31, 0x14292967) - ss[3], ss[7] = RND(ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], 32, 0x27B70A85) - ss[2], ss[6] = RND(ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], 33, 0x2E1B2138) - ss[1], ss[5] = RND(ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], 34, 0x4D2C6DFC) - ss[0], ss[4] = RND(ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], 35, 0x53380D13) - ss[7], ss[3] = RND(ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], 36, 0x650A7354) - ss[6], ss[2] = RND(ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], 37, 0x766A0ABB) - ss[5], ss[1] = RND(ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], 38, 0x81C2C92E) - ss[4], ss[0] = RND(ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], 39, 0x92722C85) - ss[3], ss[7] = RND(ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], 40, 0xA2BFE8A1) - ss[2], ss[6] = RND(ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], 41, 0xA81A664B) - ss[1], ss[5] = RND(ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], 42, 0xC24B8B70) - ss[0], ss[4] = RND(ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], 43, 0xC76C51A3) - ss[7], ss[3] = RND(ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], 44, 0xD192E819) - ss[6], ss[2] = RND(ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], 45, 0xD6990624) - ss[5], ss[1] = RND(ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], 46, 0xF40E3585) - ss[4], ss[0] = RND(ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], 47, 0x106AA070) - ss[3], ss[7] = RND(ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], 48, 0x19A4C116) - ss[2], ss[6] = RND(ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], 49, 0x1E376C08) - ss[1], ss[5] = RND(ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], 50, 0x2748774C) - ss[0], ss[4] = RND(ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], 51, 0x34B0BCB5) - ss[7], ss[3] = RND(ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], 52, 0x391C0CB3) - ss[6], ss[2] = RND(ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], 53, 0x4ED8AA4A) - ss[5], ss[1] = RND(ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], 54, 0x5B9CCA4F) - ss[4], ss[0] = RND(ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], 55, 0x682E6FF3) - ss[3], ss[7] = RND(ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], 56, 0x748F82EE) - ss[2], ss[6] = RND(ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], 57, 0x78A5636F) - ss[1], ss[5] = RND(ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], 58, 0x84C87814) - ss[0], ss[4] = RND(ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], 59, 0x8CC70208) - ss[7], ss[3] = RND(ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], 60, 0x90BEFFFA) - ss[6], ss[2] = RND(ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], 61, 0xA4506CEB) - ss[5], ss[1] = RND(ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], 62, 0xBEF9A3F7) - ss[4], ss[0] = RND(ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], 63, 0xC67178F2) + ss[3], ss[7] = RND( + ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], 0, 0x428A2F98 + ) + ss[2], ss[6] = RND( + ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], 1, 0x71374491 + ) + ss[1], ss[5] = RND( + ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], 2, 0xB5C0FBCF + ) + ss[0], ss[4] = RND( + ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], 3, 0xE9B5DBA5 + ) + ss[7], ss[3] = RND( + ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], 4, 0x3956C25B + ) + ss[6], ss[2] = RND( + ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], 5, 0x59F111F1 + ) + ss[5], ss[1] = RND( + ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], 6, 0x923F82A4 + ) + ss[4], ss[0] = RND( + ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], 7, 0xAB1C5ED5 + ) + ss[3], ss[7] = RND( + ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], 8, 0xD807AA98 + ) + ss[2], ss[6] = RND( + ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], 9, 0x12835B01 + ) + ss[1], ss[5] = RND( + ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], 10, 0x243185BE + ) + ss[0], ss[4] = RND( + ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], 11, 0x550C7DC3 + ) + ss[7], ss[3] = RND( + ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], 12, 0x72BE5D74 + ) + ss[6], ss[2] = RND( + ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], 13, 0x80DEB1FE + ) + ss[5], ss[1] = RND( + ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], 14, 0x9BDC06A7 + ) + ss[4], ss[0] = RND( + ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], 15, 0xC19BF174 + ) + ss[3], ss[7] = RND( + ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], 16, 0xE49B69C1 + ) + ss[2], ss[6] = RND( + ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], 17, 0xEFBE4786 + ) + ss[1], ss[5] = RND( + ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], 18, 0x0FC19DC6 + ) + ss[0], ss[4] = RND( + ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], 19, 0x240CA1CC + ) + ss[7], ss[3] = RND( + ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], 20, 0x2DE92C6F + ) + ss[6], ss[2] = RND( + ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], 21, 0x4A7484AA + ) + ss[5], ss[1] = RND( + ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], 22, 0x5CB0A9DC + ) + ss[4], ss[0] = RND( + ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], 23, 0x76F988DA + ) + ss[3], ss[7] = RND( + ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], 24, 0x983E5152 + ) + ss[2], ss[6] = RND( + ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], 25, 0xA831C66D + ) + ss[1], ss[5] = RND( + ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], 26, 0xB00327C8 + ) + ss[0], ss[4] = RND( + ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], 27, 0xBF597FC7 + ) + ss[7], ss[3] = RND( + ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], 28, 0xC6E00BF3 + ) + ss[6], ss[2] = RND( + ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], 29, 0xD5A79147 + ) + ss[5], ss[1] = RND( + ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], 30, 0x06CA6351 + ) + ss[4], ss[0] = RND( + ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], 31, 0x14292967 + ) + ss[3], ss[7] = RND( + ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], 32, 0x27B70A85 + ) + ss[2], ss[6] = RND( + ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], 33, 0x2E1B2138 + ) + ss[1], ss[5] = RND( + ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], 34, 0x4D2C6DFC + ) + ss[0], ss[4] = RND( + ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], 35, 0x53380D13 + ) + ss[7], ss[3] = RND( + ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], 36, 0x650A7354 + ) + ss[6], ss[2] = RND( + ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], 37, 0x766A0ABB + ) + ss[5], ss[1] = RND( + ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], 38, 0x81C2C92E + ) + ss[4], ss[0] = RND( + ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], 39, 0x92722C85 + ) + ss[3], ss[7] = RND( + ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], 40, 0xA2BFE8A1 + ) + ss[2], ss[6] = RND( + ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], 41, 0xA81A664B + ) + ss[1], ss[5] = RND( + ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], 42, 0xC24B8B70 + ) + ss[0], ss[4] = RND( + ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], 43, 0xC76C51A3 + ) + ss[7], ss[3] = RND( + ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], 44, 0xD192E819 + ) + ss[6], ss[2] = RND( + ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], 45, 0xD6990624 + ) + ss[5], ss[1] = RND( + ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], 46, 0xF40E3585 + ) + ss[4], ss[0] = RND( + ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], 47, 0x106AA070 + ) + ss[3], ss[7] = RND( + ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], 48, 0x19A4C116 + ) + ss[2], ss[6] = RND( + ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], 49, 0x1E376C08 + ) + ss[1], ss[5] = RND( + ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], 50, 0x2748774C + ) + ss[0], ss[4] = RND( + ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], 51, 0x34B0BCB5 + ) + ss[7], ss[3] = RND( + ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], 52, 0x391C0CB3 + ) + ss[6], ss[2] = RND( + ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], 53, 0x4ED8AA4A + ) + ss[5], ss[1] = RND( + ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], 54, 0x5B9CCA4F + ) + ss[4], ss[0] = RND( + ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], 55, 0x682E6FF3 + ) + ss[3], ss[7] = RND( + ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], 56, 0x748F82EE + ) + ss[2], ss[6] = RND( + ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], 57, 0x78A5636F + ) + ss[1], ss[5] = RND( + ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], ss[5], 58, 0x84C87814 + ) + ss[0], ss[4] = RND( + ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], ss[4], 59, 0x8CC70208 + ) + ss[7], ss[3] = RND( + ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], ss[3], 60, 0x90BEFFFA + ) + ss[6], ss[2] = RND( + ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], ss[2], 61, 0xA4506CEB + ) + ss[5], ss[1] = RND( + ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], ss[1], 62, 0xBEF9A3F7 + ) + ss[4], ss[0] = RND( + ss[1], ss[2], ss[3], ss[4], ss[5], ss[6], ss[7], ss[0], 63, 0xC67178F2 + ) # Feedback dig = [] @@ -264,7 +381,9 @@ def sha_final(sha_info): dig = [] for i in sha_info["digest"]: - dig.extend([((i >> 24) & 0xFF), ((i >> 16) & 0xFF), ((i >> 8) & 0xFF), (i & 0xFF)]) + dig.extend( + [((i >> 24) & 0xFF), ((i >> 16) & 0xFF), ((i >> 8) & 0xFF), (i & 0xFF)] + ) return bytes(dig) @@ -275,8 +394,7 @@ class sha256: name = "sha256" def __init__(self, s=None): - """Constructs a SHA256 hash object. - """ + """Constructs a SHA256 hash object.""" self._sha = sha_init() if s: sha_update(self._sha, getbuf(s)) @@ -297,8 +415,7 @@ def hexdigest(self): return "".join(["%.2x" % i for i in self.digest()]) def copy(self): - """Return a copy (“clone”) of the hash object. - """ + """Return a copy (“clone”) of the hash object.""" new = sha256() new._sha = self._sha.copy() return new @@ -328,7 +445,9 @@ def __init__(self, key, msg=None): """ if not isinstance(key, (bytes, bytearray)): - raise TypeError("key: expected bytes or bytearray, but got %r" % type(key).__name__) + raise TypeError( + "key: expected bytes or bytearray, but got %r" % type(key).__name__ + ) digestmod = sha256 @@ -360,13 +479,11 @@ def __init__(self, key, msg=None): @property def name(self): - """Return the name of this object - """ + """Return the name of this object""" return "hmac-" + self.inner.name def update(self, msg): - """Update this hashing object with the string msg. - """ + """Update this hashing object with the string msg.""" self.inner.update(msg) def copy(self): @@ -402,8 +519,7 @@ def digest(self): return hmac.digest() def hexdigest(self): - """Like digest(), but returns a string of hexadecimal digits instead. - """ + """Like digest(), but returns a string of hexadecimal digits instead.""" hmac = self._current() return hmac.hexdigest() diff --git a/adafruit_azureiot/iot_error.py b/adafruit_azureiot/iot_error.py index 1ca604b..833313a 100644 --- a/adafruit_azureiot/iot_error.py +++ b/adafruit_azureiot/iot_error.py @@ -1,24 +1,8 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: 2020 Jim Bennet for Adafruit Industries +# SPDX-FileCopyrightText: 2020 Elena Horton for Adafruit Industries # -# Copyright (c) 2020 Jim Bennett -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT + """ `iot_error` ===================== diff --git a/adafruit_azureiot/iot_mqtt.py b/adafruit_azureiot/iot_mqtt.py index 04f53f2..9f32209 100644 --- a/adafruit_azureiot/iot_mqtt.py +++ b/adafruit_azureiot/iot_mqtt.py @@ -1,24 +1,8 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: 2020 Jim Bennet for Adafruit Industries +# SPDX-FileCopyrightText: 2020 Elena Horton for Adafruit Industries # -# Copyright (c) 2020 Jim Bennett -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT + """ `iot_mqtt` ===================== @@ -41,8 +25,7 @@ # pylint: disable=R0903 class IoTResponse: - """A response from a direct method call - """ + """A response from a direct method call""" def __init__(self, code: int, message: str): """Creates an IoT Response object @@ -54,8 +37,7 @@ def __init__(self, code: int, message: str): class IoTMQTTCallback: - """An interface for classes that can be called by MQTT events - """ + """An interface for classes that can be called by MQTT events""" def message_sent(self, data: str) -> None: """Called when a message is sent to the cloud @@ -84,14 +66,21 @@ def cloud_to_device_message_received(self, body: str, properties: dict) -> None: :param dict properties: The propreties sent with the mesage """ - def device_twin_desired_updated(self, desired_property_name: str, desired_property_value, desired_version: int) -> None: + def device_twin_desired_updated( + self, desired_property_name: str, desired_property_value, desired_version: int + ) -> None: """Called when the device twin desired properties are updated :param str desired_property_name: The name of the desired property that was updated :param desired_property_value: The value of the desired property that was updated :param int desired_version: The version of the desired property that was updated """ - def device_twin_reported_updated(self, reported_property_name: str, reported_property_value, reported_version: int) -> None: + def device_twin_reported_updated( + self, + reported_property_name: str, + reported_property_value, + reported_version: int, + ) -> None: """Called when the device twin reported values are updated :param str reported_property_name: The name of the reported property that was updated :param reported_property_value: The value of the reported property that was updated @@ -101,17 +90,22 @@ def device_twin_reported_updated(self, reported_property_name: str, reported_pro # pylint: disable=R0902 class IoTMQTT: - """MQTT client for Azure IoT - """ + """MQTT client for Azure IoT""" def _gen_sas_token(self) -> str: token_expiry = int(time.time() + self._token_expires) uri = self._hostname + "%2Fdevices%2F" + self._device_id - signed_hmac_sha256 = compute_derived_symmetric_key(self._key, uri + "\n" + str(token_expiry)) + signed_hmac_sha256 = compute_derived_symmetric_key( + self._key, uri + "\n" + str(token_expiry) + ) signature = quote(signed_hmac_sha256, "~()*!.'") - if signature.endswith("\n"): # somewhere along the crypto chain a newline is inserted + if signature.endswith( + "\n" + ): # somewhere along the crypto chain a newline is inserted signature = signature[:-1] - token = "SharedAccessSignature sr={}&sig={}&se={}".format(uri, signature, token_expiry) + token = "SharedAccessSignature sr={}&sig={}&se={}".format( + uri, signature, token_expiry + ) return token def _create_mqtt_client(self) -> None: @@ -141,7 +135,12 @@ def _create_mqtt_client(self) -> None: # pylint: disable=C0103, W0613 def _on_connect(self, client, userdata, _, rc) -> None: - self._logger.info("- iot_mqtt :: _on_connect :: rc = " + str(rc) + ", userdata = " + str(userdata)) + self._logger.info( + "- iot_mqtt :: _on_connect :: rc = " + + str(rc) + + ", userdata = " + + str(userdata) + ) if rc == 0: self._mqtt_connected = True self._auth_response_received = True @@ -168,7 +167,9 @@ def _on_disconnect(self, client, userdata, rc) -> None: self._callback.connection_status_change(False) def _on_publish(self, client, data, topic, msg_id) -> None: - self._logger.info("- iot_mqtt :: _on_publish :: " + str(data) + " on topic " + str(topic)) + self._logger.info( + "- iot_mqtt :: _on_publish :: " + str(data) + " on topic " + str(topic) + ) # pylint: disable=W0703 def _handle_device_twin_update(self, client, topic: str, msg: str) -> None: @@ -179,7 +180,12 @@ def _handle_device_twin_update(self, client, topic: str, msg: str) -> None: try: twin = json.loads(msg) except json.JSONDecodeError as e: - self._logger.error("ERROR: JSON parse for Device Twin message object has failed. => " + msg + " => " + str(e)) + self._logger.error( + "ERROR: JSON parse for Device Twin message object has failed. => " + + msg + + " => " + + str(e) + ) return if "reported" in twin: @@ -189,11 +195,15 @@ def _handle_device_twin_update(self, client, topic: str, msg: str) -> None: reported_version = reported["$version"] reported.pop("$version") else: - self._logger.error("ERROR: Unexpected payload for reported twin update => " + msg) + self._logger.error( + "ERROR: Unexpected payload for reported twin update => " + msg + ) return for property_name, value in reported.items(): - self._callback.device_twin_reported_updated(property_name, value, reported_version) + self._callback.device_twin_reported_updated( + property_name, value, reported_version + ) is_patch = "desired" not in twin @@ -206,11 +216,15 @@ def _handle_device_twin_update(self, client, topic: str, msg: str) -> None: desired_version = desired["$version"] desired.pop("$version") else: - self._logger.error("ERROR: Unexpected payload for desired twin update => " + msg) + self._logger.error( + "ERROR: Unexpected payload for desired twin update => " + msg + ) return for property_name, value in desired.items(): - self._callback.device_twin_desired_updated(property_name, value, desired_version) + self._callback.device_twin_desired_updated( + property_name, value, desired_version + ) def _handle_direct_method(self, client, topic: str, msg: str) -> None: index = topic.find("$rid=") @@ -240,7 +254,14 @@ def _handle_direct_method(self, client, topic: str, msg: str) -> None: ret_message = json.dumps(ret_json) next_topic = "$iothub/methods/res/{}/?$rid={}".format(ret_code, method_id) - self._logger.info("C2D: => " + next_topic + " with data " + ret_message + " and name => " + method_name) + self._logger.info( + "C2D: => " + + next_topic + + " with data " + + ret_message + + " and name => " + + method_name + ) self._send_common(next_topic, ret_message) def _handle_cloud_to_device_message(self, client, topic: str, msg: str) -> None: @@ -275,7 +296,10 @@ def _send_common(self, topic: str, data) -> None: self._logger.debug("Data sent") break except RuntimeError as runtime_error: - self._logger.info("Could not send data, retrying after 0.5 seconds: " + str(runtime_error)) + self._logger.info( + "Could not send data, retrying after 0.5 seconds: " + + str(runtime_error) + ) retry = retry + 1 if retry >= 10: @@ -324,24 +348,34 @@ def __init__( self._hostname = hostname self._key = key self._token_expires = token_expires - self._username = "{}/{}/api-version={}".format(self._hostname, device_id, constants.IOTC_API_VERSION) + self._username = "{}/{}/api-version={}".format( + self._hostname, device_id, constants.IOTC_API_VERSION + ) self._passwd = self._gen_sas_token() self._logger = logger if logger is not None else logging.getLogger("log") self._is_subscribed_to_twins = False def _subscribe_to_core_topics(self): device_bound_topic = "devices/{}/messages/devicebound/#".format(self._device_id) - self._mqtts.add_topic_callback(device_bound_topic, self._handle_cloud_to_device_message) + self._mqtts.add_topic_callback( + device_bound_topic, self._handle_cloud_to_device_message + ) self._mqtts.subscribe(device_bound_topic) self._mqtts.add_topic_callback("$iothub/methods/#", self._handle_direct_method) self._mqtts.subscribe("$iothub/methods/#") def _subscribe_to_twin_topics(self): - self._mqtts.add_topic_callback("$iothub/twin/PATCH/properties/desired/#", self._handle_device_twin_update) - self._mqtts.subscribe("$iothub/twin/PATCH/properties/desired/#") # twin desired property changes + self._mqtts.add_topic_callback( + "$iothub/twin/PATCH/properties/desired/#", self._handle_device_twin_update + ) + self._mqtts.subscribe( + "$iothub/twin/PATCH/properties/desired/#" + ) # twin desired property changes - self._mqtts.add_topic_callback("$iothub/twin/res/200/#", self._handle_device_twin_update) + self._mqtts.add_topic_callback( + "$iothub/twin/res/200/#", self._handle_device_twin_update + ) self._mqtts.subscribe("$iothub/twin/res/200/#") # twin properties response def connect(self) -> bool: @@ -357,7 +391,10 @@ def connect(self) -> bool: while self._auth_response_received is None: self.loop() - self._logger.info(" - iot_mqtt :: connect :: on_connect must be fired. Connected ? " + str(self.is_connected())) + self._logger.info( + " - iot_mqtt :: connect :: on_connect must be fired. Connected ? " + + str(self.is_connected()) + ) if not self.is_connected(): return False @@ -383,8 +420,7 @@ def subscribe_to_twins(self) -> None: self._is_subscribed_to_twins = True def disconnect(self) -> None: - """Disconnects from the MQTT broker - """ + """Disconnects from the MQTT broker""" if not self.is_connected(): return @@ -393,8 +429,7 @@ def disconnect(self) -> None: self._mqtts.disconnect() def reconnect(self) -> None: - """Reconnects to the MQTT broker - """ + """Reconnects to the MQTT broker""" self._logger.info("- iot_mqtt :: reconnect :: ") self._mqtts.reconnect() @@ -407,15 +442,16 @@ def is_connected(self) -> bool: return self._mqtt_connected def loop(self) -> None: - """Listens for MQTT messages - """ + """Listens for MQTT messages""" if not self.is_connected(): return self._mqtts.loop() gc.collect() - def send_device_to_cloud_message(self, message, system_properties: dict = None) -> None: + def send_device_to_cloud_message( + self, message, system_properties: dict = None + ) -> None: """Send a device to cloud message from this device to Azure IoT Hub :param message: The message data as a JSON string or a dictionary :param system_properties: System properties to send with the message @@ -451,5 +487,7 @@ def send_twin_patch(self, patch) -> None: :raises RuntimeError: if the internet connection is not responding or is unable to connect """ self._logger.info("- iot_mqtt :: sendProperty :: " + str(patch)) - topic = "$iothub/twin/PATCH/properties/reported/?$rid={}".format(int(time.time())) + topic = "$iothub/twin/PATCH/properties/reported/?$rid={}".format( + int(time.time()) + ) self._send_common(topic, patch) diff --git a/adafruit_azureiot/iotcentral_device.py b/adafruit_azureiot/iotcentral_device.py index 43270cc..84df471 100644 --- a/adafruit_azureiot/iotcentral_device.py +++ b/adafruit_azureiot/iotcentral_device.py @@ -1,24 +1,8 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: 2020 Jim Bennet for Adafruit Industries +# SPDX-FileCopyrightText: 2020 Elena Horton for Adafruit Industries # -# Copyright (c) 2020 Jim Bennett -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT + """ `iotcentral_device` ===================== @@ -37,8 +21,7 @@ class IoTCentralDevice(IoTMQTTCallback): - """A device client for the Azure IoT Central service - """ + """A device client for the Azure IoT Central service""" def connection_status_change(self, connected: bool) -> None: """Called when the connection status changes @@ -62,7 +45,9 @@ def direct_method_called(self, method_name: str, payload: str) -> IoTResponse: raise IoTError("on_command_executed not set") - def device_twin_desired_updated(self, desired_property_name: str, desired_property_value, desired_version: int) -> None: + def device_twin_desired_updated( + self, desired_property_name: str, desired_property_value, desired_version: int + ) -> None: """Called when the device twin desired properties are updated :param str desired_property_name: The name of the desired property that was updated :param desired_property_value: The value of the desired property that was updated @@ -70,12 +55,19 @@ def device_twin_desired_updated(self, desired_property_name: str, desired_proper """ if self.on_property_changed is not None: # pylint: disable=E1102 - self.on_property_changed(desired_property_name, desired_property_value, desired_version) + self.on_property_changed( + desired_property_name, desired_property_value, desired_version + ) # when a desired property changes, update the reported to match to keep them in sync self.send_property(desired_property_name, desired_property_value) - def device_twin_reported_updated(self, reported_property_name: str, reported_property_value, reported_version: int) -> None: + def device_twin_reported_updated( + self, + reported_property_name: str, + reported_property_value, + reported_version: int, + ) -> None: """Called when the device twin reported values are updated :param str reported_property_name: The name of the reported property that was updated :param reported_property_value: The value of the reported property that was updated @@ -83,10 +75,21 @@ def device_twin_reported_updated(self, reported_property_name: str, reported_pro """ if self.on_property_changed is not None: # pylint: disable=E1102 - self.on_property_changed(reported_property_name, reported_property_value, reported_version) + self.on_property_changed( + reported_property_name, reported_property_value, reported_version + ) # pylint: disable=R0913 - def __init__(self, socket, iface, id_scope: str, device_id: str, key: str, token_expires: int = 21600, logger: logging = None): + def __init__( + self, + socket, + iface, + id_scope: str, + device_id: str, + key: str, + token_expires: int = 21600, + logger: logging = None, + ): """Create the Azure IoT Central device client :param socket: The network socket :param iface: The network interface @@ -132,11 +135,22 @@ def connect(self) -> None: :raises DeviceRegistrationError: if the device cannot be registered successfully :raises RuntimeError: if the internet connection is not responding or is unable to connect """ - self._device_registration = DeviceRegistration(self._socket, self._id_scope, self._device_id, self._key, self._logger) + self._device_registration = DeviceRegistration( + self._socket, self._id_scope, self._device_id, self._key, self._logger + ) token_expiry = int(time.time() + self._token_expires) hostname = self._device_registration.register_device(token_expiry) - self._mqtt = IoTMQTT(self, self._socket, self._iface, hostname, self._device_id, self._key, self._token_expires, self._logger) + self._mqtt = IoTMQTT( + self, + self._socket, + self._iface, + hostname, + self._device_id, + self._key, + self._token_expires, + self._logger, + ) self._mqtt.connect() self._mqtt.subscribe_to_twins() @@ -151,8 +165,7 @@ def disconnect(self) -> None: self._mqtt.disconnect() def reconnect(self) -> None: - """Reconnects to the MQTT broker - """ + """Reconnects to the MQTT broker""" if self._mqtt is None: raise IoTError("You are not connected to IoT Central") diff --git a/adafruit_azureiot/iothub_device.py b/adafruit_azureiot/iothub_device.py index bba43ba..76129e8 100755 --- a/adafruit_azureiot/iothub_device.py +++ b/adafruit_azureiot/iothub_device.py @@ -1,24 +1,8 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: 2020 Jim Bennet for Adafruit Industries +# SPDX-FileCopyrightText: 2020 Elena Horton for Adafruit Industries # -# Copyright (c) 2020 Jim Bennett, Elena Horton -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT + """ `iothub_device` ===================== @@ -35,8 +19,7 @@ def _validate_keys(connection_string_parts): - """Raise ValueError if incorrect combination of keys - """ + """Raise ValueError if incorrect combination of keys""" host_name = connection_string_parts.get(HOST_NAME) shared_access_key_name = connection_string_parts.get(SHARED_ACCESS_KEY_NAME) shared_access_key = connection_string_parts.get(SHARED_ACCESS_KEY) @@ -73,8 +56,7 @@ def _validate_keys(connection_string_parts): class IoTHubDevice(IoTMQTTCallback): - """A device client for the Azure IoT Hub service - """ + """A device client for the Azure IoT Hub service""" def connection_status_change(self, connected: bool) -> None: """Called when the connection status changes @@ -108,7 +90,9 @@ def cloud_to_device_message_received(self, body: str, properties: dict) -> None: # pylint: disable=E1102 self._on_cloud_to_device_message_received(body, properties) - def device_twin_desired_updated(self, desired_property_name: str, desired_property_value, desired_version: int) -> None: + def device_twin_desired_updated( + self, desired_property_name: str, desired_property_value, desired_version: int + ) -> None: """Called when the device twin desired properties are updated :param str desired_property_name: The name of the desired property that was updated :param desired_property_value: The value of the desired property that was updated @@ -116,9 +100,16 @@ def device_twin_desired_updated(self, desired_property_name: str, desired_proper """ if self._on_device_twin_desired_updated is not None: # pylint: disable=E1102 - self._on_device_twin_desired_updated(desired_property_name, desired_property_value, desired_version) - - def device_twin_reported_updated(self, reported_property_name: str, reported_property_value, reported_version: int) -> None: + self._on_device_twin_desired_updated( + desired_property_name, desired_property_value, desired_version + ) + + def device_twin_reported_updated( + self, + reported_property_name: str, + reported_property_value, + reported_version: int, + ) -> None: """Called when the device twin reported values are updated :param str reported_property_name: The name of the reported property that was updated :param reported_property_value: The value of the reported property that was updated @@ -126,9 +117,18 @@ def device_twin_reported_updated(self, reported_property_name: str, reported_pro """ if self._on_device_twin_reported_updated is not None: # pylint: disable=E1102 - self._on_device_twin_reported_updated(reported_property_name, reported_property_value, reported_version) - - def __init__(self, socket, iface, device_connection_string: str, token_expires: int = 21600, logger: logging = None): + self._on_device_twin_reported_updated( + reported_property_name, reported_property_value, reported_version + ) + + def __init__( + self, + socket, + iface, + device_connection_string: str, + token_expires: int = 21600, + logger: logging = None, + ): """Create the Azure IoT Central device client :param socket: The network socket :param iface: The network interface @@ -145,9 +145,13 @@ def __init__(self, socket, iface, device_connection_string: str, token_expires: try: cs_args = device_connection_string.split(DELIMITER) - connection_string_values = dict(arg.split(VALUE_SEPARATOR, 1) for arg in cs_args) + connection_string_values = dict( + arg.split(VALUE_SEPARATOR, 1) for arg in cs_args + ) except (ValueError, AttributeError) as e: - raise ValueError("Connection string is required and should not be empty or blank and must be supplied as a string") from e + raise ValueError( + "Connection string is required and should not be empty or blank and must be supplied as a string" + ) from e if len(cs_args) != len(connection_string_values): raise ValueError("Invalid Connection String - Unable to parse") @@ -218,11 +222,15 @@ def cloud_to_device_message_received(body: str, properties: dict) -> None: return self._on_cloud_to_device_message_received @on_cloud_to_device_message_received.setter - def on_cloud_to_device_message_received(self, new_on_cloud_to_device_message_received): + def on_cloud_to_device_message_received( + self, new_on_cloud_to_device_message_received + ): """A callback method that is called when a cloud to device message is received. This method should have the following signature: def cloud_to_device_message_received(body: str, properties: dict) -> None: """ - self._on_cloud_to_device_message_received = new_on_cloud_to_device_message_received + self._on_cloud_to_device_message_received = ( + new_on_cloud_to_device_message_received + ) @property def on_device_twin_desired_updated(self): @@ -267,11 +275,21 @@ def connect(self) -> None: :raises RuntimeError: if the internet connection is not responding or is unable to connect """ self._mqtt = IoTMQTT( - self, self._socket, self._iface, self._hostname, self._device_id, self._shared_access_key, self._token_expires, self._logger + self, + self._socket, + self._iface, + self._hostname, + self._device_id, + self._shared_access_key, + self._token_expires, + self._logger, ) self._mqtt.connect() - if self._on_device_twin_desired_updated is not None or self._on_device_twin_reported_updated is not None: + if ( + self._on_device_twin_desired_updated is not None + or self._on_device_twin_reported_updated is not None + ): self._mqtt.subscribe_to_twins() def disconnect(self) -> None: @@ -284,8 +302,7 @@ def disconnect(self) -> None: self._mqtt.disconnect() def reconnect(self) -> None: - """Reconnects to the MQTT broker - """ + """Reconnects to the MQTT broker""" if self._mqtt is None: raise IoTError("You are not connected to IoT Central") diff --git a/adafruit_azureiot/keys.py b/adafruit_azureiot/keys.py index 08e1b7e..c1f9c41 100644 --- a/adafruit_azureiot/keys.py +++ b/adafruit_azureiot/keys.py @@ -1,24 +1,7 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: 2020 Jim Bennet for Adafruit Industries # -# Copyright (c) 2020 Jim Bennett -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT + """Computes a derived symmetric key from a secret and a message :param str secret: The secret to use for the key :param str msg: The message to use for the key diff --git a/adafruit_azureiot/quote.py b/adafruit_azureiot/quote.py index 704188c..4a338b8 100644 --- a/adafruit_azureiot/quote.py +++ b/adafruit_azureiot/quote.py @@ -1,24 +1,7 @@ -# The MIT License (MIT) +# SPDX-FileCopyrightText: 2020 Jim Bennet for Adafruit Industries # -# Copyright (c) 2020 Jim Bennett -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. +# SPDX-License-Identifier: MIT + """ `quote` ================================================================================ @@ -28,7 +11,9 @@ safe arg. """ -_ALWAYS_SAFE = frozenset(b"ABCDEFGHIJKLMNOPQRSTUVWXYZ" b"abcdefghijklmnopqrstuvwxyz" b"0123456789" b"_.-~") +_ALWAYS_SAFE = frozenset( + b"ABCDEFGHIJKLMNOPQRSTUVWXYZ" b"abcdefghijklmnopqrstuvwxyz" b"0123456789" b"_.-~" +) _ALWAYS_SAFE_BYTES = bytes(_ALWAYS_SAFE) SAFE_QUOTERS = {} diff --git a/docs/_static/favicon.ico.license b/docs/_static/favicon.ico.license new file mode 100644 index 0000000..86a3fbf --- /dev/null +++ b/docs/_static/favicon.ico.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries + +SPDX-License-Identifier: CC-BY-4.0 diff --git a/docs/api.rst.license b/docs/api.rst.license new file mode 100644 index 0000000..9aae48d --- /dev/null +++ b/docs/api.rst.license @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: 2020 ladyada for Adafruit Industries +# +# SPDX-License-Identifier: MIT diff --git a/docs/conf.py b/docs/conf.py index 794f8dd..29ff0a8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,9 @@ # -*- coding: utf-8 -*- +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# +# SPDX-License-Identifier: MIT + import os import sys @@ -144,14 +148,28 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, "AdafruitAzureIoTLibrary.tex", "AdafruitAzureIoT Library Documentation", author, "manual",), + ( + master_doc, + "AdafruitAzureIoTLibrary.tex", + "AdafruitAzureIoT Library Documentation", + author, + "manual", + ), ] # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [(master_doc, "AdafruitAzureIoTlibrary", "Adafruit AzureIoT Library Documentation", [author], 1,)] +man_pages = [ + ( + master_doc, + "AdafruitAzureIoTlibrary", + "Adafruit AzureIoT Library Documentation", + [author], + 1, + ) +] # -- Options for Texinfo output ------------------------------------------- diff --git a/docs/examples.rst b/docs/examples.rst index 4441aa9..217c5ec 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -50,4 +50,4 @@ Handle connection errors. .. literalinclude:: ../examples/azureiot_central_notconnected.py :caption: examples/azureiot_central_notconnected.py - :linenos: \ No newline at end of file + :linenos: diff --git a/docs/examples.rst.license b/docs/examples.rst.license new file mode 100644 index 0000000..9aae48d --- /dev/null +++ b/docs/examples.rst.license @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: 2020 ladyada for Adafruit Industries +# +# SPDX-License-Identifier: MIT diff --git a/docs/index.rst.license b/docs/index.rst.license new file mode 100644 index 0000000..9aae48d --- /dev/null +++ b/docs/index.rst.license @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: 2020 ladyada for Adafruit Industries +# +# SPDX-License-Identifier: MIT diff --git a/docs/iot-central-connect-button.png.license b/docs/iot-central-connect-button.png.license new file mode 100644 index 0000000..a784acf --- /dev/null +++ b/docs/iot-central-connect-button.png.license @@ -0,0 +1,2 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT diff --git a/docs/iot-central-connect-dialog.png.license b/docs/iot-central-connect-dialog.png.license new file mode 100644 index 0000000..a784acf --- /dev/null +++ b/docs/iot-central-connect-dialog.png.license @@ -0,0 +1,2 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT diff --git a/docs/iot-hub-device-keys.png.license b/docs/iot-hub-device-keys.png.license new file mode 100644 index 0000000..a784acf --- /dev/null +++ b/docs/iot-hub-device-keys.png.license @@ -0,0 +1,2 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT diff --git a/docs/iot-hub-device.png.license b/docs/iot-hub-device.png.license new file mode 100644 index 0000000..a784acf --- /dev/null +++ b/docs/iot-hub-device.png.license @@ -0,0 +1,2 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT diff --git a/examples/azureiot_central_commands.py b/examples/azureiot_central_commands.py index a12a801..8ae0e15 100644 --- a/examples/azureiot_central_commands.py +++ b/examples/azureiot_central_commands.py @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT + import time import board import busio @@ -28,7 +31,9 @@ esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset) """Use below for Most Boards""" -status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards +status_light = neopixel.NeoPixel( + board.NEOPIXEL, 1, brightness=0.2 +) # Uncomment for Most Boards """Uncomment below for ItsyBitsy M4""" # status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2) # Uncomment below for an externally defined RGB LED @@ -86,11 +91,16 @@ # From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests +# pylint: disable=wrong-import-position from adafruit_azureiot import IoTCentralDevice from adafruit_azureiot.iot_mqtt import IoTResponse +# pylint: enable=wrong-import-position + # Create an IoT Hub device client and connect -device = IoTCentralDevice(socket, esp, secrets["id_scope"], secrets["device_id"], secrets["key"]) +device = IoTCentralDevice( + socket, esp, secrets["id_scope"], secrets["device_id"], secrets["key"] +) # Subscribe to commands # Commands can be sent from the devices Dashboard in IoT Central, assuming diff --git a/examples/azureiot_central_notconnected.py b/examples/azureiot_central_notconnected.py index d81107a..eda9bdb 100644 --- a/examples/azureiot_central_notconnected.py +++ b/examples/azureiot_central_notconnected.py @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT + import json import random import time @@ -30,7 +33,9 @@ esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset) """Use below for Most Boards""" -status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards +status_light = neopixel.NeoPixel( + board.NEOPIXEL, 1, brightness=0.2 +) # Uncomment for Most Boards """Uncomment below for ItsyBitsy M4""" # status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2) # Uncomment below for an externally defined RGB LED @@ -88,10 +93,18 @@ # From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests -from adafruit_azureiot import IoTCentralDevice, IoTError +# pylint: disable=wrong-import-position +from adafruit_azureiot import ( + IoTCentralDevice, + IoTError, +) + +# pylint: enable=wrong-import-position # Create an IoT Hub device client and connect -device = IoTCentralDevice(socket, esp, secrets["id_scope"], secrets["device_id"], secrets["key"]) +device = IoTCentralDevice( + socket, esp, secrets["id_scope"], secrets["device_id"], secrets["key"] +) # don't connect # device.connect() diff --git a/examples/azureiot_central_properties.py b/examples/azureiot_central_properties.py index 71caf6b..c5bebca 100644 --- a/examples/azureiot_central_properties.py +++ b/examples/azureiot_central_properties.py @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT + import random import time import board @@ -29,7 +32,9 @@ esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset) """Use below for Most Boards""" -status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards +status_light = neopixel.NeoPixel( + board.NEOPIXEL, 1, brightness=0.2 +) # Uncomment for Most Boards """Uncomment below for ItsyBitsy M4""" # status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2) # Uncomment below for an externally defined RGB LED @@ -87,16 +92,25 @@ # From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests -from adafruit_azureiot import IoTCentralDevice +from adafruit_azureiot import IoTCentralDevice # pylint: disable=wrong-import-position # Create an IoT Hub device client and connect -device = IoTCentralDevice(socket, esp, secrets["id_scope"], secrets["device_id"], secrets["key"]) +device = IoTCentralDevice( + socket, esp, secrets["id_scope"], secrets["device_id"], secrets["key"] +) # Subscribe to property changes # Properties can be updated either in code, or by adding a form to the view # in the device template, and setting the value on the dashboard for the device def property_changed(property_name, property_value, version): - print("Property", property_name, "updated to", str(property_value), "version", str(version)) + print( + "Property", + property_name, + "updated to", + str(property_value), + "version", + str(version), + ) # Subscribe to the property changed event diff --git a/examples/azureiot_central_simpletest.py b/examples/azureiot_central_simpletest.py index e0cbf96..49a81af 100644 --- a/examples/azureiot_central_simpletest.py +++ b/examples/azureiot_central_simpletest.py @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT + import json import random import time @@ -30,7 +33,9 @@ esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset) """Use below for Most Boards""" -status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards +status_light = neopixel.NeoPixel( + board.NEOPIXEL, 1, brightness=0.2 +) # Uncomment for Most Boards """Uncomment below for ItsyBitsy M4""" # status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2) # Uncomment below for an externally defined RGB LED @@ -88,10 +93,12 @@ # From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests -from adafruit_azureiot import IoTCentralDevice +from adafruit_azureiot import IoTCentralDevice # pylint: disable=wrong-import-position # Create an IoT Hub device client and connect -device = IoTCentralDevice(socket, esp, secrets["id_scope"], secrets["device_id"], secrets["key"]) +device = IoTCentralDevice( + socket, esp, secrets["id_scope"], secrets["device_id"], secrets["key"] +) print("Connecting to Azure IoT Central...") diff --git a/examples/azureiot_hub_directmethods.py b/examples/azureiot_hub_directmethods.py index 2a00462..9ba5f7b 100644 --- a/examples/azureiot_hub_directmethods.py +++ b/examples/azureiot_hub_directmethods.py @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT + import time import board import busio @@ -28,7 +31,9 @@ esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset) """Use below for Most Boards""" -status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards +status_light = neopixel.NeoPixel( + board.NEOPIXEL, 1, brightness=0.2 +) # Uncomment for Most Boards """Uncomment below for ItsyBitsy M4""" # status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2) # Uncomment below for an externally defined RGB LED @@ -81,9 +86,12 @@ # From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests +# pylint: disable=wrong-import-position from adafruit_azureiot import IoTHubDevice from adafruit_azureiot.iot_mqtt import IoTResponse +# pylint: enable=wrong-import-position + # Create an IoT Hub device client and connect device = IoTHubDevice(socket, esp, secrets["device_connection_string"]) diff --git a/examples/azureiot_hub_messages.py b/examples/azureiot_hub_messages.py index decd7bc..4d98ef3 100644 --- a/examples/azureiot_hub_messages.py +++ b/examples/azureiot_hub_messages.py @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT + import json import random import time @@ -30,7 +33,9 @@ esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset) """Use below for Most Boards""" -status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards +status_light = neopixel.NeoPixel( + board.NEOPIXEL, 1, brightness=0.2 +) # Uncomment for Most Boards """Uncomment below for ItsyBitsy M4""" # status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2) # Uncomment below for an externally defined RGB LED @@ -83,7 +88,7 @@ # From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests -from adafruit_azureiot import IoTHubDevice +from adafruit_azureiot import IoTHubDevice # pylint: disable=wrong-import-position # Create an IoT Hub device client and connect device = IoTHubDevice(socket, esp, secrets["device_connection_string"]) diff --git a/examples/azureiot_hub_simpletest.py b/examples/azureiot_hub_simpletest.py index 5ae4f0f..d6ef4a4 100644 --- a/examples/azureiot_hub_simpletest.py +++ b/examples/azureiot_hub_simpletest.py @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT + import json import random import time @@ -30,7 +33,9 @@ esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset) """Use below for Most Boards""" -status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards +status_light = neopixel.NeoPixel( + board.NEOPIXEL, 1, brightness=0.2 +) # Uncomment for Most Boards """Uncomment below for ItsyBitsy M4""" # status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2) # Uncomment below for an externally defined RGB LED @@ -83,7 +88,7 @@ # From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests -from adafruit_azureiot import IoTHubDevice +from adafruit_azureiot import IoTHubDevice # pylint: disable=wrong-import-position # Create an IoT Hub device client and connect device = IoTHubDevice(socket, esp, secrets["device_connection_string"]) diff --git a/examples/azureiot_hub_twin_operations.py b/examples/azureiot_hub_twin_operations.py index 12a78f8..dacb8ce 100644 --- a/examples/azureiot_hub_twin_operations.py +++ b/examples/azureiot_hub_twin_operations.py @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT + import random import time import board @@ -29,7 +32,9 @@ esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset) """Use below for Most Boards""" -status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards +status_light = neopixel.NeoPixel( + board.NEOPIXEL, 1, brightness=0.2 +) # Uncomment for Most Boards """Uncomment below for ItsyBitsy M4""" # status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2) # Uncomment below for an externally defined RGB LED @@ -85,7 +90,7 @@ # From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests -from adafruit_azureiot import IoTHubDevice +from adafruit_azureiot import IoTHubDevice # pylint: disable=wrong-import-position # Create an IoT Hub device client and connect device = IoTHubDevice(socket, esp, secrets["device_connection_string"]) @@ -94,8 +99,17 @@ # To see these changes, update the desired properties for the device either in code # or in the Azure portal by selecting the device in the IoT Hub blade, selecting # Device Twin then adding or amending an entry in the 'desired' section -def device_twin_desired_updated(desired_property_name: str, desired_property_value, desired_version: int): - print("Property", desired_property_name, "updated to", str(desired_property_value), "version", desired_version) +def device_twin_desired_updated( + desired_property_name: str, desired_property_value, desired_version: int +): + print( + "Property", + desired_property_name, + "updated to", + str(desired_property_value), + "version", + desired_version, + ) # Subscribe to the device twin desired property updated event diff --git a/examples/azureiot_secrets_example.py b/examples/azureiot_secrets_example.py index 0875a7e..7eeefde 100644 --- a/examples/azureiot_secrets_example.py +++ b/examples/azureiot_secrets_example.py @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT + # This file is where you keep secret settings, passwords, and tokens! # If you put them in the code you risk committing that info or sharing it # which would be not great. So, instead, keep it all in this one file and diff --git a/iot-central-connect-button.png.license b/iot-central-connect-button.png.license new file mode 100644 index 0000000..a784acf --- /dev/null +++ b/iot-central-connect-button.png.license @@ -0,0 +1,2 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT diff --git a/iot-central-connect-dialog.png.license b/iot-central-connect-dialog.png.license new file mode 100644 index 0000000..a784acf --- /dev/null +++ b/iot-central-connect-dialog.png.license @@ -0,0 +1,2 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT diff --git a/iot-hub-device-keys.png.license b/iot-hub-device-keys.png.license new file mode 100644 index 0000000..a784acf --- /dev/null +++ b/iot-hub-device-keys.png.license @@ -0,0 +1,2 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT diff --git a/iot-hub-device.png.license b/iot-hub-device.png.license new file mode 100644 index 0000000..a784acf --- /dev/null +++ b/iot-hub-device.png.license @@ -0,0 +1,2 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# SPDX-License-Identifier: MIT diff --git a/requirements.txt b/requirements.txt index f488495..5e8305a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,8 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# +# SPDX-License-Identifier: Unlicense + Adafruit-Blinka Adafruit-CircuitPython-miniMQTT Adafruit-CircuitPython-Requests -Adafruit-CircuitPython-Binascii \ No newline at end of file +Adafruit-CircuitPython-Binascii diff --git a/setup.py b/setup.py index 0af8ac5..60bf662 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries +# +# SPDX-License-Identifier: MIT + """A setuptools based setup module. See: