Add check for valid job file type to job validation
This commit is contained in:
parent
c1c75f032d
commit
dc8473bc4d
2 changed files with 9 additions and 2 deletions
|
|
@ -299,6 +299,7 @@ class PrinterInterface(object):
|
|||
after the file is selected.
|
||||
|
||||
Raises:
|
||||
InvalidFileType: if the file is not a machinecode file and hence cannot be printed
|
||||
InvalidFileLocation: if an absolute path was provided and not contained within local storage or
|
||||
doesn't exist
|
||||
"""
|
||||
|
|
@ -593,3 +594,6 @@ class UnknownScript(Exception):
|
|||
|
||||
class InvalidFileLocation(Exception):
|
||||
pass
|
||||
|
||||
class InvalidFileType(Exception):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ import time
|
|||
|
||||
from octoprint import util as util
|
||||
from octoprint.events import eventManager, Events
|
||||
from octoprint.filemanager import FileDestinations, NoSuchStorage
|
||||
from octoprint.filemanager import FileDestinations, NoSuchStorage, valid_file_type
|
||||
from octoprint.plugin import plugin_manager, ProgressPlugin
|
||||
from octoprint.printer import PrinterInterface, PrinterCallback, UnknownScript, InvalidFileLocation
|
||||
from octoprint.printer import PrinterInterface, PrinterCallback, UnknownScript, InvalidFileLocation, InvalidFileType
|
||||
from octoprint.printer.estimation import TimeEstimationHelper
|
||||
from octoprint.settings import settings
|
||||
from octoprint.util import comm as comm
|
||||
|
|
@ -846,6 +846,9 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
|||
self._stateMonitor.add_temperature(data)
|
||||
|
||||
def _validateJob(self, filename, sd):
|
||||
if not valid_file_type(filename, type="machinecode"):
|
||||
raise InvalidFileType("{} is not a machinecode file, cannot print".format(filename))
|
||||
|
||||
if sd:
|
||||
return
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue