Skip to content

Instantly share code, notes, and snippets.

@foosel

foosel/m33_storm.py

Last active Jul 13, 2020
Embed
What would you like to do?
Requests long names for files on printer's SD card via M33. OctoPrint 1.4.2+. No maintenance, no support.
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
import octoprint.plugin
import octoprint.events
import octoprint.util.comm
class M33StormPlugin(octoprint.plugin.EventHandlerPlugin):
def __init__(self):
self._active = False
def on_event(self, event, payload):
if event != octoprint.events.Events.UPDATED_FILES:
return
if payload.get("type") != "printables":
return
if self._active:
return
sd_files = self._printer.get_sd_files()
commands = list(map(lambda x: "M33 /{}".format(x["name"]),
filter(lambda x: x["display"] == None,
sd_files)))
if commands:
self._active = True
def process():
self._active = False
marker = octoprint.util.comm.SendQueueMarker(process)
commands.append(marker)
self._printer.commands(commands)
__plugin_name__ = "M33 Storm"
__plugin_description__ = "Requests long names for files on printer's SD card via M33"
__plugin_author__ = "Gina Häußge"
__plugin_implementation__ = M33StormPlugin()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.