Example #1
0
    def clean_all_snapshots(self):
        #TODO:  FIX THIS.  IT NEEDS TO REMOVE ALL SUBDIRECTORIES IN THE SNAPSHOT FOLDER.
        # get snapshot directory
        snapshot_directory = utility.get_snapshot_temp_directory(
            self.DataDirectory)
        self.Settings.current_debug_profile().log_snapshot_clean(
            "Cleaning snapshots from: {0}".format(snapshot_directory))

        path = os.path.dirname(snapshot_directory + os.sep)
        if os.path.isdir(path):
            try:
                shutil.rmtree(path)
                self.Settings.current_debug_profile().log_snapshot_clean(
                    "Snapshots cleaned.")
            except:
                # Todo:  What exceptions to catch here?
                exception_type = sys.exc_info()[0]
                value = sys.exc_info()[1]
                message = (
                    "Snapshot - Clean - Unable to clean the snapshot "
                    "path at {0}.  It may already have been cleaned.  "
                    "Info:  ExceptionType:{1}, Exception Value:{2}").format(
                        path, exception_type, value)
                self.Settings.current_debug_profile().log_snapshot_clean(
                    message)
        else:
            self.Settings.current_debug_profile().log_snapshot_clean(
                "Snapshot - No need to clean snapshots: they have already been removed."
            )
Example #2
0
    def _on_render_end(self, *args, **kwargs):
        job_id = args[0]
        payload = args[1]

        self.Settings.current_debug_profile().log_render_complete("Completed rendering. JobId: {0}".format(job_id))
        assert (isinstance(payload, RenderingCallbackArgs))

        if not payload.HasError and self.Snapshot.cleanup_after_render_fail:
            self.CaptureSnapshot.clean_snapshots(utility.get_snapshot_temp_directory(self.DataFolder))
        elif self.Snapshot.cleanup_after_render_complete:
            self.CaptureSnapshot.clean_snapshots(utility.get_snapshot_temp_directory(self.DataFolder))

        if self.OnRenderEndCallback is not None:
            render_end_complete_callback_thread = threading.Thread(
                target=self.OnRenderEndCallback, args=[payload]
            )
            render_end_complete_callback_thread.daemon = True
            render_end_complete_callback_thread.start()
Example #3
0
    def _on_render_end(self, *args, **kwargs):
        job_id = args[0]
        payload = args[1]

        self.Settings.current_debug_profile().log_render_complete(
            "Completed rendering. JobId: {0}".format(job_id))
        assert (isinstance(payload, RenderingCallbackArgs))

        # Remove job from list.  If it is not there, raise an exception.
        self.RenderingJobs.remove(job_id)

        if payload.ErrorType is not None:
            if self.Snapshot.cleanup_after_render_fail:
                self.CaptureSnapshot.clean_snapshots(
                    utility.get_snapshot_temp_directory(self.DataFolder))
        else:
            if self.Snapshot.cleanup_after_render_complete:
                self.CaptureSnapshot.clean_snapshots(
                    utility.get_snapshot_temp_directory(self.DataFolder))

        if self.OnRenderEndCallback is not None:
            self.OnRenderEndCallback(payload)
Example #4
0
    def process(self, job_id, print_name, print_start_time, print_end_time,
                print_state):
        self.Settings.current_debug_profile().log_render_start(
            "Rendering is starting.")

        self.PrintState = print_state
        self.PrintName = print_name
        self.PrintStartTime = print_start_time
        self.PrintEndTime = print_end_time

        # Get the capture file and directory info
        snapshot_directory = utility.get_snapshot_temp_directory(
            self.DataDirectory)
        snapshot_file_name_template = utility.get_snapshot_filename(
            print_name, print_start_time, utility.SnapshotNumberFormat)
        output_tokens = self._get_output_tokens()

        job = TimelapseRenderJob(
            job_id,
            self.Rendering,
            self.Settings.current_debug_profile(),
            print_name,
            snapshot_directory,
            snapshot_file_name_template,
            output_tokens,
            self.OctoprintTimelapseFolder,
            self.FfmpegPath,
            self.ThreadCount,
            time_added=self.TimeAdded,
            on_render_start=self.OnRenderStart,
            on_render_fail=self.OnRenderFail,
            on_render_success=self.OnRenderSuccess,
            on_render_complete=self.OnRenderComplete,
            on_after_sync_fail=self.OnAfterSyncFail,
            on_after_sync_success=self.OnAfterSycnSuccess,
            on_complete=self.OnComplete,
            clean_after_success=self.Snapshot.cleanup_after_render_complete,
            clean_after_fail=self.Snapshot.cleanup_after_render_complete)
        job.process()
Example #5
0
    def create_render_job(settings, snapshot, rendering, data_directory,
                          octoprint_timelapse_folder, ffmpeg_path,
                          thread_count, render_task_queue, job_id, print_name,
                          print_start_time, print_end_time, print_state,
                          time_added, on_render_start, on_complete):
        # Get the capture file and directory info
        snapshot_directory = utility.get_snapshot_temp_directory(
            data_directory)
        snapshot_file_name_template = utility.get_snapshot_filename(
            print_name, print_start_time, utility.SnapshotNumberFormat)
        output_tokens = Render._get_output_tokens(data_directory, print_state,
                                                  print_name, print_start_time,
                                                  print_end_time)

        job = TimelapseRenderJob(job_id, rendering,
                                 settings.current_debug_profile(), print_name,
                                 snapshot_directory,
                                 snapshot_file_name_template, output_tokens,
                                 octoprint_timelapse_folder, ffmpeg_path,
                                 thread_count, render_task_queue, time_added,
                                 on_render_start, on_complete,
                                 snapshot.cleanup_after_render_complete,
                                 snapshot.cleanup_after_render_complete)
        return job.process