Skip to content

Commit

Permalink
Handle last BFT filename string indexes
Browse files Browse the repository at this point in the history
Filename index is a string in OctoPrint >= 1.8.0
  • Loading branch information
benlye committed May 26, 2022
1 parent a2a5556 commit d5a9057
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions octoprint_firmwareupdater/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ def get_lastbft_filename(self):
return None
if profile_id in filenames.keys():
return filenames[profile_id]
elif str(profile_id) in filenames.keys():
return filenames[str(profile_id)]
else:
return None
else:
Expand All @@ -531,7 +533,7 @@ def set_lastbft_filename(self, value):
last_bft_filenames = self._settings.get(["last_bft_filenames"])
last_bft_filenames[profile_id] = value
self._settings.set(["last_bft_filenames"], last_bft_filenames)

# Send capability information to the UI
def _send_capability(self, capability, enabled):
self._plugin_manager.send_plugin_message(self._identifier, dict(type="capability", capability=capability, enabled=enabled))
Expand Down Expand Up @@ -718,7 +720,7 @@ def on_settings_migrate(self, target, current=None):
if "marlinbft_last_filename" in profile and profile["marlinbft_last_filename"] is not None:
last_bft_filenames_new.update({index: profile["marlinbft_last_filename"]})
del profile["marlinbft_last_filename"]

profiles_new.append(profile)

self._settings.set(['last_bft_filenames'],last_bft_filenames_new)
Expand Down
8 changes: 4 additions & 4 deletions octoprint_firmwareupdater/methods/marlinbft.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def _flash_marlinbft(self, firmware=None, printer_port=None, **kwargs):
time.sleep(bft_waitafterconnect)

# Try to delete the last-flashed file
if timestamp_filenames and self.get_lastbft_filename() is not None:
last_filename = self.get_lastbft_filename()
last_filename = self.get_lastbft_filename()
if timestamp_filenames and last_filename is not None:
self._logger.info(u"Attempting to delete previous firmware file /{}".format(last_filename))
protocol.send_ascii("M21")
protocol.send_ascii("M30 {}".format(last_filename))
Expand Down Expand Up @@ -245,7 +245,7 @@ def _wait_for_start(self, printer_port=None):
if not restarted:
self._logger.error(u"Timeout waiting for board to reset")
return False

end = time.time()
duration = round((end - start),2)

Expand Down Expand Up @@ -303,7 +303,7 @@ def _wait_for_board(self, printer_port=None, no_restart_wait=False):
m997_restart_wait = self.get_profile_setting("marlinbft_m997_restart_wait")
if m997_restart_wait is None:
m997_restart_wait = 20

self._logger.info(u"Waiting {seconds}s for printer at '{port}' to restart".format(seconds=m997_restart_wait, port=printer_port))

timeout = m997_restart_wait
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 = "OctoPrint-FirmwareUpdater"

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

# 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 d5a9057

Please sign in to comment.