Skip to content

Commit

Permalink
Work on Issue #516
Browse files Browse the repository at this point in the history
  • Loading branch information
FormerLurker committed May 8, 2020
1 parent 163be9f commit 8b78780
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
16 changes: 6 additions & 10 deletions octoprint_octolapse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ def cancel_preprocessing_request(self):
self.preprocessing_job_guid = None
self.cancel_preprocessing()
if self._printer.is_printing():
self._printer.cancel_print(tags={'startup-failed'})
self._printer.cancel_print(tags={'octolapse-startup-failed'})
self.send_snapshot_preview_complete_message()
return jsonify({
'success': True
Expand Down Expand Up @@ -2004,7 +2004,7 @@ def copy_octoprint_default_settings(self, apply_to_current_profile=False):
snapshot_action = urlparse(snapshot_url).query
snapshot_request_template = "{camera_address}?" + snapshot_action
logger.info("Setting octolapse camera snapshot template to %s.",
snapshot_request_template.replace('{', '{{').replace('}', '}}'))
snapshot_request_template.replace('{', '{{').replace('}', '}}')) # but why???
self._octolapse_settings.profiles.defaults.camera.webcam_settings.address = camera_address
self._octolapse_settings.profiles.defaults.camera.webcam_settings.snapshot_request_template = snapshot_request_template
if apply_to_current_profile:
Expand Down Expand Up @@ -2795,15 +2795,16 @@ def start_timelapse(self, timelapse_settings, snapshot_plans=None):
def on_print_start_failed(self, errors):
if not isinstance(errors, list):
errors = [errors]
# see if there is a job lock, if you find one release it, and don't wait for signals.
self._timelapse.release_job_on_hold_lock(True)

if self._octolapse_settings.main_settings.cancel_print_on_startup_error:
self._printer.cancel_print(tags={'startup-failed'})
self._printer.cancel_print(tags={'octolapse-startup-failed'})
self.send_plugin_errors("print-start-error", errors=errors)
else:
self.send_plugin_errors("print-start-warning", errors=errors)

# see if there is a job lock, if you find one release it, and don't wait for signals.
self._timelapse.release_job_on_hold_lock(True)

def on_preprocessing_failed(self, errors):
message_type = "gcode-preprocessing-failed"
self.send_plugin_errors(message_type, errors)
Expand Down Expand Up @@ -3713,11 +3714,6 @@ def admin_permission_validator(flask_request):
)
]

from ._version import get_versions
__version__ = get_versions()['version']
__git_version__ = get_versions()['full-revisionid']
del get_versions

__plugin_name__ = "Octolapse"
__plugin_pythoncompat__ = ">=2.7,<4"

Expand Down
11 changes: 9 additions & 2 deletions octoprint_octolapse/timelapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,8 +887,13 @@ def detect_timelapse_start(self, command_string, tags):
self._state == TimelapseState.Idle and
self.get_current_octolapse_settings().main_settings.is_octolapse_enabled and
(
{'trigger:comm.start_print', 'trigger:comm.reset_line_numbers'} <= tags or
{'script:beforePrintStarted', 'trigger:comm.send_gcode_script'} <= tags
(
'trigger:comm.start_print' in tags and
(
'trigger:comm.reset_line_numbers' in tags or
command_string.startswith("M23")
)
) or {'script:beforePrintStarted', 'trigger:comm.send_gcode_script'} <= tags
) and self._octoprint_printer.is_printing()
):
if self._octoprint_printer.set_job_on_hold(True):
Expand All @@ -905,10 +910,12 @@ def detect_timelapse_start(self, command_string, tags):
try:
parsed_command = GcodeProcessor.parse(command_string)
except ValueError as e:
self._state = TimelapseState.Idle
logger.exception("Unable to parse the command string.")
# if we don't return NONE here, we will have problems with the print!
return None
except Exception as e:
self._state = TimelapseState.Idle
logger.exception("An unexpected exception occurred while trying to parse the command string.")
# TODO: REMOVE THIS BECAUSE IT'S TOO BROAD!
raise e
Expand Down

0 comments on commit 8b78780

Please sign in to comment.