diff options
author | Nikolay Amiantov <ab@fmap.me> | 2016-02-19 14:27:32 +0300 |
---|---|---|
committer | Nikolay Amiantov <ab@fmap.me> | 2016-02-19 14:27:32 +0300 |
commit | b457b7a7eacb8b7993f3753f73d11923e8650961 (patch) | |
tree | 5611128b3af3e9beb61ac850e114593e16528e81 /pkgs/applications | |
parent | b64192744a985a5214fb249565bef0841936d4ae (diff) | |
parent | 53269f1455cd4b44a90a80e332de45d56e51e511 (diff) | |
download | nixlib-b457b7a7eacb8b7993f3753f73d11923e8650961.tar nixlib-b457b7a7eacb8b7993f3753f73d11923e8650961.tar.gz nixlib-b457b7a7eacb8b7993f3753f73d11923e8650961.tar.bz2 nixlib-b457b7a7eacb8b7993f3753f73d11923e8650961.tar.lz nixlib-b457b7a7eacb8b7993f3753f73d11923e8650961.tar.xz nixlib-b457b7a7eacb8b7993f3753f73d11923e8650961.tar.zst nixlib-b457b7a7eacb8b7993f3753f73d11923e8650961.zip |
Merge pull request #13069 from abbradar/m3d
OctoPrint and plugins and support for M3D Micro 3D-printer
Diffstat (limited to 'pkgs/applications')
4 files changed, 296 insertions, 0 deletions
diff --git a/pkgs/applications/misc/octoprint/0001-Don-t-use-static-library.patch b/pkgs/applications/misc/octoprint/0001-Don-t-use-static-library.patch new file mode 100644 index 000000000000..01b0c8f9cce9 --- /dev/null +++ b/pkgs/applications/misc/octoprint/0001-Don-t-use-static-library.patch @@ -0,0 +1,113 @@ +From 73ff28c3ee5b737303871268a5487db0fcffc0f6 Mon Sep 17 00:00:00 2001 +From: Nikolay Amiantov <ab@fmap.me> +Date: Wed, 17 Feb 2016 14:37:31 +0300 +Subject: [PATCH 1/2] Don't use static library + +--- + octoprint_m3dfio/__init__.py | 67 +----------------------------------------- + shared library source/Makefile | 6 ++-- + 2 files changed, 5 insertions(+), 68 deletions(-) + +diff --git a/octoprint_m3dfio/__init__.py b/octoprint_m3dfio/__init__.py +index 5e5369b..9f59768 100644 +--- a/octoprint_m3dfio/__init__.py ++++ b/octoprint_m3dfio/__init__.py +@@ -764,72 +764,7 @@ class M3DFioPlugin( + # Set file locations + self.setFileLocations() + +- # Check if running on Linux +- if platform.uname()[0].startswith("Linux") : +- +- # Check if running on a Raspberry Pi +- if platform.uname()[4].startswith("armv6l") and self.getCpuHardware() == "BCM2708" : +- +- # Set shared library +- self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_arm1176jzf-s.so") +- +- # Otherwise check if running on a Raspberry Pi 2 +- elif platform.uname()[4].startswith("armv7l") and self.getCpuHardware() == "BCM2709" : +- +- # Set shared library +- self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_arm_cortex-a7.so") +- +- # Otherwise check if running on an ARM7 device +- elif platform.uname()[4].startswith("armv7") : +- +- # Set shared library +- self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_arm7.so") +- +- # Otherwise check if using an i386 or x86-64 device +- elif platform.uname()[4].endswith("86") or platform.uname()[4].endswith("64") : +- +- # Check if Python is running as 32-bit +- if platform.architecture()[0].startswith("32") : +- +- # Set shared library +- self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_i386.so") +- +- # Otherwise check if Python is running as 64-bit +- elif platform.architecture()[0].startswith("64") : +- +- # Set shared library +- self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_x86-64.so") +- +- # Otherwise check if running on Windows and using an i386 or x86-64 device +- elif platform.uname()[0].startswith("Windows") and (platform.uname()[4].endswith("86") or platform.uname()[4].endswith("64")) : +- +- # Check if Python is running as 32-bit +- if platform.architecture()[0].startswith("32") : +- +- # Set shared library +- self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_i386.dll") +- +- # Otherwise check if Python is running as 64-bit +- elif platform.architecture()[0].startswith("64") : +- +- # Set shared library +- self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_x86-64.dll") +- +- # Otherwise check if running on OS X and using an i386 or x86-64 device +- elif platform.uname()[0].startswith("Darwin") and (platform.uname()[4].endswith("86") or platform.uname()[4].endswith("64")) : +- +- # Check if Python is running as 32-bit +- if platform.architecture()[0].startswith("32") : +- +- # Set shared library +- self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_i386.dylib") +- +- # Otherwise check if Python is running as 64-bit +- elif platform.architecture()[0].startswith("64") : +- +- # Set shared library +- self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/static/libraries/preprocessor_x86-64.dylib") +- ++ self.sharedLibrary = ctypes.cdll.LoadLibrary(self._basefolder.replace('\\', '/') + "/../../../libpreprocessor.so") + # Check if shared library was set + if self.sharedLibrary : + +diff --git a/shared library source/Makefile b/shared library source/Makefile +index 4062a91..89dab71 100644 +--- a/shared library source/Makefile ++++ b/shared library source/Makefile +@@ -58,13 +58,15 @@ ifeq ($(TARGET_PLATFORM), OSX64) + CFLAGS = -fPIC -m64 -stdlib=libc++ -O3 -Wl,-install_name,$(PROG)$(VER) + endif + ++PROG = lib$(LIBRARY_NAME).so ++CC = g++ + SRCS = preprocessor.cpp gcode.cpp vector.cpp +-CFLAGS += -Wall -std=c++11 -fvisibility=hidden -shared ++CFLAGS = -O3 -fPIC -Wall -std=c++11 -fvisibility=hidden -shared + + all: $(PROG) + + $(PROG): $(SRCS) +- $(CC) $(CFLAGS) -o ../octoprint_m3dfio/static/libraries/$(PROG) $(SRCS) ++ $(CC) $(CFLAGS) -o $(PROG) $(SRCS) + + clean: + rm -f ../octoprint_m3dfio/static/libraries/$(PROG) +-- +2.7.0 + diff --git a/pkgs/applications/misc/octoprint/0002-Try-to-create-connection-several-times-if-printer-is.patch b/pkgs/applications/misc/octoprint/0002-Try-to-create-connection-several-times-if-printer-is.patch new file mode 100644 index 000000000000..63495fd6db9c --- /dev/null +++ b/pkgs/applications/misc/octoprint/0002-Try-to-create-connection-several-times-if-printer-is.patch @@ -0,0 +1,57 @@ +From b99fc3fd012765c5b3d8ac7a3f64762af5121b4a Mon Sep 17 00:00:00 2001 +From: Nikolay Amiantov <ab@fmap.me> +Date: Wed, 17 Feb 2016 15:47:34 +0300 +Subject: [PATCH 2/2] Try to create connection several times if printer is not + yet available + +--- + octoprint_m3dfio/__init__.py | 25 ++++++++++++++++++++++--- + 1 file changed, 22 insertions(+), 3 deletions(-) + +diff --git a/octoprint_m3dfio/__init__.py b/octoprint_m3dfio/__init__.py +index 9f59768..e7d97eb 100644 +--- a/octoprint_m3dfio/__init__.py ++++ b/octoprint_m3dfio/__init__.py +@@ -3421,8 +3421,16 @@ class M3DFioPlugin( + # Set updated port + currentPort = self.getPort() + +- # Re-connect +- connection = serial.Serial(currentPort, currentBaudrate) ++ # Re-connect; wait for the device to be available ++ connection = None ++ for i in range(1, 5): ++ try: ++ connection = serial.Serial(currentPort, currentBaudrate) ++ break ++ except OSError: ++ time.sleep(1) ++ if connection is None: ++ raise Exception("Couldn't reconnect to the printer") + + # Check if getting EEPROM was successful + if self.getEeprom(connection) : +@@ -6799,8 +6807,19 @@ class M3DFioPlugin( + # Set state to connecting + comm_instance._log("Connecting to: " + str(port)) + ++ # Create a connection ++ connection = None ++ for i in range(1, 5): ++ try: ++ connection = serial.Serial(str(port), baudrate) ++ # If printer has just power-cycled it may not yet be ready ++ except OSError: ++ time.sleep(1) ++ if connection is None: ++ raise Exception("Couldn't reconnect to the printer") ++ + # Return connection +- return serial.Serial(str(port), baudrate) ++ return connection + + # Disable sleep + def disableSleep(self) : +-- +2.7.0 + diff --git a/pkgs/applications/misc/octoprint/default.nix b/pkgs/applications/misc/octoprint/default.nix new file mode 100644 index 000000000000..3e8b35ba4350 --- /dev/null +++ b/pkgs/applications/misc/octoprint/default.nix @@ -0,0 +1,43 @@ +{ stdenv, fetchFromGitHub, pythonPackages }: + +pythonPackages.buildPythonPackage rec { + name = "OctoPrint-${version}"; + version = "1.2.9"; + + src = fetchFromGitHub { + owner = "foosel"; + repo = "OctoPrint"; + rev = version; + sha256 = "00hhq52jqwykhk3p57mn9kkcjbjz6g9mcrp96vx8lqzhw42m3a86"; + }; + + # We need old Tornado + propagatedBuildInputs = with pythonPackages; [ + awesome-slugify flask_assets watchdog rsa requests2 pkginfo pylru + semantic-version flask_principal sarge tornado_4_0_1 werkzeug netaddr flaskbabel + netifaces psutil pyserial flask_login pyyaml sockjs-tornado + ]; + + postPatch = '' + # Jailbreak dependencies + sed -i \ + -e 's,rsa==,rsa>=,g' \ + -e 's,sockjs-tornado==,sockjs-tornado>=,g' \ + -e 's,Flask-Principal==,Flask-Principal>=,g' \ + -e 's,werkzeug==,werkzeug>=,g' \ + -e 's,netaddr==,netaddr>=,g' \ + -e 's,requests==,requests>=,g' \ + -e 's,netifaces==,netifaces>=,g' \ + -e 's,psutil==,psutil>=,g' \ + -e 's,PyYAML==,PyYAML>=,g' \ + setup.py + ''; + + meta = with stdenv.lib; { + homepage = http://octoprint.org/; + description = "The snappy web interface for your 3D printer"; + platforms = platforms.all; + license = licenses.agpl3; + maintainers = with maintainers; [ abbradar ]; + }; +} diff --git a/pkgs/applications/misc/octoprint/plugins.nix b/pkgs/applications/misc/octoprint/plugins.nix new file mode 100644 index 000000000000..801be43220d9 --- /dev/null +++ b/pkgs/applications/misc/octoprint/plugins.nix @@ -0,0 +1,83 @@ +{ stdenv, fetchFromGitHub, octoprint, pythonPackages }: + +let + buildPlugin = args: pythonPackages.buildPythonPackage (args // { + buildInputs = (args.buildInputs or []) ++ [ octoprint ]; + }); +in { + + m3d-fio = buildPlugin rec { + name = "M3D-Fio-${version}"; + version = "0.26"; + + src = fetchFromGitHub { + owner = "donovan6000"; + repo = "M3D-Fio"; + rev = "V${version}"; + sha256 = "1dl8m0cxp2vzla2a729r3jrq5ahxkj10pygp7m9bblj5nn2s0rll"; + }; + + patches = [ + ./0001-Don-t-use-static-library.patch + ./0002-Try-to-create-connection-several-times-if-printer-is.patch + ]; + + postInstall = '' + ( + cd 'shared library source' + make + install -Dm755 libpreprocessor.so $out/lib/libpreprocessor.so + ) + rm -rf $out/${pythonPackages.python.sitePackages}/octoprint_m3dfio/static/libraries + ''; + + meta = with stdenv.lib; { + homepage = https://github.com/donovan6000/M3D-Fio; + description = " OctoPrint plugin for the Micro 3D printer"; + platforms = platforms.all; + license = licenses.gpl3; + maintainers = with maintainers; [ abbradar ]; + }; + }; + + titlestatus = buildPlugin rec { + name = "OctoPrint-TitleStatus-${version}"; + version = "0.0.2"; + + src = fetchFromGitHub { + owner = "MoonshineSG"; + repo = "OctoPrint-TitleStatus"; + rev = version; + sha256 = "0rfbpxbcmadyihcrynh6bjywy3yqnzsnjn3yiwifisbrjgpm6sfw"; + }; + + meta = with stdenv.lib; { + homepage = https://github.com/MoonshineSG/OctoPrint-TitleStatus; + description = "Show printers status in window title"; + platforms = platforms.all; + license = licenses.agpl3; + maintainers = with maintainers; [ abbradar ]; + }; + }; + + stlviewer = buildPlugin rec { + name = "OctoPrint-STLViewer-${version}"; + version = "0.3.0"; + + src = fetchFromGitHub { + owner = "jneilliii"; + repo = "OctoPrint-STLViewer"; + rev = "v${version}"; + sha256 = "1a6sa8pw9ay7x27pfwr3nzb22x3jaw0c9vwyz4mrj76zkiw6svfi"; + }; + + meta = with stdenv.lib; { + homepage = https://github.com/jneilliii/Octoprint-STLViewer; + description = "A simple stl viewer tab for OctoPrint"; + platforms = platforms.all; + license = licenses.agpl3; + maintainers = with maintainers; [ abbradar ]; + }; + }; + +} |