def _render_timelapse(self, print_end_state): # make sure we have a non null TimelapseSettings object. We may have terminated the timelapse for some reason if self.Rendering is not None and self.Rendering.enabled: self.Settings.current_debug_profile().log_render_start("Started Rendering Timelapse") # we are rendering, set the state before starting the rendering job. timelapse_render_job = Render( self.Settings, self.Snapshot, self.Rendering, self.DataFolder, self.DefaultTimelapseDirectory, self.FfMpegPath, 1, time_added=self.SecondsAddedByOctolapse, on_render_start=self._on_render_start, on_render_fail=self._on_render_fail, on_render_success=self._on_render_success, on_render_complete=self.on_render_complete, on_after_sync_fail=self._on_synchronize_rendering_fail, on_after_sync_success=self._on_synchronize_rendering_complete, on_complete=self._on_render_end ) job_id = "TimelapseRenderJob_{0}".format(str(uuid.uuid4())) self.RenderingJobs.add(job_id) try: timelapse_render_job.process(job_id, utility.get_currently_printing_filename( self.OctoprintPrinter), self.PrintStartTime, time.time(), print_end_state) return True except Exception as e: self.Settings.current_debug_profile().log_exception(e) self.RenderingJobs.remove(job_id) return False
def _renderTimelapse(self): # make sure we have a non null TimelapseSettings object. We may have terminated the timelapse for some reason if (self.Rendering.enabled): self.Settings.CurrentDebugProfile().LogRenderStart( "Started Rendering Timelapse") # we are rendering, set the state before starting the rendering job. self.IsRendering = True timelapseRenderJob = Render( self.Settings, self.Snapshot, self.Rendering, self.DataFolder, self.DefaultTimelapseDirectory, self.FfMpegPath, 1, timeAdded=self.SecondsAddedByOctolapse, onRenderStart=self._onRenderStart, onRenderFail=self._onRenderFail, onRenderSuccess=self._onRenderSuccess, onRenderComplete=self._onRenderComplete, onAfterSyncFail=self._onSynchronizeRenderingFail, onAfterSycnSuccess=self._onSynchronizeRenderingComplete, onComplete=self._onRenderEnd) timelapseRenderJob.Process( utility.CurrentlyPrintingFileName(self.OctoprintPrinter), self.PrintStartTime, time.time()) return True return False
def createRenderingJob(self, rendering): self.on_render_start = Mock(return_value=None) self.on_render_success = Mock(return_value=None) self.on_render_error = Mock(return_value=None) return TimelapseRenderJob( job_id=self.rendering_job_id, rendering=rendering, debug=self.octolapse_settings.current_debug_profile(), print_filename=self.print_name, capture_dir=self.snapshot_dir_path, snapshot_filename_format=self.capture_template, output_tokens=Render._get_output_tokens(self.data_directory, "COMPLETED", self.print_name, self.print_start_time, self.print_end_time), octoprint_timelapse_folder=self.octoprint_timelapse_folder, ffmpeg_path=self.ffmpeg_path, threads=1, time_added=0, on_render_start=self.on_render_start, on_success=self.on_render_success, on_error=self.on_render_error, clean_after_success=True, clean_after_fail=True)
def _render_timelapse(self, print_end_state): def _render_timelapse_async(render_job_id, timelapse_render_job): try: snapshot_thread = threading.Thread(target=timelapse_render_job, args=[]) snapshot_thread.daemon = True num_snapshot_tasks = self._snapshot_task_queue.qsize() if num_snapshot_tasks > 0: self.Settings.current_debug_profile().log_render_start("Started Rendering Timelapse.") else: self.Settings.current_debug_profile().log_render_start( "Waiting for {0} snapshot threads to complete".format( self._snapshot_task_queue.qsize())) self._snapshot_task_queue.join() self.Settings.current_debug_profile().log_render_start( "All snapshot tasks have completed, rendering timelapse" ) # we are rendering, set the state before starting the rendering job. self._rendering_task_queue.put(render_job_id) snapshot_thread.start() except Exception as e: self.Settings.current_debug_profile().log_exception(e) self._rendering_task_queue.get() self._rendering_task_queue.task_done() # make sure we have a non null TimelapseSettings object. We may have terminated the timelapse for some reason if self.Rendering is not None and self.Rendering.enabled: job_id = "TimelapseRenderJob_{0}".format(str(uuid.uuid4())) job = Render.create_render_job( self.Settings, self.Snapshot, self.Rendering, self.DataFolder, self.DefaultTimelapseDirectory, self.FfMpegPath, 1, self._rendering_task_queue, job_id, utility.get_currently_printing_filename(self.OctoprintPrinter), self.PrintStartTime, time.time(), print_end_state, self.SecondsAddedByOctolapse, self._on_render_start, self._on_render_end ) rendering_thread = threading.Thread(target=_render_timelapse_async, args=[job_id, job]) rendering_thread.daemon = True rendering_thread.start() return True return False
def createRenderingJob(self, rendering): return TimelapseRenderJob( job_id=self.rendering_job_id, rendering=rendering, debug=self.octolapse_settings.current_debug_profile(), print_filename=self.print_name, capture_dir=self.snapshot_dir_path, capture_template=self.capture_template, output_tokens=Render._get_output_tokens(self.data_directory, "COMPLETED", self.print_name, self.print_start_time, self.print_end_time), octoprint_timelapse_folder=self.octoprint_timelapse_folder, ffmpeg_path=self.ffmpeg_path, threads=1, rendering_task_queue=self.render_task_queue, time_added=0, on_render_start=lambda job_id, payload: None, on_complete=lambda job_id, payload: None, clean_after_success=True, clean_after_fail=True)