From d7d71e7ce8acec48165e37328cbb002651d83b84 Mon Sep 17 00:00:00 2001 From: Max Velitchko Date: Tue, 15 Jul 2025 13:16:43 -0700 Subject: [PATCH 1/2] Fix: str2bool does not raise ValueError on invalid value, enable build and pytest --- .github/workflows/buddy-build.yml | 38 +++++++++++++++++++++++++++++++ .gitignore | 3 ++- setup.py | 2 +- src/amcrest/utils.py | 10 +++++++- 4 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/buddy-build.yml diff --git a/.github/workflows/buddy-build.yml b/.github/workflows/buddy-build.yml new file mode 100644 index 0000000..6037625 --- /dev/null +++ b/.github/workflows/buddy-build.yml @@ -0,0 +1,38 @@ +name: Buddy Build + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.11, 3.13] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel pytest responses + + - name: Build + env: + CI: 1 + run: | + python setup.py sdist bdist_wheel + + - name: Install wheel + run: + pip install dist/amcrest-*.whl + + - name: Test + run: | + pytest -v diff --git a/.gitignore b/.gitignore index 57bb572..2df561f 100644 --- a/.gitignore +++ b/.gitignore @@ -105,5 +105,6 @@ ENV/ # Rope project settings .ropeproject -# Vim temporary files +# Vim/emacs temporary/backup files *.swp +*~ diff --git a/setup.py b/setup.py index 539946a..098e047 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ def readme(): setup( name="amcrest", - version="1.9.9", + version="1.9.10", description="Python wrapper implementation for Amcrest cameras.", long_description=readme(), author="Douglas Schilling Landgraf, Marcelo Moreira de Mello", diff --git a/src/amcrest/utils.py b/src/amcrest/utils.py index a54d7b6..d575f01 100644 --- a/src/amcrest/utils.py +++ b/src/amcrest/utils.py @@ -51,7 +51,15 @@ def str2bool(value: Union[str, int]) -> bool: False values: n, no, false, off, 0 """ if isinstance(value, str): - return value.lower() in ("y", "yes", "on", "1", "true", "t") + valueCompare = value.lower() + + if valueCompare in ("y", "yes", "on", "1", "true", "t"): + return True + elif valueCompare in ("n", "no", "off", "0", "false"): + return False + else: + raise ValueError(value) + return bool(value) From 93fbd411f2d9f37a045c0e913d2d6c583dfbf5f4 Mon Sep 17 00:00:00 2001 From: Max Velitchko Date: Tue, 15 Jul 2025 13:19:44 -0700 Subject: [PATCH 2/2] Make houndci-bot happy --- src/amcrest/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/amcrest/utils.py b/src/amcrest/utils.py index d575f01..b0b37bb 100644 --- a/src/amcrest/utils.py +++ b/src/amcrest/utils.py @@ -59,7 +59,7 @@ def str2bool(value: Union[str, int]) -> bool: return False else: raise ValueError(value) - + return bool(value)