From 259f5abc783e98e6f686e01ec935ac6209e2fe83 Mon Sep 17 00:00:00 2001 From: avollkopf <43980694+avollkopf@users.noreply.github.com> Date: Mon, 14 Feb 2022 07:53:04 +0100 Subject: [PATCH 1/4] changed RPi.GPIO version to latest official version --- Dockerfile | 4 ++-- cbpi/__init__.py | 2 +- setup.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 884bf9e..7f11171 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,7 +39,7 @@ RUN pip3 install --no-cache-dir -r /cbpi-src/requirements.txt # Install RPi.GPIO separately because it's excluded in setup.py for non-raspberrys. # This can enable GPIO support for the image when used on a raspberry pi and the # /dev/gpiomem device. -RUN pip3 install --no-cache-dir RPi.GPIO==0.7.1a4 +RUN pip3 install --no-cache-dir RPi.GPIO==0.7.1 FROM base as deploy # Install craftbeerpi from source @@ -61,4 +61,4 @@ RUN ["cbpi", "setup"] EXPOSE 8000 # Start cbpi -CMD ["cbpi", "start"] \ No newline at end of file +CMD ["cbpi", "start"] diff --git a/cbpi/__init__.py b/cbpi/__init__.py index 5c14468..778fc0e 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1 +1 @@ -__version__ = "4.0.1.14" +__version__ = "4.0.1.15" diff --git a/setup.py b/setup.py index 99d5137..cbce4c1 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ setup(name='cbpi', 'psutil==5.8.0', 'cbpi4ui', 'importlib_metadata'] + ( - ['RPi.GPIO==0.7.1a4'] if raspberrypi else [] ) + + ['RPi.GPIO==0.7.1'] if raspberrypi else [] ) + (['numpy==1.22.0'] if (int(platform.python_version_tuple()[1]) >= 9) and (int(platform.python_version_tuple()[0]) == 3) else ['numpy==1.20.3'] ) + (['pandas==1.4.0'] if (int(platform.python_version_tuple()[1]) >= 9) and (int(platform.python_version_tuple()[0]) == 3) else ['pandas==1.1.5'] ), From 68fb5f45c80002e3fc5061e3f2a001f2754e19f6 Mon Sep 17 00:00:00 2001 From: Philipp Grathwohl Date: Mon, 14 Feb 2022 09:54:27 +0100 Subject: [PATCH 2/4] Update python to v3.9 when building --- .github/workflows/build.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7dbc85d..39d9296 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: - name: Setup python environment uses: actions/setup-python@v2 with: - python-version: '3.7' + python-version: '3.9' - name: Clean run: python setup.py clean --all diff --git a/Dockerfile b/Dockerfile index 7f11171..23fa44e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ RUN apk --no-cache add curl && mkdir /downloads # Download installation files RUN curl https://github.com/avollkopf/craftbeerpi4-ui/archive/main.zip -L -o ./downloads/cbpi-ui.zip -FROM python:3.7 as base +FROM python:3.9 as base # Install dependencies RUN apt-get update \ From baed31f8b6822db4c1142ddbb1f9ca95eded2d2d Mon Sep 17 00:00:00 2001 From: Philipp Grathwohl Date: Mon, 14 Feb 2022 09:54:51 +0100 Subject: [PATCH 3/4] Update dependencies for dev environment for python 3.9 see github issue avollkopf/craftbeerpi4#39 --- requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 28e5433..1bb28da 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,13 +10,13 @@ cryptography==3.3.2 requests==2.25.1 voluptuous==0.12.1 pyfiglet==0.8.post1 -pandas==1.1.5 +pandas==1.4.0 shortuuid==1.0.1 tabulate==0.8.7 -numpy==1.20.3 +numpy==1.22.0 cbpi4ui click==7.1.2 importlib_metadata==4.8.2 asyncio-mqtt psutil==5.8.0 -zipp>=0.5 \ No newline at end of file +zipp>=0.5 From 972c9dbf49587facecf75732569dc315142dcf98 Mon Sep 17 00:00:00 2001 From: avollkopf <43980694+avollkopf@users.noreply.github.com> Date: Tue, 15 Feb 2022 18:11:14 +0100 Subject: [PATCH 4/4] Added check for plugin addition before plugin is added to the config, cli.py checks if the package does exist and if the name is correct (capital letters,...) --- cbpi/__init__.py | 2 +- cbpi/cli.py | 37 ++++++++++++++++++++++++------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/cbpi/__init__.py b/cbpi/__init__.py index 778fc0e..8528c67 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1 +1 @@ -__version__ = "4.0.1.15" +__version__ = "4.0.1.16" diff --git a/cbpi/cli.py b/cbpi/cli.py index 9b28fc6..6f310ff 100644 --- a/cbpi/cli.py +++ b/cbpi/cli.py @@ -218,20 +218,31 @@ def plugins_add(package_name): return return + installation = True try: - with open(os.path.join(".", 'config', "config.yaml"), 'rt') as f: - data = yaml.load(f, Loader=yaml.FullLoader) - if package_name in data["plugins"]: - print("") - print("Plugin {} already active".format(package_name)) - print("") - return - data["plugins"].append(package_name) - with open(os.path.join(".", 'config', "config.yaml"), 'w') as outfile: - yaml.dump(data, outfile, default_flow_style=False) - print("") - print("Plugin {} activated".format(package_name)) - print("") + try: + p_metadata= metadata(package_name) + p_name=p_metadata['Name'] + if p_name != package_name: + print("Error. Package name {} does not exist. Did you mean {}".format(package_name,p_name)) + installation = False + except Exception as e: + print("Error. Package {} cannot be found in installed packages".format(package_name)) + installation = False + if installation: + with open(os.path.join(".", 'config', "config.yaml"), 'rt') as f: + data = yaml.load(f, Loader=yaml.FullLoader) + if package_name in data["plugins"]: + print("") + print("Plugin {} already active".format(package_name)) + print("") + return + data["plugins"].append(package_name) + with open(os.path.join(".", 'config', "config.yaml"), 'w') as outfile: + yaml.dump(data, outfile, default_flow_style=False) + print("") + print("Plugin {} activated".format(package_name)) + print("") except Exception as e: print(e) pass