Skip to content

Instantly share code, notes, and snippets.

@foosel
Last active September 15, 2021 13:24
Show Gist options
  • Save foosel/cadc38123687a46816a1d3e1d160d48a to your computer and use it in GitHub Desktop.
Save foosel/cadc38123687a46816a1d3e1d160d48a to your computer and use it in GitHub Desktop.
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