Skip to content

Commit

Permalink
New Version 1.25.3
Browse files Browse the repository at this point in the history
#205 ...fix for another stupid mistake
  • Loading branch information
OllisGit committed Jan 31, 2021
1 parent 8b3eda0 commit cad2f79
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
27 changes: 18 additions & 9 deletions octoprint_DisplayLayerProgress/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,11 @@ def createFilePreProcessor(self, path, file_object, blinks=None, printer_profile
if addLayerIndicators == False:
return file_object

alreadyAddedLayerIndicators = self._alreadyAddedLayerIndicators(file_object["path"], file_object["filename"])
if (alreadyAddedLayerIndicators == "property found" or alreadyAddedLayerIndicators == "marker found"):
return file_object
if (hasattr(file_object, "path")):
path = file_object.path
alreadyAddedLayerIndicators = self._alreadyAddedLayerIndicators(path)
if (alreadyAddedLayerIndicators == "property found" or alreadyAddedLayerIndicators == "marker found"):
return file_object

# check filesize
# filePath = file_object.path
Expand Down Expand Up @@ -1053,7 +1055,7 @@ def _parseLayerExpressions(self, layerExpressionPatterns):
# - no marker
# - property found
# - marker found
def _alreadyAddedLayerIndicators(self, path, filename):
def _alreadyAddedLayerIndicators(self, path):
resultType = "no marker"
try:
lastLines = stringUtils.getLastLinesFromFile(path, 10)
Expand Down Expand Up @@ -1084,7 +1086,7 @@ def _alreadyAddedLayerIndicators(self, path, filename):
return resultType

# Add at the end of the file a property to indicate the this file was alread processed
def _markFileLayerIndicatorProcessed(self, storage, path, name):
def _markFileLayerIndicatorProcessed(self, path):
try:
fileHandle = open(path, "a+")
fileHandle.write("; BEGIN DISPLAYLAYERPROGRESS SETTINGS\n")
Expand Down Expand Up @@ -1236,9 +1238,16 @@ def on_event(self, event, payload):
self._updateDisplay(UPDATE_DISPLAY_REASON_FRONTEND_CALL)

elif event == Events.FILE_ADDED:
fileLocation = payload.get("storage")
addedFilename = payload.get("name")

if (self._layerDetectorFileProcessorLastProcessedFilename != None):
# mark this file that LayerIndicators were added
self._markFileLayerIndicatorProcessed(payload["storage"], payload["path"], payload["name"])
if (fileLocation == octoprint.filemanager.FileDestinations.LOCAL):
addedFile = self._file_manager.path_on_disk(fileLocation, addedFilename)
# mark this file that LayerIndicators were added
self._markFileLayerIndicatorProcessed(addedFile)
else:
pass #skipping sd-card files

elif event == Events.FILE_SELECTED:
self._initializeEventLogger()
Expand Down Expand Up @@ -1335,10 +1344,10 @@ def on_event(self, event, payload):
self._storeLayerCountInMeta(fileLocation, selectedFilename, self._layerTotalCountWithoutOffset)

# New check if file is already marked with property
resultType = self._alreadyAddedLayerIndicators(selectedFile, selectedFile)
resultType = self._alreadyAddedLayerIndicators(selectedFile)
if (resultType == "marker found"):
# add property to confirm that the file already marked
self._markFileLayerIndicatorProcessed("", selectedFile ,"")
self._markFileLayerIndicatorProcessed(selectedFile)

except Exception as error:
errorMessage = "ERROR! File: '" + selectedFile + "' Line: " + str(lineNumber) + " Message: '" + str(error) + "'"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
plugin_name = "DisplayLayerProgress"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "1.25.2"
plugin_version = "1.25.3"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit cad2f79

Please sign in to comment.