From c40bd54c2ed015be7b1c2f66a29b825270e91798 Mon Sep 17 00:00:00 2001 From: danieleborgo Date: Thu, 15 Feb 2024 22:18:50 +0100 Subject: [PATCH] Extended the plugin to support Windows --- .gitignore | 1 + README.md | 2 +- extra/filamentbuddy.md | 3 ++- octoprint_filamentbuddy/manager/__init__.py | 2 +- .../templates/filamentbuddy_settings.jinja2 | 9 ++++++--- setup.py | 7 ++++++- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 26a5553..1e57227 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ dist *.egg* .DS_Store *.zip +/.venv/ diff --git a/README.md b/README.md index 2aa5274..5c6748f 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ The _Filament Sensor_ module is different since it uses a Python module specifically developed for the Raspberry boards, _gpiozero_, so it has this board as prerequisite. Nevertheless, Marlin is not a requirement, since it only uses OctoPrint functionalities. In the case FilamentBuddy -is not running on a Raspberry Pi, the plugin will disable this features. +is not running on a Raspberry Pi, the plugin will disable this feature. ## Setup diff --git a/extra/filamentbuddy.md b/extra/filamentbuddy.md index e5b9cbd..1a8d4ab 100644 --- a/extra/filamentbuddy.md +++ b/extra/filamentbuddy.md @@ -87,6 +87,7 @@ compatibility: os: - linux + - windows # Compatible Python version # @@ -176,7 +177,7 @@ The _Filament Sensor_ module is different since it uses a Python module specifically developed for the Raspberry boards, _gpiozero_, so it has this board as prerequisite. Nevertheless, Marlin is not a requirement, since it only uses OctoPrint functionalities. In the case FilamentBuddy -is not running on a Raspberry Pi, the plugin will disable this features. +is not running on a Raspberry Pi, the plugin will disable this feature. ## Setup diff --git a/octoprint_filamentbuddy/manager/__init__.py b/octoprint_filamentbuddy/manager/__init__.py index 6a7c1bc..4780d51 100644 --- a/octoprint_filamentbuddy/manager/__init__.py +++ b/octoprint_filamentbuddy/manager/__init__.py @@ -18,7 +18,7 @@ try: from RPi import GPIO is_imported = True -except RuntimeError: +except (RuntimeError, ModuleNotFoundError): is_imported = False diff --git a/octoprint_filamentbuddy/templates/filamentbuddy_settings.jinja2 b/octoprint_filamentbuddy/templates/filamentbuddy_settings.jinja2 index 34e17c4..9de44e5 100644 --- a/octoprint_filamentbuddy/templates/filamentbuddy_settings.jinja2 +++ b/octoprint_filamentbuddy/templates/filamentbuddy_settings.jinja2 @@ -292,9 +292,12 @@ along with this program. If not, see .
- Filament Sensor has been disabled since the GPIO has not been found. - This message should appear if FilamentBuddy is not running on a Raspberry Pi.
- It is still possible to use Filament Changer and Filament Remover. + Filament Sensor has been disabled since the GPIO has not been found. This message should appear + only when FilamentBuddy is not running on a Raspberry Pi.
+ It is still possible to use Filament Changer and Filament Remover.

+ In case this plugin is running on a Raspberry and this message is shown, it is suggested to + uninstall it, reboot OctoPrint and then install it again. If the problem persists, open an issue + here.
diff --git a/setup.py b/setup.py index a93f2a7..96b9f1c 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,7 @@ # coding=utf-8 +from platform import system + ######################################################################################################################## # Do not forget to adjust the following variables to your own plugin. @@ -35,9 +37,12 @@ # Any additional requirements besides OctoPrint should be listed here plugin_requires = [ - "OctoPrint>=1.7.2", "RPi.GPIO>=0.7.1", "gpiozero>=1.6.2", "flask>=2.2.3", "paho-mqtt>=1.6.1", + "OctoPrint>=1.7.2", "flask>=2.2.3", "paho-mqtt>=1.6.1", ] +if system() != "Windows": + plugin_requires.extend(["gpiozero>=1.6.2", "RPi.GPIO>=0.7.1"]) + # -------------------------------------------------------------------------------------------------------------------- # More advanced options that you usually shouldn't have to touch follow after this point # --------------------------------------------------------------------------------------------------------------------