How to use the octoprint.plugin function in OctoPrint

To help you get started, we’ve selected a few OctoPrint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OllisGit / OctoPrint-DisplayLayerProgress / octoprint_DisplayLayerProgress / __init__.py View on Github external
matched = pattern.match(line)
        if matched:
            groupIndex = layerExpression.groupIndex
            if layerExpression.type_countable:
                self._currentLayerCount = self._currentLayerCount + 1
                currentLayer = str(self._currentLayerCount)
            else:
                currentLayer = str(matched.group(groupIndex))
            line = line + LAYER_MESSAGE_PREFIX + currentLayer + "\r\n"
        return line


class DisplaylayerprogressPlugin(
    octoprint.plugin.StartupPlugin,
    octoprint.plugin.SettingsPlugin,
    octoprint.plugin.AssetPlugin,
    octoprint.plugin.TemplatePlugin,
    # my stuff
    octoprint.plugin.EventHandlerPlugin,
    octoprint.plugin.ProgressPlugin,
    octoprint.plugin.SimpleApiPlugin,
    octoprint.plugin.BlueprintPlugin
):
    # VAR
    _tempCurrentHeightFromFile = 0.0
    _tempCurrentTotalHeight = 0.0
    _currentLayerCount = 0
    _layerTotalCount = NOT_PRESENT
    _currentLayer = NOT_PRESENT
    _progress = str(0)
    _currentHeight = NOT_PRESENT
    _totalHeight = NOT_PRESENT
github pkElectronics / OctoPrint-Octoremote / octoprint_OctoRemote / __init__.py View on Github external
# coding=utf-8
from __future__ import absolute_import
import octoprint.plugin
import serial
import binascii
from threading import Thread
import time

from time import sleep


class OctoremotePlugin(octoprint.plugin.SettingsPlugin,
					   octoprint.plugin.AssetPlugin,
					   octoprint.plugin.TemplatePlugin,
					   octoprint.plugin.StartupPlugin,
					   octoprint.plugin.ShutdownPlugin):
	##~~ SettingsPlugin mixin

	def get_settings_defaults(self):
		return dict(
			comport="COM3",
			baudrate=115200,
			baudrateOpt=[9600, 19200, 115200],
			extrusionAmount=5,
			retractionAmount=5,
			numberOfTools=3,
			movementSteps=[0.1, 1, 10, 100],
			movementStep1=0.1,
			movementStep2=1,
			movementStep3=10,
			movementStep4=100,
			userCommand1 = "",
github synman / Octoprint-Bettergrblsupport / octoprint_bettergrblsupport / __init__.py View on Github external
from __future__ import absolute_import
from octoprint.events import Events

# import sys
import time
import math
import os
import subprocess

import octoprint.plugin
import re
import logging
import json
import flask

class BetterGrblSupportPlugin(octoprint.plugin.SettingsPlugin,
                              octoprint.plugin.SimpleApiPlugin,
                              octoprint.plugin.AssetPlugin,
                              octoprint.plugin.TemplatePlugin,
                              octoprint.plugin.StartupPlugin,
                              octoprint.plugin.EventHandlerPlugin):

    def __init__(self):
        self.hideTempTab = True
        self.hideControlTab = True
        self.hideGCodeTab = True
        self.customControls = False
        self.helloCommand = "M5"
        self.statusCommand = "?$G"
        self.dwellCommand = "G4 P0"
        self.positionCommand = "?"
        self.suppressM114 = True
github sidddy / OctoScreen / octoprint_plugin / octoscreen_plugin.py View on Github external
import octoprint.plugin

class OctoscreenPlugin(octoprint.plugin.StartupPlugin,octoprint.plugin.EventHandlerPlugin,octoprint.plugin.SimpleApiPlugin):
	_repeat_timer = None

	def __init__(self):
		self.mqtt_publish = lambda *args, **kwargs: None
		self.mqtt_subscribe = lambda *args, **kwargs: None
		self.mqtt_unsubscribe = lambda *args, **kwargs: None

	def get_api_commands(self):
		return dict(dummy=[])

	def on_api_get(self, request):
		from flask import jsonify
		from octoprint.server import fileManager
		import octoprint.filemanager
		import octoprint.filemanager.util
		import octoprint.filemanager.storage
github sedgett / OctoPrint_IFTTTmaker / octoprint_IFTTTmaker / __init__.py View on Github external
# coding=utf-8
from __future__ import absolute_import

import octoprint.plugin
import requests
from octoprint.events import Events

import os


class IFTTTMakerPlugin(octoprint.plugin.StartupPlugin,
                        octoprint.plugin.TemplatePlugin,
                        octoprint.plugin.SettingsPlugin,
                        octoprint.plugin.RestartNeedingPlugin,
                        octoprint.plugin.EventHandlerPlugin):

    def on_settings_save(self, data):
        octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
        if (hasattr, self._settings, 'makerkey'):
#            self.makerkey = self._settings.get(["makerkey"])
            self._logger.info("Saving IFTTT Maker Key: %s" % self._settings.get(["makerkey"]))
        else:
#            self.makerkey=''
            self._logger.info("No Maker key set while trying to save!")
                    
    def on_after_startup(self):
        self._logger.info("IFTTT Maker Plugin Active")
#        self.makerkey = self._settings.get(["makerkey"])
github dattas / OctoPrint-DetailedProgress / octoprint_detailedprogress / __init__.py View on Github external
# coding=utf-8
from __future__ import absolute_import
import time
import socket

import octoprint.plugin
import octoprint.util
import traceback
from octoprint.events import Events

class DetailedProgressPlugin(octoprint.plugin.EventHandlerPlugin,
                             octoprint.plugin.SettingsPlugin):
	_last_updated = 0.0
	_last_message = 0
	_repeat_timer = None
	_etl_format = ""
	_eta_strftime = ""
	_messages = []
	def on_event(self, event, payload):
		if event == Events.PRINT_STARTED:
			self._logger.info("Printing started. Detailed progress started.")
			self._etl_format = self._settings.get(["etl_format"])
			self._eta_strftime = self._settings.get(["eta_strftime"])
			self._messages = self._settings.get(["messages"])
			self._repeat_timer = octoprint.util.RepeatedTimer(self._settings.get_int(["time_to_change"]), self.do_work)
			self._repeat_timer.start()
		elif event in (Events.PRINT_DONE, Events.PRINT_FAILED, Events.PRINT_CANCELLED):
github ieatacid / OctoPrint-TerminalCommands / octoprint_TerminalCommands / __init__.py View on Github external
# coding=utf-8
from __future__ import absolute_import

import octoprint.plugin

class TerminalCommandsPlugin(octoprint.plugin.SettingsPlugin,
                             octoprint.plugin.AssetPlugin,
                             octoprint.plugin.TemplatePlugin):

	def get_settings_defaults(self):
		return dict(
			controls=[]
		)

	def get_assets(self):
		return dict(
			js=["js/TerminalCommands.js"],
			css=["css/TerminalCommands.css"]
		)

	def get_template_configs(self):
		return [
            dict(type="settings", custom_bindings=True)
        ]
github scottrini / OctoPrint-PrusaLevelingGuide / octoprint_PrusaLevelingGuide / __init__.py View on Github external
# coding=utf-8
from __future__ import absolute_import


import time
import datetime
import octoprint.plugin
import octoprint.printer
import re

import flask


class PrusaLevelingGuidePlugin(octoprint.plugin.SimpleApiPlugin,
							octoprint.plugin.SettingsPlugin,
                          octoprint.plugin.AssetPlugin,
                          octoprint.plugin.TemplatePlugin,
                          octoprint.plugin.StartupPlugin):
	
	
	def on_after_startup(self):
		self.bed_variance = None
		self.relative_values = []
		self.last_result = None
		self.regex = re.compile(r"^(  -?\d+.\d+)+$")
		self.waiting_for_response = False
		self.sent_time = False