def checkin_render(self): render_dir = self.render_context.get_render_dir() # create a render log entry file = open("%s/session.xml" % render_dir, "r") session_xml = file.read() file.close() # attach the sobject and snapshot to the render snapshot = self.render_context.get_snapshot() sobject = self.render_context.get_sobject() file_range = self.render_context.get_frame_range().get_key() render = Render.create(sobject, snapshot, file_range, session_xml) self.description = "Rendered image" # create a reference snapshot snapshot_builder = SnapshotBuilder() snapshot_builder.add_ref_by_snapshot(snapshot) checkin = SnapshotCheckin( sobject, snapshot_builder.to_string, \ snapshot_type="set", context="render" ) checkin.execute() # checkin the rendered files to the render object paths = [] types = [] paths.append( final_path ) types.append( "frame" ) file_range = self.render_context.get_frame_range() snapshot_type = "frame" checkin = FileGroupCheckin(render, snapshot_type, "render", "snapshot", paths, types, file_range.get_key() ) checkin.add_input_snapshot(snapshot) checkin.execute()
def execute(self): web = WebContainer.get_web() if web.get_form_value("add") == "": raise CommandExitException() # get the source search_type = web.get_form_value("search_type") search_id = web.get_form_value("search_id") parent = Search.get_by_id(search_type, search_id) parent_snapshot = Snapshot.get_latest_by_sobject(parent) parent_xml = parent_snapshot.get_xml_value("snapshot") parent_builder = SnapshotBuilder(parent_xml) # get the selected textures selected = web.get_form_values("selected") self.add_description("Adding source to texture for [%s]" % ','.join(selected)) for select in selected: sobject = Search.get_by_search_key(select) # add a backward reference sobject_snapshot = Snapshot.get_latest_by_sobject(sobject) xml = sobject_snapshot.get_xml_value("snapshot") builder = SnapshotBuilder(xml) builder.add_ref_by_snapshot(parent_snapshot) sobject_snapshot.set_value("snapshot", builder.to_string()) sobject_snapshot.commit() # add a forward reference parent_builder.add_fref_by_snapshot(sobject_snapshot) parent_snapshot.set_value("snapshot", parent_builder.to_string()) parent_snapshot.commit()
def execute(my): web = WebContainer.get_web() if web.get_form_value("add") == "": raise CommandExitException() # get the source search_type = web.get_form_value("search_type") search_id = web.get_form_value("search_id") parent = Search.get_by_id(search_type,search_id) parent_snapshot = Snapshot.get_latest_by_sobject(parent) parent_xml = parent_snapshot.get_xml_value("snapshot") parent_builder = SnapshotBuilder(parent_xml) # get the selected textures selected = web.get_form_values("selected") my.add_description("Adding source to texture for [%s]" %','.join(selected)) for select in selected: sobject = Search.get_by_search_key(select) # add a backward reference sobject_snapshot = Snapshot.get_latest_by_sobject(sobject) xml = sobject_snapshot.get_xml_value("snapshot") builder = SnapshotBuilder(xml) builder.add_ref_by_snapshot(parent_snapshot) sobject_snapshot.set_value("snapshot", builder.to_string() ) sobject_snapshot.commit() # add a forward reference parent_builder.add_fref_by_snapshot(sobject_snapshot) parent_snapshot.set_value("snapshot", parent_builder.to_string() ) parent_snapshot.commit()
def postprocess(self): sobject = self.sobject texture_snapshot = Snapshot.get_latest_by_sobject(sobject) web = WebContainer.get_web() source_search_key = web.get_form_value("predefined_source") if source_search_key and texture_snapshot: source = Search.get_by_search_key(source_search_key) source_snapshot = Snapshot.get_latest_by_sobject(source) xml = texture_snapshot.get_xml_value("snapshot") builder = SnapshotBuilder(xml) builder.add_ref_by_snapshot(source_snapshot) texture_snapshot.set_value("snapshot", builder.to_string()) texture_snapshot.commit() return # if no files have been uploaded, don't do anything field_storage = web.get_form_value("add_source") if field_storage == "": return # process and get the uploaded files upload = FileUpload() upload.set_field_storage(field_storage) upload.execute() files = upload.get_files() if not files: return file_types = upload.get_file_types() asset_code = sobject.get_value("asset_code") # checkin this as a new source import os source_code = os.path.basename(files[0]) source_description = "Referred to %s" % self.sobject.get_code() source_category = "default" source = TextureSource.create(asset_code, source_code, \ source_category, source_description) # add the file as a snapshot to this source checkin = FileCheckin(source, files, file_types) checkin.execute() source_snapshot = Snapshot.get_latest_by_sobject(source) xml = source_snapshot.get_xml_value("snapshot") builder = SnapshotBuilder(xml) builder.add_fref_by_snapshot(texture_snapshot) source_snapshot.set_value("snapshot", builder.to_string()) source_snapshot.commit() # Modify the snapshot in the original texture to reference this # source. This assumes that the other uploaded snapshot has # already been dealt with. source_snapshot = checkin.get_snapshot() # FIXME: what if no texture was uploaded??? xml = texture_snapshot.get_xml_value("snapshot") builder = SnapshotBuilder(xml) builder.add_ref_by_snapshot(source_snapshot) texture_snapshot.set_value("snapshot", builder.to_string()) texture_snapshot.commit()
def postprocess(my): sobject = my.sobject texture_snapshot = Snapshot.get_latest_by_sobject(sobject) web = WebContainer.get_web() source_search_key = web.get_form_value("predefined_source") if source_search_key and texture_snapshot: source = Search.get_by_search_key(source_search_key) source_snapshot = Snapshot.get_latest_by_sobject(source) xml = texture_snapshot.get_xml_value("snapshot") builder = SnapshotBuilder(xml) builder.add_ref_by_snapshot(source_snapshot) texture_snapshot.set_value("snapshot", builder.to_string() ) texture_snapshot.commit() return # if no files have been uploaded, don't do anything field_storage = web.get_form_value("add_source") if field_storage == "": return # process and get the uploaded files upload = FileUpload() upload.set_field_storage(field_storage) upload.execute() files = upload.get_files() if not files: return file_types = upload.get_file_types() asset_code = sobject.get_value("asset_code") # checkin this as a new source import os source_code = os.path.basename(files[0]) source_description = "Referred to %s" % my.sobject.get_code() source_category = "default" source = TextureSource.create(asset_code, source_code, \ source_category, source_description) # add the file as a snapshot to this source checkin = FileCheckin(source, files, file_types ) checkin.execute() source_snapshot = Snapshot.get_latest_by_sobject(source) xml = source_snapshot.get_xml_value("snapshot") builder = SnapshotBuilder(xml) builder.add_fref_by_snapshot(texture_snapshot) source_snapshot.set_value("snapshot", builder.to_string() ) source_snapshot.commit() # Modify the snapshot in the original texture to reference this # source. This assumes that the other uploaded snapshot has # already been dealt with. source_snapshot = checkin.get_snapshot() # FIXME: what if no texture was uploaded??? xml = texture_snapshot.get_xml_value("snapshot") builder = SnapshotBuilder(xml) builder.add_ref_by_snapshot(source_snapshot) texture_snapshot.set_value("snapshot", builder.to_string() ) texture_snapshot.commit()