Ejemplo n.º 1
0
 def __init__(self,
              timelapse_job_info,
              temporary_directory,
              snapshot_number,
              current_camera,
              job_type,
              metadata={}):
     self.camera = current_camera
     self.temporary_directory = temporary_directory
     self.snapshot_directory = utility.get_temporary_snapshot_job_camera_path(
         temporary_directory, timelapse_job_info.JobGuid,
         current_camera.guid)
     self.snapshot_file_name = utility.get_snapshot_filename(
         timelapse_job_info.PrintFileName, snapshot_number)
     self.snapshot_full_path = os.path.join(self.snapshot_directory,
                                            self.snapshot_file_name)
     self.snapshot_number = snapshot_number
     self.camera_guid = current_camera.guid
     self.success = False
     self.error = ""
     self.delay_seconds = current_camera.delay / 1000.0
     self.timeout_seconds = current_camera.timeout_ms / 1000.0
     self.snapshot_number = snapshot_number
     self.job_type = job_type
     self.metadata = metadata
Ejemplo n.º 2
0
    def setUp(self):
        self.octolapse_settings = OctolapseSettings(NamedTemporaryFile().name)
        self.rendering_job_id = "job_id"

        self.print_name = "print_name"
        self.print_start_time = 0
        self.print_end_time = 100

        # Create fake snapshots.
        self.capture_template = get_snapshot_filename(self.print_name,
                                                      SnapshotNumberFormat)
        self.data_directory = mkdtemp()
        self.octoprint_timelapse_folder = mkdtemp()

        self.ffmpeg_path = "ffmpeg"
        self.render_task_queue = Queue(maxsize=1)
        self.render_task_queue.put(self.rendering_job_id)
Ejemplo n.º 3
0
 def __init__(self, timelapse_job_info, data_directory, snapshot_number,
              current_camera):
     self.camera = current_camera
     self.directory = os.path.join(data_directory, "snapshots",
                                   timelapse_job_info.JobGuid,
                                   current_camera.guid)
     self.file_name = utility.get_snapshot_filename(
         timelapse_job_info.PrintFileName,
         timelapse_job_info.PrintStartTime, snapshot_number)
     self.snapshot_number = snapshot_number
     self.camera_guid = current_camera.guid
     self.success = False
     self.error = ""
     self.DelaySeconds = current_camera.delay / 1000.0
     self.TimeoutSeconds = current_camera.timeout_ms / 1000.0
     self.SnapshotNumber = snapshot_number
     self.DataDirectory = data_directory
     self.SnapshotTranspose = current_camera.snapshot_transpose
Ejemplo n.º 4
0
 def __init__(self, timelapse_job_info, data_directory, current_camera,
              print_state, job_number, total_jobs):
     self.job_id = timelapse_job_info.JobGuid
     self.job_number = job_number
     self.total_jobs = total_jobs
     self.camera = current_camera
     self.job_directory = os.path.join(data_directory, "snapshots",
                                       timelapse_job_info.JobGuid)
     self.snapshot_directory = os.path.join(data_directory, "snapshots",
                                            timelapse_job_info.JobGuid,
                                            current_camera.guid)
     self.snapshot_filename_format = os.path.basename(
         utility.get_snapshot_filename(timelapse_job_info.PrintFileName,
                                       timelapse_job_info.PrintStartTime,
                                       utility.SnapshotNumberFormat))
     self.output_tokens = self._get_output_tokens(
         data_directory, print_state, timelapse_job_info.PrintFileName,
         timelapse_job_info.PrintStartTime, timelapse_job_info.PrintEndTime)
Ejemplo n.º 5
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()
Ejemplo n.º 6
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