diff --git a/src/octoprint/plugins/action_command_prompt/__init__.py b/src/octoprint/plugins/action_command_prompt/__init__.py index 680ea9dd1..d0e7f97ea 100644 --- a/src/octoprint/plugins/action_command_prompt/__init__.py +++ b/src/octoprint/plugins/action_command_prompt/__init__.py @@ -221,10 +221,12 @@ class ActionCommandPromptPlugin(octoprint.plugin.AssetPlugin, self._close_prompt() if "{choice}" in self._command: - self._printer.commands([self._command.format(choice=choice)]) + self._printer.commands([self._command.format(choice=choice)], + force=True) else: self._printer.commands(["{command} S{choice}".format(command=self._command, - choice=choice)]) + choice=choice)], + force=True) __plugin_name__ = "Action Command Prompt Support" diff --git a/src/octoprint/printer/__init__.py b/src/octoprint/printer/__init__.py index 09b8e25d7..529b0d475 100644 --- a/src/octoprint/printer/__init__.py +++ b/src/octoprint/printer/__init__.py @@ -175,7 +175,7 @@ class PrinterInterface(object): """ raise NotImplementedError() - def commands(self, commands, tags=None, *args, **kwargs): + def commands(self, commands, tags=None, force=False, *args, **kwargs): """ Sends the provided ``commands`` to the printer. @@ -183,6 +183,7 @@ class PrinterInterface(object): commands (str, list): The commands to send. Might be a single command provided just as a string or a list of multiple commands to send in order. tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle + force (bool): Whether to force sending of the command right away or allow queuing while printing """ raise NotImplementedError() diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 6aab74705..9296832a5 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -303,7 +303,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): self._comm.fakeOk() - def commands(self, commands, *args, **kwargs): + def commands(self, commands, tags=None, force=False, *args, **kwargs): """ Sends one or more gcode commands to the printer. """ @@ -313,8 +313,14 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): if not isinstance(commands, (list, tuple)): commands = [commands] + if tags is None: + tags = set() + tags |= {"trigger:printer.commands"} + for command in commands: - self._comm.sendCommand(command, tags=kwargs.get("tags", set()) | {"trigger:printer.commands"}) + self._comm.sendCommand(command, + tags=tags, + force=force) def script(self, name, context=None, must_be_set=True, part_of_job=False, *args, **kwargs): if self._comm is None: