def get_xml_value(my): if my.sobject.has_value(my.name): return my.sobject.get_xml_value( my.name ) else: from pyasm.biz import Snapshot return Snapshot.get_latest_by_sobject(\ my.sobject).get_xml_value( my.name )
def get_message(my): search_type_obj = my.sobject.get_search_type_obj() title = search_type_obj.get_title() notification_message = my.notification.get_value("message") message = "%s %s" % (title, my.sobject.get_name()) if notification_message: message = "%s (%s)" % (message, notification_message) update_desc = my.sobject.get_update_description() parent_search_type = my.sobject.get_value('search_type') grand_parent = None if 'prod/submission' in parent_search_type: parent = Search.get_by_id(parent_search_type, my.sobject.get_value('search_id')) snapshot = Snapshot.get_latest_by_sobject(parent, 'publish') if snapshot: file_name = snapshot.get_file_name_by_type('main') update_desc = '%s \n %s \n' % (update_desc, file_name) grand_parent = parent.get_parent() if grand_parent: update_desc = '%s %s' % (update_desc, grand_parent.get_code()) command_desc = my.command.get_description() message = '%s\n\nReport from transaction:\n%s\n\n%s' \ % (message, update_desc, command_desc) return message
def get_xml_value(self): if self.sobject.has_value(self.name): return self.sobject.get_xml_value( self.name ) else: from pyasm.biz import Snapshot return Snapshot.get_latest_by_sobject(\ self.sobject).get_xml_value( self.name )
def get_xml_value(my): if my.sobject.has_value(my.name): return my.sobject.get_xml_value(my.name) else: from pyasm.biz import Snapshot return Snapshot.get_latest_by_sobject(\ my.sobject).get_xml_value( my.name )
def execute(my): search = Search(Submission) search.set_show_retired(True) submissions = search.get_sobjects() for submission in submissions: snapshot = Snapshot.get_latest_by_sobject(submission, "publish") paths = snapshot.get_all_lib_paths() bins = submission.get_bins() if not bins: print "Bin for submissin [%s] does not exist" % submission.get_id() continue bin = bins[0] code = bin.get_code() type = bin.get_value("type") label = bin.get_value("label") for path in paths: if not os.path.exists(path): print "WARNING: path '%s' does not exist" % path continue dirname = os.path.dirname(path) basename = os.path.basename(path) new_dirname = "%s/%s/%s/%s" % (dirname,type,label,code) if not os.path.exists(new_dirname): os.makedirs(new_dirname) new_path = "%s/%s" % (new_dirname, basename) print new_path FileUndo.move(path, new_path)
def execute(my): from pyasm.flash.widget import FlashLayerCheckboxWdg web = WebContainer.get_web() cam_search_key = web.get_form_value( FlashRenderTableElementWdg.RENDER_CAM) # FIXME: why is this called "context" context_name = web.get_form_value( FlashRenderTableElementWdg.CONTEXT_NAME) # submit all the selected sobjects context = "publish" for search_key in my.search_keys: sobject = Search.get_by_search_key(search_key) snapshot = Snapshot.get_latest_by_sobject(sobject, context) if not snapshot: raise TacticException("No checkins of context '%s' for '%s' exists" % (context, sobject.get_code() ) ) render = FlashGenerateExecuteXml(sobject.get_code()) render.set_snapshot_code(snapshot.get_code()) #render.execute() # store this in the appropriate queue dispatch = TacticDispatcher() dispatch.set_description("Flash Render: %s" % sobject.get_code()) dispatch.execute_slave(render) my.description = "Submitted: %s" % ", ".join(my.search_keys)
def get_message(my): search_type_obj = my.sobject.get_search_type_obj() title = search_type_obj.get_title() notification_message = my.notification.get_value("message") message = "%s %s" % (title, my.sobject.get_name()) if notification_message: message = "%s (%s)" %(message, notification_message) update_desc = my.sobject.get_update_description() parent_search_type = my.sobject.get_value('search_type') grand_parent = None if 'prod/submission' in parent_search_type: parent = Search.get_by_id(parent_search_type, my.sobject.get_value('search_id') ) snapshot = Snapshot.get_latest_by_sobject(parent, 'publish') if snapshot: file_name = snapshot.get_file_name_by_type('main') update_desc = '%s \n %s \n' %(update_desc, file_name) grand_parent = parent.get_parent() if grand_parent: update_desc = '%s %s'%(update_desc, grand_parent.get_code()) command_desc = my.command.get_description() message = '%s\n\nReport from transaction:\n%s\n\n%s' \ % (message, update_desc, command_desc) return message
def execute(my): from pyasm.flash.widget import FlashLayerCheckboxWdg web = WebContainer.get_web() cam_search_key = web.get_form_value(FlashRenderTableElementWdg.RENDER_CAM) # FIXME: why is this called "context" context_name = web.get_form_value(FlashRenderTableElementWdg.CONTEXT_NAME) # submit all the selected sobjects context = "publish" for search_key in my.search_keys: sobject = Search.get_by_search_key(search_key) snapshot = Snapshot.get_latest_by_sobject(sobject, context) if not snapshot: raise TacticException("No checkins of context '%s' for '%s' exists" % (context, sobject.get_code())) render = FlashGenerateExecuteXml(sobject.get_code()) render.set_snapshot_code(snapshot.get_code()) # render.execute() # store this in the appropriate queue dispatch = TacticDispatcher() dispatch.set_description("Flash Render: %s" % sobject.get_code()) dispatch.execute_slave(render) my.description = "Submitted: %s" % ", ".join(my.search_keys)
def get_xml_value(self): if self.sobject.has_value(self.name): return self.sobject.get_xml_value(self.name) else: from pyasm.biz import Snapshot return Snapshot.get_latest_by_sobject(\ self.sobject).get_xml_value( self.name )
def execute(my): print "EXECUTING sample command" # create the render render = SearchType.create("prod/render") render.set_parent(my.prev_command.sobject) render.set_value("pipeline_code", "turntable") render.commit() Task.add_initial_tasks(render) prev_sobject = my.prev_command.sobject prev_process = "model" this_sobject = my.prev_command.sobject this_process = "turntable" # get the deliverable snapshot = Snapshot.get_latest_by_sobject(prev_sobject, prev_process) if not snapshot: return # once we have this snapshot, open the file and process lib_dir = snapshot.get_lib_dir() file_name = snapshot.get_name_by_type("maya") file_path = "%s/%s" % (lib_dir, file_name) f = open(file_path, 'r') lines = f.readlines() f.close() tmp_dir = Environment.get_tmp_dir() new_file_name = "whatever.new" new_file_path = "%s/%s" % (tmp_dir, new_file_name) f2 = open(new_file_path, 'wb') for i, line in enumerate(lines): line = "%s - %s" % (i, line) f2.write(line) f2.close() file_paths = [new_file_path] file_types = ['maya'] from pyasm.checkin import FileCheckin checkin = FileCheckin.get(this_sobject, file_paths, file_types, context=this_process) checkin.execute() my.set_event_name("task/approved") my.set_process("preprocess") my.set_pipeline_code("turntable") my.sobjects = [render] # ??? my.sobject = render my.set_as_approved()
def execute(my): print "EXECUTING sample command" # create the render render = SearchType.create("prod/render") render.set_parent(my.prev_command.sobject) render.set_value("pipeline_code", "turntable") render.commit() Task.add_initial_tasks(render) prev_sobject = my.prev_command.sobject prev_process = "model" this_sobject = my.prev_command.sobject this_process = "turntable" # get the deliverable snapshot = Snapshot.get_latest_by_sobject(prev_sobject, prev_process) if not snapshot: return # once we have this snapshot, open the file and process lib_dir = snapshot.get_lib_dir() file_name = snapshot.get_name_by_type("maya") file_path = "%s/%s" % (lib_dir, file_name) f = open( file_path, 'r') lines = f.readlines() f.close() tmp_dir = Environment.get_tmp_dir() new_file_name = "whatever.new" new_file_path = "%s/%s" % (tmp_dir, new_file_name) f2 = open( new_file_path, 'wb') for i, line in enumerate(lines): line = "%s - %s" % ( i,line) f2.write(line) f2.close() file_paths = [new_file_path] file_types = ['maya'] from pyasm.checkin import FileCheckin checkin = FileCheckin.get(this_sobject, file_paths, file_types, context=this_process) checkin.execute() my.set_event_name("task/approved") my.set_process("preprocess") my.set_pipeline_code("turntable") my.sobjects = [render] # ??? my.sobject = render my.set_as_approved()
def _append_xml(my, asset, context, inst_mode, uber_xml ): '''append xml to the uber_xml''' snapshot = Snapshot.get_latest_by_sobject(asset, context) loader_context = ProdLoaderContext() loader_context.set_context(context) loader_context.set_option('instantiation', inst_mode) loader = loader_context.get_loader(snapshot) loader.execute() execute_xml = loader.get_execute_xml() xml = execute_xml.get_xml() xml = Xml(string=xml) nodes = xml.get_nodes("execute/*") for node in nodes: uber_xml.append( " %s" % xml.to_string(node, pretty=False))
def get_display(self): sobject = self.get_current_sobject() context = self.kwargs.get('context') if not context: context = "publish" snapshot = Snapshot.get_latest_by_sobject(sobject, context) if not snapshot: return "Nothing checked in" xml = snapshot.get_xml_value("snapshot") print xml.to_string() # this is a comp object ... need to find the shot shot = sobject.get_parent("prod/shot") # now get all of the layers layers = shot.get_all_children("prod/layer") div = DivWdg() table = Table(css='embed') # get the renders for each of the references in the snapshot #ref_nodes = xml.get_nodes("snapshot/file/ref") ref_nodes = xml.get_nodes("snapshot/input_ref") unknown_ref_nodes = xml.get_nodes("snapshot/unknown_ref") if ref_nodes: table.add_row_cell('Ref:') self.draw_node(ref_nodes, table) if unknown_ref_nodes: table.add_row_cell('Unknown Ref:') for node in unknown_ref_nodes: table.add_row() table.add_cell(xml.get_attribute(node, 'path')) div.add(table) return div
def _get_file_info(my, sobject): ''' return the web url and the file name with flash sobject''' snapshot = web_dir = None if sobject: snapshot = my.snapshot_dict.get(sobject.get_search_key()) if not snapshot: snapshot = Snapshot.get_latest_by_sobject(sobject) web_dir = sobject.get_remote_web_dir() if snapshot: fla = snapshot.get_name_by_type(".fla") fla_file_name = snapshot.get_file_name_by_type(".fla") fla_link = "%s/%s" % (web_dir, fla_file_name) return fla_link, fla else: return None, None
def _get_file_info(my, sobject, snapshot=None, file_type='main'): ''' return the web url and the file name with media sobject''' web_dir = None if not sobject: return None, None if not snapshot: key = sobject.get_search_key() # the latest snapshot snapshot = Snapshot.get_latest_by_sobject(sobject) if snapshot: fla = snapshot.get_name_by_type(file_type) fla_file_name = snapshot.get_file_name_by_type(file_type) web_dir = sobject.get_remote_web_dir() fla_link = "%s/%s" % (web_dir, fla_file_name) return fla_link, fla else: return None, None
def get_version_wdg(my, session, snapshot, node_name): if not snapshot: return "---" session_context = snapshot.get_value("context") session_version = snapshot.get_value("version") # get the latest latest = Snapshot.get_latest_by_sobject(snapshot.get_sobject(),session_context) latest_context = latest.get_value("context") latest_version = latest.get_value("version") version_wdg = LatestVersionContextWdg() data = {'session_version': session_version, \ 'session_context': session_context, \ 'latest_context': latest_context, \ 'latest_version': latest_version } version_wdg.set_options(data) return version_wdg
def get_version_wdg(self, session, snapshot, node_name): if not snapshot: return "---" session_context = snapshot.get_value("context") session_version = snapshot.get_value("version") # get the latest latest = Snapshot.get_latest_by_sobject(snapshot.get_sobject(),session_context) latest_context = latest.get_value("context") latest_version = latest.get_value("version") version_wdg = LatestVersionContextWdg() data = {'session_version': session_version, \ 'session_context': session_context, \ 'latest_context': latest_context, \ 'latest_version': latest_version } version_wdg.set_options(data) return version_wdg
def handle_set(my, table, instance_name, asset, session_instances): asset_code = asset.get_code() # get all of the reference instances from the latest published snapshot = Snapshot.get_latest_by_sobject(asset, "publish") # if there is no publish snapshot, then this is definitely not # a set, so handle it like an instance if not instance_name in session_instances: return if not snapshot: my.handle_instance(table, instance_name, asset) return xml = snapshot.get_xml_value("snapshot") # skip if none are in session set_instances = xml.get_values("snapshot/ref/@instance") # TODO should get it based on the set's asset code so that # if the sesssion's set is older, it will still work session_set_items = my.session._get_data().get_nodes_attr(\ "session/node[@set_asset_code='%s']" %asset_code, 'instance') count = 0 set_instances_in_session = [] set_instances_not_in_session = [] for set_instance in set_instances: # backwards compatible: tmp_set_instance = set_instance if set_instance.find(":") != -1: print "WARNING: snapshot '%s' has deprecated maya instance names" % snapshot.get_code() set_instance, tmp = set_instance.split(":") # make sure the set_instance comes from this set if set_instance in session_set_items: count += 1 set_instances_in_session.append(tmp_set_instance) else: set_instances_not_in_session.append(tmp_set_instance) if count == 0: return my.handle_instance(table, instance_name, asset) # display all of the set instance that are in session for set_instance in set_instances_in_session: ref_snapshot = snapshot.get_ref_snapshot("instance", set_instance) ref_asset = ref_snapshot.get_sobject() # backwards compatible if set_instance.find(":") != -1: print "WARNING: snapshot '%s' has deprecated maya instance names" % snapshot.get_code() set_instance, tmp = set_instance.split(":") my.handle_instance(table, set_instance, ref_asset, publish=False) widget = Widget(" ") if set_instances_not_in_session: widget = Widget() widget.add(IconWdg("warning", icon=IconWdg.ERROR)) widget.add("missing set items from last publish") th, td = table.add_row_cell(widget) for set_instance in set_instances_not_in_session: ref_snapshot = snapshot.get_ref_snapshot("instance", set_instance) ref_asset = ref_snapshot.get_sobject() # backwards compatible if set_instance.find(":") != -1: print "WARNING: snapshot '%s' has deprecated maya instance names" % snapshot.get_code() set_instance, tmp = set_instance.split(":") my.handle_missing_instance(table, set_instance, ref_asset) if set_instances_not_in_session: table.add_row_cell(" ")
def get_display(my): web = WebContainer.get_web() search_key = web.get_form_value("search_key") widget = Widget() sobject = Search.get_by_search_key(search_key) table = TableWdg( sobject.get_search_type(), "render" ) table.set_sobject(sobject) widget.add(table) # get all of the snapshots with a context render sobject_snapshot = Snapshot.get_latest_by_sobject(sobject,"render") if sobject_snapshot: search_type = sobject.get_search_type() search_id = sobject.get_value('search_id') render_snapshots = Snapshot.get_by_search_type(search_type,search_id,"render") table = TableWdg("sthpw/snapshot") table.set_sobjects(render_snapshots) widget.add(table) widget.add(HtmlElement.h3("Rendered Frames")) if sobject_snapshot: widget.add("Render version: v%0.3d" % sobject_snapshot.get_value("version") ) # get latest snapshot of the render renders = Render.get_all_by_sobject(sobject) if not renders: widget.add("<h4>No renders found</h4>") return widget render = renders[0] snapshot = Snapshot.get_latest_by_sobject(render,"render") if snapshot == None: widget.add("<h4>No snapshots found</h4>") return widget # get the images web_dir = snapshot.get_web_dir() lib_dir = snapshot.get_lib_dir() xml = snapshot.get_xml_value("snapshot") file_nodes = xml.get_nodes("snapshot/file") file_name = icon_file_name = '' frame_range = icon_frame_range = None for file_node in file_nodes: if Xml.get_attribute(file_node, 'type') == 'main': file_name, frame_range = my._get_frame_info(file_node, sobject) if Xml.get_attribute(file_node, 'type') == 'icon': icon_file_name, icon_frame_range = my._get_frame_info(file_node, sobject) file_names = [file_name] icon_file_names = [icon_file_name] if "##" in file_name: file_names = FileGroup.expand_paths(file_name, frame_range) if "##" in icon_file_name: icon_file_names = FileGroup.expand_paths(icon_file_name, \ icon_frame_range) div = DivWdg() for k in range(len(file_names)): file_name = file_names[k] # ignore frames that don't exist lib_path = "%s/%s" % (lib_dir, file_name) if not os.path.exists(lib_path): continue try: icon_file_name = icon_file_names[k] except IndexError: icon_file_name = file_names[k] file_path = "%s/%s" % (web_dir, file_name) icon_file_path = "%s/%s" % (web_dir, icon_file_name) img = HtmlElement.img(icon_file_path) img.set_attr("width", "60") img.add_event("onmouseover","hint_bubble.show(event,'Ctrl + Click to open in new window')") href = HtmlElement.href(img, file_path) div.add(href) widget.add(div) widget.add( "<h3>Render History</h3>" ) widget.add( my.get_render_history(renders) ) return widget
def handle_set(my, table, instance_name, asset, session_instances): asset_code = asset.get_code() # get all of the reference instances from the latest published snapshot = Snapshot.get_latest_by_sobject(asset, "publish") # if there is no publish snapshot, then this is definitely not # a set, so handle it like an instance if not instance_name in session_instances: return if not snapshot: my.handle_instance(table, instance_name, asset) return xml = snapshot.get_xml_value("snapshot") # skip if none are in session set_instances = xml.get_values("snapshot/ref/@instance") # TODO should get it based on the set's asset code so that # if the sesssion's set is older, it will still work session_set_items = my.session._get_data().get_nodes_attr(\ "session/node[@set_asset_code='%s']" %asset_code, 'instance') count = 0 set_instances_in_session = [] set_instances_not_in_session = [] for set_instance in set_instances: # backwards compatible: tmp_set_instance = set_instance if set_instance.find(":") != -1: print "WARNING: snapshot '%s' has deprecated maya instance names" % snapshot.get_code( ) set_instance, tmp = set_instance.split(":") # make sure the set_instance comes from this set if set_instance in session_set_items: count += 1 set_instances_in_session.append(tmp_set_instance) else: set_instances_not_in_session.append(tmp_set_instance) if count == 0: return my.handle_instance(table, instance_name, asset) # display all of the set instance that are in session for set_instance in set_instances_in_session: ref_snapshot = snapshot.get_ref_snapshot("instance", set_instance) ref_asset = ref_snapshot.get_sobject() # backwards compatible if set_instance.find(":") != -1: print "WARNING: snapshot '%s' has deprecated maya instance names" % snapshot.get_code( ) set_instance, tmp = set_instance.split(":") my.handle_instance(table, set_instance, ref_asset, publish=False) widget = Widget(" ") if set_instances_not_in_session: widget = Widget() widget.add(IconWdg("warning", icon=IconWdg.ERROR)) widget.add("missing set items from last publish") th, td = table.add_row_cell(widget) for set_instance in set_instances_not_in_session: ref_snapshot = snapshot.get_ref_snapshot("instance", set_instance) ref_asset = ref_snapshot.get_sobject() # backwards compatible if set_instance.find(":") != -1: print "WARNING: snapshot '%s' has deprecated maya instance names" % snapshot.get_code( ) set_instance, tmp = set_instance.split(":") my.handle_missing_instance(table, set_instance, ref_asset) if set_instances_not_in_session: table.add_row_cell(" ")
def get_display(my): my.set_option('icon', "CONTENTS") sobject = my.get_current_sobject() search_type = sobject.get_search_type() context = my.get_option("context") if not context: context = "publish" process = my.get_option("process") if not process: process = "publish" if sobject.get_base_search_type() == "sthpw/snapshot": snapshot = sobject sobject = snapshot.get_parent() search_type = sobject.get_search_type() else: if process: snapshot = Snapshot.get_latest_by_sobject(sobject, process=process) else: snapshot = Snapshot.get_latest_by_sobject(sobject, context=context) if not snapshot: top = DivWdg() return top top = DivWdg() icon = IconButtonWdg("Show Metadata", eval("IconWdg.%s" % my.get_option('icon'))) top.add(icon) lib_path = snapshot.get_lib_path_by_type("main") basename = os.path.basename(lib_path) dirname = os.path.dirname(lib_path) my.behavior['basename'] = basename my.behavior['dirname'] = dirname my.behavior['search_type'] = search_type cbjs_action = ''' var class_name = 'tactic.ui.tools.repo_browser_wdg.RepoBrowserContentWdg'; var kwargs = { basename: '%(basename)s', dirname: '%(dirname)s', search_type: '%(search_type)s' }; //spt.tab.set_main_body_tab(); //spt.tab.add_new("Detail", "Detail", class_name, kwargs); spt.panel.load_popup("Detail", class_name, kwargs); ''' % (my.behavior) my.behavior['type'] = 'click_up' my.behavior['cbjs_action'] = cbjs_action icon.add_behavior(my.behavior) return top
def get_display(my): web = WebContainer.get_web() search_type = web.get_form_value("search_type") search_ids = web.get_form_value("search_ids") #print "PicLens why am I begin run???" if not search_type or not search_ids: return "" from pyasm.search import Search search = Search(search_type) search.add_filters('id', search_ids.split("|")) search.add_enum_order_by('id', search_ids.split("|") ) sobjects = search.get_sobjects() xml = '''<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <rss version="2.0" xmlns:media="http://search.yahoo.com/mrss"> <channel> <title></title> <link></link> <description></description> ''' from pyasm.biz import Snapshot for sobject in sobjects: snapshot = Snapshot.get_latest_by_sobject(sobject, "icon") if not snapshot: snapshot = Snapshot.get_latest_by_sobject(sobject, "publish") if not snapshot: continue web = snapshot.get_name_by_type(".swf") if not web: web = snapshot.get_name_by_type("web") icon = snapshot.get_name_by_type("icon") web_dir = snapshot.get_web_dir() web_path = "%s/%s" % (web_dir, web) icon_path = "%s/%s" % (web_dir, icon) title = "%s - %s" % (sobject.get_code(), sobject.get_name() ) xml += ''' <item> <title>%s</title> <link>%s</link> <media:thumbnail url="%s" /> <media:content url="%s" type="" /> </item> ''' % (title, web_path, icon_path, web_path) xml += ''' </channel> </rss> ''' return xml
def init(self): WebContainer.register_cmd("pyasm.widget.AnnotateCbk") sobject = self.get_current_sobject() if not sobject: if not self.__dict__.has_key("search_type"): web = WebContainer.get_web() self.search_type = web.get_form_value("search_type") self.search_id = web.get_form_value("search_id") if not self.search_type: self.add("No search type") return search = Search(self.search_type) search.add_id_filter(self.search_id) sobject = search.get_sobject() snapshot = Snapshot.get_latest_by_sobject(sobject) # TODO: # this is a bit klunky snapshot_xml = snapshot.get_xml_value("snapshot") file_code = snapshot_xml.get_value( "snapshot/file[@type='web']/@file_code") file = File.get_by_code(file_code) web_dir = snapshot.get_web_dir() path = "%s/%s" % (web_dir, file.get_full_file_name()) # add the annotate js object script = HtmlElement.script("annotate = new Annotate()") self.add(script) # add the image self.add("<h3>Image Annotations</h3>") width = 600 img = HtmlElement.img(path) img.add_style("position: absolute") img.set_id("annotate_image") img.add_style("left: 0px") img.add_style("top: 0px") img.add_style("opacity: 1.0") img.add_style("z-index: 1") img.add_style("width", width) img.add_event("onmouseup", "annotate.add_new(event)") self.add(img) # test version = snapshot.get_value("version") if version != 1: last_version = version - 1 snapshot = Snapshot.get_by_version( \ self.search_type, self.search_id, version=last_version ) snapshot_xml = snapshot.get_xml_value("snapshot") file_code = snapshot_xml.get_value( "snapshot/file[@type='web']/@file_code") file = File.get_by_code(file_code) web_dir = snapshot.get_web_dir() path = "%s/%s" % (web_dir, file.get_full_file_name()) img = HtmlElement.img(path) img.set_id("annotate_image_alt") img.add_style("position: absolute") img.add_style("left: 0px") img.add_style("top: 0px") img.add_style("opacity: 1.0") img.add_style("z-index: 0") img.add_style("width", width) img.add_event("onmouseup", "annotate.add_new(event)") self.add(img) #script = HtmlElement.script("align_element('%s','%s')" % \ # ("annotate_image", "annotate_image_alt") ) #self.add(script) div = DivWdg() div.add_style("position: absolute") div.add_style("left: 620") div.add_style("top: 300") self.add(div) button = IconButtonWdg("Switch", IconWdg.REFRESH, True) button.add_event("onclick", "annotate.switch_alt()") div.add(button) button = IconButtonWdg("Opacity", IconWdg.LOAD, True) button.add_event("onclick", "annotate.set_opacity()") div.add(button) # add the new annotation div new_annotation_div = DivWdg() new_annotation_div.set_id("annotate_msg") new_annotation_div.set_class("annotate_new") new_annotation_div.add_style("top: 0") new_annotation_div.add_style("left: 0") title = DivWdg("Enter Annotation:") title.add_style("background-color: #000000") title.add_style("color: #ffffff") new_annotation_div.add(title) text = TextAreaWdg("annotate_msg") text.set_attr("cols", "30") text.set_attr("rows", "3") new_annotation_div.add(text) new_annotation_div.add("<br/>") cancel = ButtonWdg("Cancel") cancel.add_style("float: right") cancel.add_event("onclick", "toggle_display('annotate_msg')") new_annotation_div.add(cancel) submit = SubmitWdg("Add Annotation") submit.add_style("float: right") new_annotation_div.add(submit) new_annotation_div.add_style("display: none") new_annotation_div.add_style("position: absolute") self.add(new_annotation_div) # get all of the stored annotations for this image search = Search("sthpw/annotation") search.add_order_by("login") search.add_filter("file_code", file_code) annotations = search.get_sobjects() # sort by user sorted_annotations = {} for annotation in annotations: user = annotation.get_value("login") if not sorted_annotations.has_key(user): sorted_annotations[user] = [] sorted_annotations[user].append(annotation) buttons = [] for user, annotations in sorted_annotations.items(): button = IconButtonWdg(user, IconWdg.INSERT, True) button.add_event( "onclick", "annotate.show_marks('%s','%s')" % (user, len(annotations) - 1)) buttons.append(button) count = 0 for annotation in annotations: self.add(self.get_annotate_wdg(annotation, count)) count += 1 # add the user buttons table = Table() table.set_class("table") table.add_style("width: 0px") table.add_style("position: absolute") table.add_style("left: 620") table.add_style("top: 0") table.add_row() table.add_header("Annotations") for button in buttons: table.add_row() legend_wdg = DivWdg() legend_wdg.set_class("annotate_mark") legend_wdg.add_style("position: relative") legend_wdg.add(" ") table.add_cell(legend_wdg) table.add_cell(button) self.add(table) # add form elements hidden = HiddenWdg("mouse_xpos") self.add(hidden) hidden = HiddenWdg("mouse_ypos") self.add(hidden) hidden = HiddenWdg("file_code", file_code) self.add(hidden) # move the rest below self.add("<div style='height:300'> </div>")
def get_display(my): top = my.top my.set_as_panel(top) top.add_class("spt_checkin_dependency_top") top.add_color("background", "background") top.add_color("color", "color") top.add_style("width: 800px") title = DivWdg() top.add(title) title.add("Current Dependencies") title.add_color("color", "color3") title.add_color("background", "background3") title.add_style("font-size: 1.2em") title.add_style("font-weight: bold") title.add_style("padding: 10px 10px") # Not sure what to do with this yet search_key = my.kwargs.get("search_key") search_key = None snapshot_key = my.kwargs.get("snapshot_key") process = my.kwargs.get("process") if not process: process = "publish" if snapshot_key: snapshot = Search.get_by_search_key(snapshot_key) elif search_key: sobject = Search.get_by_search_key(search_key) snapshot = Snapshot.get_latest_by_sobject(sobject, process=process) else: snapshot = None #context = my.kwargs.get("context") #context = "publish/X6.tex" from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title="Browse") button.add_style("float: left") top.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var applet = spt.Applet.get(); var files = applet.open_file_browser(); alert(files); ''' } ) from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title="Clipboard") button.add_style("float: left") top.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': r''' var server = TacticServerStub.get(); var items = server.eval("@SOBJECT(sthpw/clipboard['category','select']['login',$LOGIN])") var search_keys = spt.table.get_all_search_keys(); for (var i = 0; i < items.length; i++) { var item = items[i]; var search_key = item.search_type + "&code=" + item.search_code; search_keys.push(search_key); } var top = bvr.src_el.getParent(".spt_checkin_dependency_top"); top.setAttribute("spt_snapshot_keys", search_keys.join("|")) spt.panel.refresh(top); spt.tab.set_tab_top_from_child(bvr.src_el); var content = spt.tab.get_content("Dependency"); var activator = content.activator; activator.setAttribute("spt_depend_keys", search_keys.join("|")); ''' } ) button = ActionButtonWdg(title="Remove") button.add_style("float: left") top.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkin_dependency_top"); var layout = top.getElement(".spt_layout"); spt.table.set_layout(layout); spt.table.remove_selected(); var search_keys = spt.table.get_all_search_keys(); alert(search_keys); spt.tab.set_tab_top_from_child(bvr.src_el); var content = spt.tab.get_content("Dependency"); var activator = content.activator; activator.setAttribute("spt_depend_keys", search_keys.join("|")); activator.setStyle("border", "solid 1px green"); ''' } ) """ button = ActionButtonWdg(title="Attach") button.add_style("float: left") top.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkin_dependency_top"); var layout = top.getElement(".spt_layout"); spt.table.set_layout(layout); var search_keys = spt.table.get_selected_search_keys(); ''' } ) """ top.add("<br clear='all'/>") sobject_wdg = DivWdg() top.add(sobject_wdg) #text = TextInputWdg("search_type") #sobject_wdg.add(text) depend_keys = my.kwargs.get("depend_keys") print "depend_keys: ", depend_keys if isinstance(depend_keys, basestring): depend_keys = depend_keys.split("|") if depend_keys: ref_snapshots = Search.get_by_search_keys(depend_keys) elif snapshot: # get the already existing snapshots ref_snapshots = snapshot.get_all_ref_snapshots(snapshot) else: ref_snapshots = [] snapshot_keys = my.kwargs.get("snapshot_keys") if snapshot_keys: snapshot_keys = snapshot_keys.split("|") extra_snapshots = Search.get_by_search_keys(snapshot_keys) for extra_snapshot in extra_snapshots: extra_snapshot = Snapshot.get_latest_by_sobject(extra_snapshot, process=process) if extra_snapshot: ref_snapshots.append(extra_snapshot) if not ref_snapshots: return top print "ref: ", ref_snapshots search_type = "jobs/media" search_type = "sthpw/snapshot" from tactic.ui.panel import ViewPanelWdg panel = ViewPanelWdg( search_type=search_type, show_shelf=False, ) #layout='tile', panel.set_sobjects(ref_snapshots) top.add(panel) return top
def init(my): WebContainer.register_cmd("pyasm.widget.AnnotateCbk") sobject = my.get_current_sobject() if not sobject: if not my.__dict__.has_key("search_type"): web = WebContainer.get_web() my.search_type = web.get_form_value("search_type") my.search_id = web.get_form_value("search_id") if not my.search_type: my.add("No search type") return search = Search(my.search_type) search.add_id_filter(my.search_id) sobject = search.get_sobject() snapshot = Snapshot.get_latest_by_sobject(sobject) # TODO: # this is a bit klunky snapshot_xml = snapshot.get_xml_value("snapshot") file_code = snapshot_xml.get_value("snapshot/file[@type='web']/@file_code") file = File.get_by_code(file_code) web_dir = snapshot.get_web_dir() path = "%s/%s" % (web_dir, file.get_full_file_name() ) # add the annotate js object script = HtmlElement.script("annotate = new Annotate()") my.add(script) # add the image my.add("<h3>Image Annotations</h3>") width = 600 img = HtmlElement.img(path) img.add_style("position: absolute") img.set_id("annotate_image") img.add_style("left: 0px") img.add_style("top: 0px") img.add_style("opacity: 1.0") img.add_style("z-index: 1") img.add_style("width", width) img.add_event("onmouseup", "annotate.add_new(event)") my.add(img) # test version = snapshot.get_value("version") if version != 1: last_version = version - 1 snapshot = Snapshot.get_by_version( \ my.search_type, my.search_id, version=last_version ) snapshot_xml = snapshot.get_xml_value("snapshot") file_code = snapshot_xml.get_value("snapshot/file[@type='web']/@file_code") file = File.get_by_code(file_code) web_dir = snapshot.get_web_dir() path = "%s/%s" % (web_dir, file.get_full_file_name() ) img = HtmlElement.img(path) img.set_id("annotate_image_alt") img.add_style("position: absolute") img.add_style("left: 0px") img.add_style("top: 0px") img.add_style("opacity: 1.0") img.add_style("z-index: 0") img.add_style("width", width) img.add_event("onmouseup", "annotate.add_new(event)") my.add(img) #script = HtmlElement.script("align_element('%s','%s')" % \ # ("annotate_image", "annotate_image_alt") ) #my.add(script) div = DivWdg() div.add_style("position: absolute") div.add_style("left: 620") div.add_style("top: 300") my.add(div) button = IconButtonWdg("Switch", IconWdg.REFRESH, True) button.add_event("onclick", "annotate.switch_alt()") div.add(button) button = IconButtonWdg("Opacity", IconWdg.LOAD, True) button.add_event("onclick", "annotate.set_opacity()") div.add(button) # add the new annotation div new_annotation_div = DivWdg() new_annotation_div.set_id("annotate_msg") new_annotation_div.set_class("annotate_new") new_annotation_div.add_style("top: 0") new_annotation_div.add_style("left: 0") title = DivWdg("Enter Annotation:") title.add_style("background-color: #000000") title.add_style("color: #ffffff") new_annotation_div.add(title) text = TextAreaWdg("annotate_msg") text.set_attr("cols", "30") text.set_attr("rows", "3") new_annotation_div.add(text) new_annotation_div.add("<br/>") cancel = ButtonWdg("Cancel") cancel.add_style("float: right") cancel.add_event("onclick", "toggle_display('annotate_msg')") new_annotation_div.add( cancel ) submit = SubmitWdg("Add Annotation") submit.add_style("float: right") new_annotation_div.add( submit ) new_annotation_div.add_style("display: none") new_annotation_div.add_style("position: absolute") my.add(new_annotation_div) # get all of the stored annotations for this image search = Search("sthpw/annotation") search.add_order_by("login") search.add_filter("file_code", file_code) annotations = search.get_sobjects() # sort by user sorted_annotations = {} for annotation in annotations: user = annotation.get_value("login") if not sorted_annotations.has_key(user): sorted_annotations[user] = [] sorted_annotations[user].append(annotation) buttons = [] for user, annotations in sorted_annotations.items(): button = IconButtonWdg(user, IconWdg.INSERT, True) button.add_event("onclick", "annotate.show_marks('%s','%s')" % (user, len(annotations)-1) ) buttons.append(button) count = 0 for annotation in annotations: my.add( my.get_annotate_wdg(annotation,count) ) count += 1 # add the user buttons table = Table() table.set_class("table") table.add_style("width: 0px") table.add_style("position: absolute") table.add_style("left: 620") table.add_style("top: 0") table.add_row() table.add_header("Annotations") for button in buttons: table.add_row() legend_wdg = DivWdg() legend_wdg.set_class("annotate_mark") legend_wdg.add_style("position: relative") legend_wdg.add(" ") table.add_cell(legend_wdg) table.add_cell(button) my.add(table) # add form elements hidden = HiddenWdg("mouse_xpos") my.add(hidden) hidden = HiddenWdg("mouse_ypos") my.add(hidden) hidden = HiddenWdg("file_code", file_code) my.add(hidden) # move the rest below my.add("<div style='height:300'> </div>")
def execute(self): web = WebContainer.get_web() search_keys = [] # discovery phase to find the sobject to be rendered. This can be # either a snapshots or sobjects. If it is an sobject, then # the latest snapshot will be rendered search_type = web.get_form_value("parent_search_type") search_id = web.get_form_value("parent_search_id") if search_type: search_keys = ["%s|%s" % (search_type, search_id)] if not search_keys: if self.sobject: search_keys = [self.sobject.get_search_key()] else: search_keys = web.get_form_values("search_key") # get the policy policy = None if self.sobject: policy_code = self.sobject.get_value("policy_code") if policy_code: policy = RenderPolicy.get_by_code(policy_code) # render options options = {} keys = web.get_form_keys() for key in keys: if key.startswith("edit|"): value = web.get_form_value(key) new_key = key.replace("edit|", "") options[new_key] = value # add the xmlrpc server to the package: # WARNING: not that there is no / separating the 2 %s. client_api_url = web.get_client_api_url() options['client_api_url'] = client_api_url # go through each of the search keys found from the interface for search_key in search_keys: # find the sobject associates with this key if not search_key: continue sobject = Search.get_by_search_key(search_key) if not sobject: raise TacticException("Search Key [%s] does not exist" % search_key) # if the search_keys represented a snapshot, then use this as # the snapshot and find the parent if sobject.get_base_search_type() == "sthpw/snapshot": snapshot = sobject sobject = sobject.get_sobject() else: # else use the latest, assuming a context (really doesn't # make much sense????!!!??? # FIXME: will deal with this later context = "publish" snapshot = Snapshot.get_latest_by_sobject(sobject, context) if not snapshot: raise TacticException("No checkins of context '%s' exist for '%s'. Please look at the chekin history" % (context, sobject.get_code()) ) # We provide a render package with a bunch of necessary information render_package = RenderPackage() render_package.set_policy(policy) render_package.set_snapshot(snapshot) render_package.set_sobject(sobject) render_package.set_options(options) # submission class submit_class = self.get_option("submit") if not submit_class: submit_class = Config.get_value("services", "render_submit_class", no_exception=True) if not submit_class: submit_class = "pyasm.prod.render.RenderSubmit" # now we have an sobject and a snapshot, we initiate a job submit = Common.create_from_class_path(submit_class, [render_package]) # if this is from the EditWdg for queues then use this queue # entry instead if self.sobject.get_base_search_type() == "sthpw/queue": submit.set_queue(self.sobject) submit.execute() self.description = "Submitted: %s" % ", ".join(search_keys)
def get_display(my): web = WebContainer.get_web() search_key = web.get_form_value("search_key") widget = Widget() sobject = Search.get_by_search_key(search_key) # get all of the snapshots with a context render sobject_snapshot = Snapshot.get_latest_by_sobject(sobject, "backplate") widget.add(HtmlElement.h3("BackPlate Frames")) if not sobject_snapshot: widget.add("No backplates checked in") return widget # get the images web_dir = sobject_snapshot.get_web_dir() xml = sobject_snapshot.get_xml_value("snapshot") file_nodes = xml.get_nodes("snapshot/file") file_name = icon_file_name = '' frame_range = icon_frame_range = None for file_node in file_nodes: if Xml.get_attribute(file_node, 'type') == 'main': file_name, frame_range = my._get_frame_info(file_node, sobject) if Xml.get_attribute(file_node, 'type') == 'icon': icon_file_name, icon_frame_range = my._get_frame_info( file_node, sobject) file_names = [file_name] icon_file_names = [icon_file_name] if "##" in file_name: file_names = FileGroup.expand_paths(file_name, frame_range) if "##" in icon_file_name: icon_file_names = FileGroup.expand_paths(icon_file_name, \ icon_frame_range) div = DivWdg() for k in range(len(file_names)): file_name = file_names[k] try: icon_file_name = icon_file_names[k] except IndexError: icon_file_name = file_names[k] file_path = "%s/%s" % (web_dir, file_name) icon_file_path = "%s/%s" % (web_dir, icon_file_name) img = HtmlElement.img(icon_file_path) img.add_event( "onmouseover", "hint_bubble.show(event,'Ctrl + Click to open in new window')") href = HtmlElement.href(img, file_path) div.add("%0.4d" % (k + 1)) div.add(href) if k != 0 and (k + 1) % 4 == 0: div.add("<br/>") div.add("<br/>") widget.add(div) return widget
def get_display(my): my.set_option('icon', "CONTENTS") sobject = my.get_current_sobject() search_type = sobject.get_search_type() context = my.get_option("context") if not context: context = "publish" process = my.get_option("process") if not process: process = "publish" if sobject.get_base_search_type() == "sthpw/snapshot": snapshot = sobject sobject = snapshot.get_parent() if sobject: search_type = sobject.get_search_type() else: top = DivWdg() return top else: if process: snapshot = Snapshot.get_latest_by_sobject(sobject, process=process) else: snapshot = Snapshot.get_latest_by_sobject(sobject, context=context) if not snapshot: top = DivWdg() return top top = DivWdg() icon = IconButtonWdg( "Show Metadata", eval( "IconWdg.%s" % my.get_option('icon') ) ) top.add(icon) top.add_style("text-align: center") lib_path = snapshot.get_lib_path_by_type("main") basename = os.path.basename(lib_path) dirname = os.path.dirname(lib_path) my.behavior['basename'] = basename my.behavior['dirname'] = dirname my.behavior['search_type'] = search_type cbjs_action = ''' var class_name = 'tactic.ui.tools.repo_browser_wdg.RepoBrowserContentWdg'; var kwargs = { basename: '%(basename)s', dirname: '%(dirname)s', search_type: '%(search_type)s' }; //spt.tab.set_main_body_tab(); //spt.tab.add_new("Detail", "Detail", class_name, kwargs); spt.panel.load_popup("Detail", class_name, kwargs); ''' % (my.behavior) my.behavior['type'] = 'click_up' my.behavior['cbjs_action'] = cbjs_action icon.add_behavior(my.behavior) return top
def get_display(my): top = my.top my.set_as_panel(top) top.add_class("spt_checkout_top") top.add_color("background", "background") top.add_style("width: 800px") inner = DivWdg() top.add(inner) snapshot_codes = my.kwargs.get("snapshot_codes") search_keys = my.kwargs.get("search_keys") if snapshot_codes: if isinstance(snapshot_codes, basestring): snapshots_codes = eval(snapshot_codes) search = Search("sthpw/snapshot") search.add_filters("code", snapshot_codes) snapshots = search.get_sobjects() elif search_keys: if isinstance(search_keys, basestring): search_keys = eval(search_keys) sobjects = Search.get_by_search_keys(search_keys) snapshots = [] for sobject in sobjects: snapshot = Snapshot.get_latest_by_sobject(sobject, process="publish") if snapshot: snapshots.append(snapshot) snapshot_codes = [] for snapshot in snapshots: snapshot_codes.append( snapshot.get("code") ) if not snapshot_codes: no_snapshots_div = DivWdg() no_snapshots_div.add("No files in selection") inner.add(no_snapshots_div) return top sandbox_dir = Environment.get_sandbox_dir("default") project_code = Project.get_project_code() sandbox_dir = "%s/%s" % (sandbox_dir, project_code) base_dir = my.kwargs.get("base_dir") if base_dir: title_div = DivWdg() inner.add(title_div) title_div.add_color("background", "background3") title_div.add_color("color", "color3") title_div.add_style("padding", "15px") title_div.add_style("font-weight: bold") title_div.add("Path: %s" % base_dir) inner.add("Check-out to: %s" % sandbox_dir) button_div = ButtonRowWdg() inner.add(button_div) button = ButtonNewWdg(title="Refresh", icon=IconWdg.REFRESH) button_div.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkout_top"); spt.panel.refresh(top) ''' } ) web = WebContainer.get_web() if web.use_applet(): button = ButtonNewWdg(title="Check-out", icon=IconWdg.CHECK_OUT) button_div.add(button) button.add_behavior( { 'type': 'click_up', 'snapshot_codes': snapshot_codes, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkout_top"); var progress = top.getElement(".spt_checkout_progress"); var message = top.getElement(".spt_checkout_message"); var snapshot_codes = bvr.snapshot_codes; var num_snapshots = snapshot_codes.length; var server = TacticServerStub.get(); for (var i = 0; i < snapshot_codes.length; i++) { var snapshot_code = snapshot_codes[i]; var percent = parseInt( (i+1) / (num_snapshots-1) * 100); var desc = "Checking out: "+(i+1)+" of "+num_snapshots+": "+snapshot_code; progress.setStyle("width", percent + "%"); message.innerHTML = desc; server.checkout_snapshot(snapshot_code, null, {file_types: ['main'], filename_mode: 'source'}); } progress.setStyle("width", "100%"); progress.setStyle("background", "#0F0"); message.innerHTML = "" ''' } ) button = ButtonNewWdg(title="Sandbox", icon=IconWdg.FOLDER_GO) button_div.add(button) button.add_behavior( { 'type': 'click_up', 'sandbox_dir': sandbox_dir, 'cbjs_action': ''' var applet = spt.Applet.get(); applet.open_explorer(bvr.sandbox_dir); ''' } ) msg_div = DivWdg() inner.add(msg_div) msg_div.add_class("spt_checkout_message") msg_div.add(" ") progress_div = DivWdg() inner.add(progress_div) progress_div.add_style("width: auto") progress_div.add_style("height: 15px") progress_div.add_style("margin: 0px 10px 10px 10px") progress_div.add_border() progress = DivWdg() progress.add_class("spt_checkout_progress") progress_div.add(progress) progress.add_style("background", "#F00") progress.add_style("width", "0%") progress.add(" ") snapshot_div = DivWdg() inner.add(snapshot_div) layout = ViewPanelWdg( search_type="sthpw/snapshot", show_shelf=False, edit=False, width="100%", element_names=['preview','file','context','version','timestamp','description'], ) snapshot_div.add(layout) layout.set_sobjects(snapshots[:50]) if my.kwargs.get("is_refresh") == 'true': return inner else: return top
def init(my): search_type = "prod/shot" widget = Widget() search = Search(search_type) div = DivWdg(css="filter_box") filter = SequenceFilterWdg() div.add(filter) #context_filter = ContextFilterWdg(label="Context: ", search_type=) #context_filter.set_search_type(search_type) #div.add(context_filter) context_wdg = TextWdg("context") context_wdg.set_persistence() span = SpanWdg(css="med") span.add("Context: ") span.add(context_wdg) div.add(span) my.context = context_wdg.get_value() if not my.context: my.context = None mode = "latest" filter.alter_search(search) sobjects = search.get_sobjects() widget.add(div) table = Table(css="table") table.add_style("width: 100%") for sobject in sobjects: table.add_row() thumb = ThumbWdg() thumb.set_sobject(sobject) table.add_cell(thumb) table.add_cell( sobject.get_code() ) td = table.add_cell( WikiUtil().convert(sobject.get_value("description") )) td.add_style("width: 300px") if mode == "latest": snapshot = Snapshot.get_latest_by_sobject(sobject, my.context) else: snapshot = Snapshot.get_current_by_sobject(sobject, my.context) if not snapshot: table.add_cell("<i>No snapshot found</i>") continue dependency = DependencyWdg() dependency.set_show_title(False) dependency.set_sobject(snapshot) table.add_cell(dependency) widget.add(table) my.add(widget)
class FlashLayerRenderCmd(Command): FLASH_LAYER_TYPE = '.fla' def __init__(my): super(FlashLayerRenderCmd, my).__init__() my.sobject = None def set_project(my, project): my.project = project def set_search_keys(my, search_keys): my.search_keys = search_keys def set_cam_search_key(my, search_key): my.cam_search_key = search_key def set_context_name(my, context_name): my.render_context_name = context_name def set_render_context(my, context): my.render_context = context def get_title(my): return "Flash Layer Render" def execute(my): SearchType.set_project(my.project) # multiple layers can get rendered for search_key in my.search_keys: f = file('%s/temp/render_exec.jsfl' % Environment.get_tmp_dir(), 'w') render_command = my.get_render_command(search_key, my.cam_search_key) f.write(render_command) f.write(my.get_render_log_command()) f.close() os.startfile("\"%s\"" % f.name) my.remove_file(my.get_render_log_path()) # check if the render is done sys.stdout.write("\nRendering") while not os.path.isfile(my.get_render_log_path()): sys.stdout.write('. ') time.sleep(2) print f = file(my.get_render_log_path(), 'a') now = time.localtime(time.time()) f.write(' at %s' % time.asctime(now)) f.close() #my.convert_images() print("Checking in Render. . .") my.checkin_render() def get_render_log_command(my): '''generate render log, mainly to signal a layer render is finished''' render_dir = my.render_context.get_render_dir() render_log = my.render_context.get_render_log() function = 'write_render_log' server = Config.get_value("install", "install_dir") jsfl_path = 'file:///%s/src/context/JSFL/load.jsfl' % server cmd = "fl.runScript( '%s', '%s', '%s', '%s')\n" \ % (jsfl_path, function, render_dir, render_log) return cmd def get_render_command(my, search_key, cam_search_key): '''render in a separate process''' '''NOTE: Highly specific to Flash render''' fla_clone_path, fla_sobj, fla_snap = my._get_layer_info(search_key) cam_clone_path, cam_sobj, cam_snap = my._get_layer_info(cam_search_key) cam_layer_name = '' if cam_sobj: cam_layer_name = cam_sobj.get_value('name') #search_type, search_id = search_key.split('|') #fla_snap = Snapshot.get_latest(search_type, search_id) function = 'render_layer' render_context = eval('%s(fla_sobj)' % my.render_context_name) render_context.set_snapshot(fla_snap) my.set_render_context(render_context) # directories will get auto-created before rendering render_dir = my.render_context.get_render_dir() file_format = my.render_context.get_file_format() server = Config.get_value("install", "install_dir") # TODO: Merge this back in to work with layer concept. #jsfl_path = 'file:///%s/src/context/JSFL/load.jsfl' % server #preprocess_jsfl_path = 'file:///%s/src/context/JSFL/preprocess.jsfl' % server #cmd = "fl.runScript( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')\n" \ # % (jsfl_path, function, preprocess_jsfl_path, fla_clone_path, \ # fla_sobj.get_value('name'),\ # cam_clone_path, cam_layer_name, render_dir, file_format) jsfl_path = 'file:///%s/src/context/JSFL/load2.jsfl' % server cmd = "fl.runScript( '%s', '%s', '%s', '%s', '%s')\n" \ % (jsfl_path, "load_asset", fla_clone_path, "", fla_sobj.get_name() ) jsfl_path = 'file:///%s/src/context/JSFL/render.jsfl' % server cmd += "fl.runScript( '%s', '%s', '%s', '%s', '%s')\n" \ % (jsfl_path, "render_layer", fla_sobj.get_name(), file_format, render_dir ) return cmd def _get_layer_info(my, search_key): ''' clone the source and return the clone path and layer name ''' try: search_type, search_id = search_key.split('|') except Exception, e: print "WARNING: invalid or empty search key. ", e return None, None, None fla_sobj = Search.get_by_search_key(search_key) fla_snap = Snapshot.get_latest(search_type, search_id) if not fla_snap: parent = fla_sobj.get_parent("prod/shot") fla_snap = Snapshot.get_latest_by_sobject(parent) if not fla_snap: raise CommandException("Nothing to render for %s" % search_key) fla_path = fla_snap.get_lib_path_by_type(my.FLASH_LAYER_TYPE) fla_dir, fla_basename = os.path.split(fla_path) fla_clone_path = '%s/download/%s' %(\ Environment.get_tmp_dir(), fla_basename) shutil.copy2(fla_path, fla_clone_path) return fla_clone_path, fla_sobj, fla_snap
def get_display(my): my.doc_mode = my.kwargs.get("doc_mode") path = my.kwargs.get("path") my.search_type = my.kwargs.get("search_type") my.last_path = None doc_key = my.kwargs.get("doc_key") if doc_key: my.doc = Search.get_by_search_key(doc_key) snapshot = Snapshot.get_latest_by_sobject(my.doc) if snapshot: my.last_path = snapshot.get_lib_path_by_type('main') path = my.doc.get_value("link") # TEST TEST TEST if not path: #path = "/home/apache/pdf/mongodb.txt" #path = "/home/apache/assets/google_docs.html" #path = "/home/apache/pdf/star_wars.txt" path = "https://docs.google.com/document/d/1AC_YR8X8wbKsshkJ1h8EjZuFIr41guvqXq3_PXgaqJ0/pub?embedded=true" path = "https://docs.google.com/document/d/1WPUmXYoSkR2cz0NcyM2vqQYO6OGZW8BAiDL31YEj--M/pub" #path = "https://docs.google.com/spreadsheet/pub?key=0Al0xl-XktnaNdExraEE4QkxVQXhaOFh1SHIxZmZMQ0E&single=true&gid=0&output=html" path = "/home/apache/tactic/doc/alias.json" if not my.search_type: my.search_type = "test3/shot" my.column = "description" top = my.top top.add_class("spt_document_top") my.set_as_panel(top) #table = Table() table = ResizableTableWdg() top.add(table) table.add_row() table.set_max_width() left_td = table.add_cell() left_td.add_style("vertical-align: top") title = DivWdg() left_td.add(title) title.add_style("padding: 10px") title.add_color("background", "background3") button = IconButtonWdg(title="Refresh", icon=IconWdg.REFRESH) title.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.app_busy.show("Reloading Document"); var top = bvr.src_el.getParent(".spt_document_top"); spt.panel.refresh(top); spt.app_busy.hide(); ''' }) button.add_style("float: left") button = IconButtonWdg(title="Save", icon=IconWdg.SAVE) title.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' ''' }) button.add_style("float: left") if not my.doc_mode: my.doc_mode = "text" select = SelectWdg("doc_mode") select.set_option("values", "text|formatted") title.add(select) select.set_value(my.doc_mode) select.add_behavior({ 'type': 'change', 'cbjs_action': ''' spt.app_busy.show("Reloading Document"); var top = bvr.src_el.getParent(".spt_document_top"); var value = bvr.src_el.value; top.setAttribute("spt_doc_mode", value); spt.panel.refresh(top); spt.app_busy.hide(); ''' }) title.add("<br clear='all'/>") #title.add(path) text_wdg = DivWdg() text_wdg.add_class("spt_document_content") left_td.add(text_wdg) #if path.startswith("https://docs.google.com/spreadsheet"): # #path = "http://www.southpawtech.com.com" # text_wdg.add(''' # <iframe class="spt_document_iframe" style="width: 100%%; height: auto; min-height: 600px; font-size: 1.0em" src="%s"></iframe> # ''' % path) # text_wdg.add_style("overflow-x: hidden") if True: if not my.last_path and my.doc: tmp_dir = Environment.get_tmp_dir() tmp_path = '%s/last_path.txt' % tmp_dir f = open(tmp_path, 'w') text = my.get_text(path, highlight=False) f.write(text) f.close() cmd = FileCheckin(my.doc, tmp_path) Command.execute_cmd(cmd) else: save = False if save: # open up the last path f = open(my.last_path, 'r') last_text = f.read() text = my.get_text(path, None, highlight=False) if last_text != text: tmp_dir = Environment.get_tmp_dir() tmp_path = '%s/last_path.txt' % tmp_dir f = open(tmp_path, 'w') f.write(text) f.write(text) f.close() cmd = FileCheckin(my.doc, tmp_path) Command.execute_cmd(cmd) text = my.get_text(path, my.last_path) lines = text.split("\n") if my.doc_mode == "text": num_lines = len(lines) """ line_div = HtmlElement.pre() text_wdg.add(line_div) line_div.add_style("width: 20px") line_div.add_style("float: left") line_div.add_style("text-align: right") line_div.add_style("opacity: 0.3") line_div.add_style("padding-right: 10px") for i in range(0, num_lines*2): line_div.add(i+1) line_div.add("<br/>") """ if my.doc_mode == "text": pre = HtmlElement.pre() pre.add_style("white-space: pre-wrap") else: pre = DivWdg() pre = DivWdg() text_wdg.add(pre) text_wdg.add_style("padding: 10px 5px") text_wdg.add_style("max-height: 600px") text_wdg.add_style("overflow-y: auto") text_wdg.add_style("width: 600px") text_wdg.add_class("spt_resizable") pre.add_style("font-family: courier") if my.doc_mode == "formatted": pre.add(text) else: line_table = Table() pre.add(line_table) line_table.add_style("width: 100%") count = 1 for line in lines: #line = line.replace(" ", " ") tr = line_table.add_row() if count % 2 == 0: tr.add_color("background", "background", -2) td = line_table.add_cell() # FIXME: hacky if line.startswith('''<span style='background: #CFC'>'''): is_new = True else: td.add_style("vertical-align: top") text = TextWdg() text.add_style("border", "none") text.add_style("text-align", "right") text.add_style("width", "25px") text.add_style("margin", "0 10 0 0") text.add_style("opacity", "0.5") text.set_value(count) td.add(text) count += 1 is_new = False td = line_table.add_cell() if not is_new: SmartMenu.assign_as_local_activator(td, 'TEXT_CTX') tr.add_class("spt_line") else: SmartMenu.assign_as_local_activator(td, 'TEXT_NEW_CTX') tr.add_class("spt_new_line") td.add_class("spt_line_content") td.add(line) #from tactic.ui.app import AceEditorWdg #editor = AceEditorWdg(code=text, show_options=False, readonly=True, height="600px") #text_wdg.add(editor) # add a click on spt_item text_wdg.add_relay_behavior({ 'type': 'mouseup', 'bvr_match_class': 'spt_document_item', 'search_type': my.search_type, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_document_top"); var data_el = top.getElement(".spt_document_data"); var search_key = bvr.src_el.getAttribute("spt_search_key"); var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': bvr.search_type, 'search_key': search_key, } spt.panel.load(data_el, class_name, kwargs); ''' }) # add a double click on spt_item bgcolor = text_wdg.get_color("background", -10) text_wdg.add_relay_behavior({ 'type': 'mouseover', 'bvr_match_class': 'spt_document_item', 'search_type': my.search_type, 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("opacity", "1.0"); //bvr.src_el.setStyle("font-weight", "normal"); bvr.src_el.setStyle("background", bvr.bgcolor); ''' }) # add a double click on spt_item text_wdg.add_relay_behavior({ 'type': 'mouseout', 'bvr_match_class': 'spt_document_item', 'search_type': my.search_type, 'cbjs_action': ''' bvr.src_el.setStyle("opacity", "1.0"); //bvr.src_el.setStyle("font-weight", "bold"); bvr.src_el.setStyle("background", ""); ''' }) # add a context menu ctx_menu = my.get_text_context_menu() ctx_new_menu = my.get_text_new_context_menu() menus_in = { 'TEXT_CTX': ctx_menu, 'TEXT_NEW_CTX': ctx_new_menu, } SmartMenu.attach_smart_context_menu(text_wdg, menus_in, False) panel = ViewPanelWdg(search_type=my.search_type, layout="blah") right_td = table.add_cell() right_td.add_style("vertical-align: top") panel_div = DivWdg() panel_div.add_class("spt_document_data") right_td.add(panel_div) panel_div.add(panel) text_wdg.add_behavior({ 'type': 'load', 'cbjs_action': r''' spt.document = {}; spt.document.selected_text = null; spt.document.get_selected_text = function(frame) { var t = ''; if (frame) { var rng = frame.contentWindow.getSelection().getRangeAt(0); spt.document.expandtoword(rng); t = rng.toString(); } else if (window.getSelection) // FF4 with one tab open? { var rng = window.getSelection().getRangeAt(0); spt.document.expandtoword(rng); t = rng.toString(); } else if (document.getSelection) // FF4 with multiple tabs open? { var rng = document.getSelection().getRangeAt(0); spt.document.expandtoword(rng); t = rng.toString(); } else if (document.selection) // IE8 { var rng = document.selection.createRange(); // expand range to enclose any word partially enclosed in it rng.expand("word"); t = rng.text; } // convert newline chars to spaces, collapse whitespace, and trim non-word chars return t.replace(/^\W+|\W+$/g, ''); //return t.replace(/\r?\n/g, " ").replace(/\s+/g, " ").replace(/^\W+|\W+$/g, ''); } // expand FF range to enclose any word partially enclosed in it spt.document.expandtoword = function(range) { if (range.collapsed) { return; } while (range.startOffset > 0 && range.toString()[0].match(/\w/)) { range.setStart(range.startContainer, range.startOffset - 1); } while (range.endOffset < range.endContainer.length && range.toString()[range.toString().length - 1].match(/\w/)) { range.setEnd(range.endContainer, range.endOffset + 1); } } ''' }) top.add_relay_behavior({ 'type': 'mouseup', 'bvr_match_class': 'spt_document_content', 'cbjs_action': r''' //spt.ace_editor.set_editor_top(bvr.src_el); //var text = spt.ace_editor.get_selection(); var text = spt.document.get_selected_text(); text = text.replace(/\n\n/mg, "\n"); text = text.replace(/\n\n/mg, "\n"); spt.document.selected_text = text + ""; ''' }) return top
def get_display(self): top = self.top self.set_as_panel(top) top.add_class("spt_checkin_dependency_top") top.add_color("background", "background") top.add_color("color", "color") top.add_style("width: 800px") title = DivWdg() top.add(title) title.add("Current Dependencies") title.add_color("color", "color3") title.add_color("background", "background3") title.add_style("font-size: 1.2em") title.add_style("font-weight: bold") title.add_style("padding: 10px 10px") # Not sure what to do with this yet search_key = self.kwargs.get("search_key") search_key = None snapshot_key = self.kwargs.get("snapshot_key") process = self.kwargs.get("process") if not process: process = "publish" if snapshot_key: snapshot = Search.get_by_search_key(snapshot_key) elif search_key: sobject = Search.get_by_search_key(search_key) snapshot = Snapshot.get_latest_by_sobject(sobject, process=process) else: snapshot = None #context = self.kwargs.get("context") #context = "publish/X6.tex" from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title="Browse") button.add_style("float: left") top.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var applet = spt.Applet.get(); var files = applet.open_file_browser(); alert(files); ''' }) from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title="Clipboard") button.add_style("float: left") top.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': r''' var server = TacticServerStub.get(); var items = server.eval("@SOBJECT(sthpw/clipboard['category','select']['login',$LOGIN])") var search_keys = spt.table.get_all_search_keys(); for (var i = 0; i < items.length; i++) { var item = items[i]; var search_key = item.search_type + "&code=" + item.search_code; search_keys.push(search_key); } var top = bvr.src_el.getParent(".spt_checkin_dependency_top"); top.setAttribute("spt_snapshot_keys", search_keys.join("|")) spt.panel.refresh(top); spt.tab.set_tab_top_from_child(bvr.src_el); var content = spt.tab.get_content("Dependency"); var activator = content.activator; activator.setAttribute("spt_depend_keys", search_keys.join("|")); ''' }) button = ActionButtonWdg(title="Remove") button.add_style("float: left") top.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkin_dependency_top"); var layout = top.getElement(".spt_layout"); spt.table.set_layout(layout); spt.table.remove_selected(); var search_keys = spt.table.get_all_search_keys(); alert(search_keys); spt.tab.set_tab_top_from_child(bvr.src_el); var content = spt.tab.get_content("Dependency"); var activator = content.activator; activator.setAttribute("spt_depend_keys", search_keys.join("|")); activator.setStyle("border", "solid 1px green"); ''' }) """ button = ActionButtonWdg(title="Attach") button.add_style("float: left") top.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkin_dependency_top"); var layout = top.getElement(".spt_layout"); spt.table.set_layout(layout); var search_keys = spt.table.get_selected_search_keys(); ''' } ) """ top.add("<br clear='all'/>") sobject_wdg = DivWdg() top.add(sobject_wdg) #text = TextInputWdg("search_type") #sobject_wdg.add(text) depend_keys = self.kwargs.get("depend_keys") if isinstance(depend_keys, basestring): depend_keys = depend_keys.split("|") if depend_keys: ref_snapshots = Search.get_by_search_keys(depend_keys) elif snapshot: # get the already existing snapshots ref_snapshots = snapshot.get_all_ref_snapshots(snapshot) else: ref_snapshots = [] snapshot_keys = self.kwargs.get("snapshot_keys") if snapshot_keys: snapshot_keys = snapshot_keys.split("|") extra_snapshots = Search.get_by_search_keys(snapshot_keys) for extra_snapshot in extra_snapshots: extra_snapshot = Snapshot.get_latest_by_sobject( extra_snapshot, process=process) if extra_snapshot: ref_snapshots.append(extra_snapshot) if not ref_snapshots: return top #print "ref: ", ref_snapshots search_type = "jobs/media" search_type = "sthpw/snapshot" from tactic.ui.panel import ViewPanelWdg panel = ViewPanelWdg( search_type=search_type, show_shelf=False, ) #layout='tile', panel.set_sobjects(ref_snapshots) top.add(panel) return top
def get_display(my): top = my.top my.set_as_panel(top) top.add_class("spt_checkout_top") top.add_color("background", "background") top.add_style("width: 800px") inner = DivWdg() top.add(inner) snapshot_codes = my.kwargs.get("snapshot_codes") search_keys = my.kwargs.get("search_keys") if snapshot_codes: if isinstance(snapshot_codes, basestring): snapshots_codes = eval(snapshot_codes) search = Search("sthpw/snapshot") search.add_filters("code", snapshot_codes) snapshots = search.get_sobjects() elif search_keys: if isinstance(search_keys, basestring): search_keys = eval(search_keys) sobjects = Search.get_by_search_keys(search_keys) snapshots = [] for sobject in sobjects: snapshot = Snapshot.get_latest_by_sobject(sobject, process="publish") if snapshot: snapshots.append(snapshot) snapshot_codes = [] for snapshot in snapshots: snapshot_codes.append(snapshot.get("code")) if not snapshot_codes: no_snapshots_div = DivWdg() no_snapshots_div.add("No files in selection") inner.add(no_snapshots_div) return top sandbox_dir = Environment.get_sandbox_dir("default") project_code = Project.get_project_code() sandbox_dir = "%s/%s" % (sandbox_dir, project_code) base_dir = my.kwargs.get("base_dir") if base_dir: title_div = DivWdg() inner.add(title_div) title_div.add_color("background", "background3") title_div.add_color("color", "color3") title_div.add_style("padding", "15px") title_div.add_style("font-weight: bold") title_div.add("Path: %s" % base_dir) inner.add("Check-out to: %s" % sandbox_dir) button_div = ButtonRowWdg() inner.add(button_div) button = ButtonNewWdg(title="Refresh", icon=IconWdg.REFRESH) button_div.add(button) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkout_top"); spt.panel.refresh(top) ''' }) web = WebContainer.get_web() if web.use_applet(): button = ButtonNewWdg(title="Check-out", icon=IconWdg.CHECK_OUT) button_div.add(button) button.add_behavior({ 'type': 'click_up', 'snapshot_codes': snapshot_codes, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_checkout_top"); var progress = top.getElement(".spt_checkout_progress"); var message = top.getElement(".spt_checkout_message"); var snapshot_codes = bvr.snapshot_codes; var num_snapshots = snapshot_codes.length; var server = TacticServerStub.get(); for (var i = 0; i < snapshot_codes.length; i++) { var snapshot_code = snapshot_codes[i]; var percent = parseInt( (i+1) / (num_snapshots-1) * 100); var desc = "Checking out: "+(i+1)+" of "+num_snapshots+": "+snapshot_code; progress.setStyle("width", percent + "%"); message.innerHTML = desc; server.checkout_snapshot(snapshot_code, null, {file_types: ['main'], filename_mode: 'source'}); } progress.setStyle("width", "100%"); progress.setStyle("background", "#0F0"); message.innerHTML = "" ''' }) button = ButtonNewWdg(title="Sandbox", icon=IconWdg.FOLDER_GO) button_div.add(button) button.add_behavior({ 'type': 'click_up', 'sandbox_dir': sandbox_dir, 'cbjs_action': ''' var applet = spt.Applet.get(); applet.open_explorer(bvr.sandbox_dir); ''' }) msg_div = DivWdg() inner.add(msg_div) msg_div.add_class("spt_checkout_message") msg_div.add(" ") progress_div = DivWdg() inner.add(progress_div) progress_div.add_style("width: auto") progress_div.add_style("height: 15px") progress_div.add_style("margin: 0px 10px 10px 10px") progress_div.add_border() progress = DivWdg() progress.add_class("spt_checkout_progress") progress_div.add(progress) progress.add_style("background", "#F00") progress.add_style("width", "0%") progress.add(" ") snapshot_div = DivWdg() inner.add(snapshot_div) layout = ViewPanelWdg( search_type="sthpw/snapshot", show_shelf=False, edit=False, width="100%", element_names=[ 'preview', 'file', 'context', 'version', 'timestamp', 'description' ], ) snapshot_div.add(layout) layout.set_sobjects(snapshots[:50]) if my.kwargs.get("is_refresh") == 'true': return inner else: return top
def get_message(my): search_type_obj = my.parent.get_search_type_obj() title = search_type_obj.get_title() subject = my.get_subject() notification_message = my.notification.get_value("message") message = "%s %s Note Entry" % (title, my.parent.get_name()) if notification_message: message = "%s (%s)" %(message, notification_message) submit_desc = '' from pyasm.prod.biz import Submission if isinstance(my.parent, Submission): update_info = [''] # add more info about the file and bin snapshot = Snapshot.get_latest_by_sobject(my.parent, "publish") xpath = "snapshot/file[@type='main']" xml = snapshot.get_xml_value('snapshot') file = None if xml.get_node(xpath) is not None: file = my._get_file_obj(snapshot) else: snapshots = snapshot.get_all_ref_snapshots() snapshot_file_objects = [] if snapshots: snapshot = snapshots[0] file = my._get_file_obj(snapshot, type=None) if file: file_name = file.get_file_name() web_path = file.get_web_path() from pyasm.web import WebContainer host = WebContainer.get_web().get_base_url() update_info.append('Browse: %s %s%s' %( file_name, host.to_string(), web_path)) bins = my.parent.get_bins() bin_labels = [ bin.get_label() for bin in bins] update_info.append('Bin: %s' %', '.join(bin_labels)) update_info.append('Artist: %s' %my.parent.get_value('artist')) update_info.append('Description: %s' %my.parent.get_value('description')) # get notes search = Note.get_search_by_sobjects([my.parent]) if search: search.add_order_by("context") search.add_order_by("timestamp desc") notes = search.get_sobjects() last_context = None note_list = [] for i, note in enumerate(notes): context = note.get_value('context') # explicit compare to None if last_context == None or context != last_context: note_list.append( "[ %s ] " % context ) last_context = context #child_notes = my.notes_dict.get(note.get_id()) # draw note item date = Date(db=note.get_value('timestamp')) note_list.append('(%s) %s'%(date.get_display_time(), note.get_value("note"))) update_info.append('Notes: \n %s' % '\n'.join(note_list)) submit_desc = '\n'.join(update_info) update_desc = my.sobject.get_update_description() command_desc = my.command.get_description() message = '%s\n\nReport from transaction:\n%s\n\n%s\n%s' \ % (message, update_desc, command_desc, submit_desc) return message
def get_display(my): web = WebContainer.get_web() search_key = web.get_form_value("search_key") widget = Widget() sobject = Search.get_by_search_key(search_key) # get all of the snapshots with a context render sobject_snapshot = Snapshot.get_latest_by_sobject(sobject,"backplate") widget.add(HtmlElement.h3("BackPlate Frames")) if not sobject_snapshot: widget.add("No backplates checked in") return widget # get the images web_dir = sobject_snapshot.get_web_dir() xml = sobject_snapshot.get_xml_value("snapshot") file_nodes = xml.get_nodes("snapshot/file") file_name = icon_file_name = '' frame_range = icon_frame_range = None for file_node in file_nodes: if Xml.get_attribute(file_node, 'type') == 'main': file_name, frame_range = my._get_frame_info(file_node, sobject) if Xml.get_attribute(file_node, 'type') == 'icon': icon_file_name, icon_frame_range = my._get_frame_info(file_node, sobject) file_names = [file_name] icon_file_names = [icon_file_name] if "##" in file_name: file_names = FileGroup.expand_paths(file_name, frame_range) if "##" in icon_file_name: icon_file_names = FileGroup.expand_paths(icon_file_name, \ icon_frame_range) div = DivWdg() for k in range(len(file_names)): file_name = file_names[k] try: icon_file_name = icon_file_names[k] except IndexError: icon_file_name = file_names[k] file_path = "%s/%s" % (web_dir, file_name) icon_file_path = "%s/%s" % (web_dir, icon_file_name) img = HtmlElement.img(icon_file_path) img.add_event("onmouseover","hint_bubble.show(event,'Ctrl + Click to open in new window')") href = HtmlElement.href(img, file_path) div.add("%0.4d" % (k+1)) div.add(href) if k != 0 and (k+1) % 4 == 0: div.add("<br/>") div.add("<br/>") widget.add(div) return widget
def get_display(self): self.doc_mode = self.kwargs.get("doc_mode") path = self.kwargs.get("path") self.search_type = self.kwargs.get("search_type") self.last_path = None doc_key = self.kwargs.get("doc_key") if doc_key: self.doc = Search.get_by_search_key(doc_key) snapshot = Snapshot.get_latest_by_sobject(self.doc) if snapshot: self.last_path = snapshot.get_lib_path_by_type('main') path = self.doc.get_value("link") # TEST TEST TEST if not path: #path = "/home/apache/pdf/mongodb.txt" #path = "/home/apache/assets/google_docs.html" #path = "/home/apache/pdf/star_wars.txt" path = "https://docs.google.com/document/d/1AC_YR8X8wbKsshkJ1h8EjZuFIr41guvqXq3_PXgaqJ0/pub?embedded=true" path = "https://docs.google.com/document/d/1WPUmXYoSkR2cz0NcyM2vqQYO6OGZW8BAiDL31YEj--M/pub" #path = "https://docs.google.com/spreadsheet/pub?key=0Al0xl-XktnaNdExraEE4QkxVQXhaOFh1SHIxZmZMQ0E&single=true&gid=0&output=html" path = "/home/apache/tactic/doc/alias.json" if not self.search_type: self.search_type = "test3/shot" self.column = "description" top = self.top top.add_class("spt_document_top") self.set_as_panel(top) #table = Table() table = ResizableTableWdg() top.add(table) table.add_row() table.set_max_width() left_td = table.add_cell() left_td.add_style("vertical-align: top") title = DivWdg() left_td.add(title) title.add_style("padding: 10px") title.add_color("background", "background3") button = IconButtonWdg(title="Refresh", icon=IconWdg.REFRESH) title.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.app_busy.show("Reloading Document"); var top = bvr.src_el.getParent(".spt_document_top"); spt.panel.refresh(top); spt.app_busy.hide(); ''' } ) button.add_style("float: left") button = IconButtonWdg(title="Save", icon=IconWdg.SAVE) title.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' ''' } ) button.add_style("float: left") if not self.doc_mode: self.doc_mode = "text" select = SelectWdg("doc_mode") select.set_option("values", "text|formatted") title.add(select) select.set_value(self.doc_mode) select.add_behavior( { 'type': 'change', 'cbjs_action': ''' spt.app_busy.show("Reloading Document"); var top = bvr.src_el.getParent(".spt_document_top"); var value = bvr.src_el.value; top.setAttribute("spt_doc_mode", value); spt.panel.refresh(top); spt.app_busy.hide(); ''' } ) title.add("<br clear='all'/>") #title.add(path) text_wdg = DivWdg() text_wdg.add_class("spt_document_content") left_td.add(text_wdg) #if path.startswith("https://docs.google.com/spreadsheet"): # #path = "http://www.southpawtech.com.com" # text_wdg.add(''' # <iframe class="spt_document_iframe" style="width: 100%%; height: auto; min-height: 600px; font-size: 1.0em" src="%s"></iframe> # ''' % path) # text_wdg.add_style("overflow-x: hidden") if True: if not self.last_path and self.doc: tmp_dir = Environment.get_tmp_dir() tmp_path = '%s/last_path.txt' % tmp_dir f = open(tmp_path, 'w') text = self.get_text(path, highlight=False) f.write(text) f.close() cmd = FileCheckin(self.doc, tmp_path) Command.execute_cmd(cmd) else: save = False if save: # open up the last path f = open(self.last_path, 'r') last_text = f.read() text = self.get_text(path, None, highlight=False) if last_text != text: tmp_dir = Environment.get_tmp_dir() tmp_path = '%s/last_path.txt' % tmp_dir f = open(tmp_path, 'w') f.write(text) f.write(text) f.close() cmd = FileCheckin(self.doc, tmp_path) Command.execute_cmd(cmd) text = self.get_text(path, self.last_path) lines = text.split("\n") if self.doc_mode == "text": num_lines = len(lines) """ line_div = HtmlElement.pre() text_wdg.add(line_div) line_div.add_style("width: 20px") line_div.add_style("float: left") line_div.add_style("text-align: right") line_div.add_style("opacity: 0.3") line_div.add_style("padding-right: 10px") for i in range(0, num_lines*2): line_div.add(i+1) line_div.add("<br/>") """ if self.doc_mode == "text": pre = HtmlElement.pre() pre.add_style("white-space: pre-wrap") else: pre = DivWdg() pre = DivWdg() text_wdg.add(pre) text_wdg.add_style("padding: 10px 5px") text_wdg.add_style("max-height: 600px") text_wdg.add_style("overflow-y: auto") text_wdg.add_style("width: 600px") text_wdg.add_class("spt_resizable") pre.add_style("font-family: courier") if self.doc_mode == "formatted": pre.add(text) else: line_table = Table() pre.add(line_table) line_table.add_style("width: 100%") count = 1 for line in lines: #line = line.replace(" ", " ") tr = line_table.add_row() if count % 2 == 0: tr.add_color("background", "background", -2) td = line_table.add_cell() # FIXME: hacky if line.startswith('''<span style='background: #CFC'>'''): is_new = True else: td.add_style("vertical-align: top") text = TextWdg() text.add_style("border", "none") text.add_style("text-align", "right") text.add_style("width", "25px") text.add_style("margin", "0 10 0 0") text.add_style("opacity", "0.5") text.set_value(count) td.add(text) count += 1 is_new = False td = line_table.add_cell() if not is_new: SmartMenu.assign_as_local_activator( td,'TEXT_CTX' ) tr.add_class("spt_line"); else: SmartMenu.assign_as_local_activator( td,'TEXT_NEW_CTX' ) tr.add_class("spt_new_line"); td.add_class("spt_line_content"); td.add(line) #from tactic.ui.app import AceEditorWdg #editor = AceEditorWdg(code=text, show_options=False, readonly=True, height="600px") #text_wdg.add(editor) # add a click on spt_item text_wdg.add_relay_behavior( { 'type': 'mouseup', 'bvr_match_class': 'spt_document_item', 'search_type': self.search_type, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_document_top"); var data_el = top.getElement(".spt_document_data"); var search_key = bvr.src_el.getAttribute("spt_search_key"); var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': bvr.search_type, 'search_key': search_key, } spt.panel.load(data_el, class_name, kwargs); ''' } ) # add a double click on spt_item bgcolor = text_wdg.get_color("background", -10) text_wdg.add_relay_behavior( { 'type': 'mouseover', 'bvr_match_class': 'spt_document_item', 'search_type': self.search_type, 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("opacity", "1.0"); //bvr.src_el.setStyle("font-weight", "normal"); bvr.src_el.setStyle("background", bvr.bgcolor); ''' } ) # add a double click on spt_item text_wdg.add_relay_behavior( { 'type': 'mouseout', 'bvr_match_class': 'spt_document_item', 'search_type': self.search_type, 'cbjs_action': ''' bvr.src_el.setStyle("opacity", "1.0"); //bvr.src_el.setStyle("font-weight", "bold"); bvr.src_el.setStyle("background", ""); ''' } ) # add a context menu ctx_menu = self.get_text_context_menu() ctx_new_menu = self.get_text_new_context_menu() menus_in = { 'TEXT_CTX': ctx_menu, 'TEXT_NEW_CTX': ctx_new_menu, } SmartMenu.attach_smart_context_menu( text_wdg, menus_in, False ) panel = ViewPanelWdg( search_type=self.search_type, layout="blah" ) right_td = table.add_cell() right_td.add_style("vertical-align: top") panel_div = DivWdg() panel_div.add_class("spt_document_data") right_td.add(panel_div) panel_div.add(panel) text_wdg.add_behavior( { 'type': 'load', 'cbjs_action': r''' spt.document = {}; spt.document.selected_text = null; spt.document.get_selected_text = function(frame) { var t = ''; if (frame) { var rng = frame.contentWindow.getSelection().getRangeAt(0); spt.document.expandtoword(rng); t = rng.toString(); } else if (window.getSelection) // FF4 with one tab open? { var rng = window.getSelection().getRangeAt(0); spt.document.expandtoword(rng); t = rng.toString(); } else if (document.getSelection) // FF4 with multiple tabs open? { var rng = document.getSelection().getRangeAt(0); spt.document.expandtoword(rng); t = rng.toString(); } else if (document.selection) // IE8 { var rng = document.selection.createRange(); // expand range to enclose any word partially enclosed in it rng.expand("word"); t = rng.text; } // convert newline chars to spaces, collapse whitespace, and trim non-word chars return t.replace(/^\W+|\W+$/g, ''); //return t.replace(/\r?\n/g, " ").replace(/\s+/g, " ").replace(/^\W+|\W+$/g, ''); } // expand FF range to enclose any word partially enclosed in it spt.document.expandtoword = function(range) { if (range.collapsed) { return; } while (range.startOffset > 0 && range.toString()[0].match(/\w/)) { range.setStart(range.startContainer, range.startOffset - 1); } while (range.endOffset < range.endContainer.length && range.toString()[range.toString().length - 1].match(/\w/)) { range.setEnd(range.endContainer, range.endOffset + 1); } } ''' } ) top.add_relay_behavior( { 'type': 'mouseup', 'bvr_match_class': 'spt_document_content', 'cbjs_action': r''' //spt.ace_editor.set_editor_top(bvr.src_el); //var text = spt.ace_editor.get_selection(); var text = spt.document.get_selected_text(); text = text.replace(/\n\n/mg, "\n"); text = text.replace(/\n\n/mg, "\n"); spt.document.selected_text = text + ""; ''' } ) return top
def init(self): search_type = "prod/shot" widget = Widget() search = Search(search_type) div = DivWdg(css="filter_box") filter = SequenceFilterWdg() div.add(filter) #context_filter = ContextFilterWdg(label="Context: ", search_type=) #context_filter.set_search_type(search_type) #div.add(context_filter) context_wdg = TextWdg("context") context_wdg.set_persistence() span = SpanWdg(css="med") span.add("Context: ") span.add(context_wdg) div.add(span) self.context = context_wdg.get_value() if not self.context: self.context = None mode = "latest" filter.alter_search(search) sobjects = search.get_sobjects() widget.add(div) table = Table(css="table") table.add_style("width: 100%") for sobject in sobjects: table.add_row() thumb = ThumbWdg() thumb.set_sobject(sobject) table.add_cell(thumb) table.add_cell(sobject.get_code()) td = table.add_cell(WikiUtil().convert( sobject.get_value("description"))) td.add_style("width: 300px") if mode == "latest": snapshot = Snapshot.get_latest_by_sobject( sobject, self.context) else: snapshot = Snapshot.get_current_by_sobject( sobject, self.context) if not snapshot: table.add_cell("<i>No snapshot found</i>") continue dependency = DependencyWdg() dependency.set_show_title(False) dependency.set_sobject(snapshot) table.add_cell(dependency) widget.add(table) self.add(widget)
def get_display(my): web = WebContainer.get_web() search_key = web.get_form_value("search_key") widget = Widget() sobject = Search.get_by_search_key(search_key) table = TableWdg(sobject.get_search_type(), "render") table.set_sobject(sobject) widget.add(table) # get all of the snapshots with a context render sobject_snapshot = Snapshot.get_latest_by_sobject(sobject, "render") if sobject_snapshot: search_type = sobject.get_search_type() search_id = sobject.get_value('search_id') render_snapshots = Snapshot.get_by_search_type( search_type, search_id, "render") table = TableWdg("sthpw/snapshot") table.set_sobjects(render_snapshots) widget.add(table) widget.add(HtmlElement.h3("Rendered Frames")) if sobject_snapshot: widget.add("Render version: v%0.3d" % sobject_snapshot.get_value("version")) # get latest snapshot of the render renders = Render.get_all_by_sobject(sobject) if not renders: widget.add("<h4>No renders found</h4>") return widget render = renders[0] snapshot = Snapshot.get_latest_by_sobject(render, "render") if snapshot == None: widget.add("<h4>No snapshots found</h4>") return widget # get the images web_dir = snapshot.get_web_dir() lib_dir = snapshot.get_lib_dir() xml = snapshot.get_xml_value("snapshot") file_nodes = xml.get_nodes("snapshot/file") file_name = icon_file_name = '' frame_range = icon_frame_range = None for file_node in file_nodes: if Xml.get_attribute(file_node, 'type') == 'main': file_name, frame_range = my._get_frame_info(file_node, sobject) if Xml.get_attribute(file_node, 'type') == 'icon': icon_file_name, icon_frame_range = my._get_frame_info( file_node, sobject) file_names = [file_name] icon_file_names = [icon_file_name] if "##" in file_name: file_names = FileGroup.expand_paths(file_name, frame_range) if "##" in icon_file_name: icon_file_names = FileGroup.expand_paths(icon_file_name, \ icon_frame_range) div = DivWdg() for k in range(len(file_names)): file_name = file_names[k] # ignore frames that don't exist lib_path = "%s/%s" % (lib_dir, file_name) if not os.path.exists(lib_path): continue try: icon_file_name = icon_file_names[k] except IndexError: icon_file_name = file_names[k] file_path = "%s/%s" % (web_dir, file_name) icon_file_path = "%s/%s" % (web_dir, icon_file_name) img = HtmlElement.img(icon_file_path) img.set_attr("width", "60") img.add_event( "onmouseover", "hint_bubble.show(event,'Ctrl + Click to open in new window')") href = HtmlElement.href(img, file_path) div.add(href) widget.add(div) widget.add("<h3>Render History</h3>") widget.add(my.get_render_history(renders)) return widget
def get_message(my): search_type_obj = my.parent.get_search_type_obj() title = search_type_obj.get_title() subject = my.get_subject() notification_message = my.notification.get_value("message") message = "%s %s Note Entry" % (title, my.parent.get_name()) if notification_message: message = "%s (%s)" % (message, notification_message) submit_desc = '' from pyasm.prod.biz import Submission if isinstance(my.parent, Submission): update_info = [''] # add more info about the file and bin snapshot = Snapshot.get_latest_by_sobject(my.parent, "publish") xpath = "snapshot/file[@type='main']" xml = snapshot.get_xml_value('snapshot') file = None if xml.get_node(xpath) is not None: file = my._get_file_obj(snapshot) else: snapshots = snapshot.get_all_ref_snapshots() snapshot_file_objects = [] if snapshots: snapshot = snapshots[0] file = my._get_file_obj(snapshot, type=None) if file: file_name = file.get_file_name() web_path = file.get_web_path() from pyasm.web import WebContainer host = WebContainer.get_web().get_base_url() update_info.append('Browse: %s %s%s' % (file_name, host.to_string(), web_path)) bins = my.parent.get_bins() bin_labels = [bin.get_label() for bin in bins] update_info.append('Bin: %s' % ', '.join(bin_labels)) update_info.append('Artist: %s' % my.parent.get_value('artist')) update_info.append('Description: %s' % my.parent.get_value('description')) # get notes search = Note.get_search_by_sobjects([my.parent]) if search: search.add_order_by("context") search.add_order_by("timestamp desc") notes = search.get_sobjects() last_context = None note_list = [] for i, note in enumerate(notes): context = note.get_value('context') # explicit compare to None if last_context == None or context != last_context: note_list.append("[ %s ] " % context) last_context = context #child_notes = my.notes_dict.get(note.get_id()) # draw note item date = Date(db=note.get_value('timestamp')) note_list.append( '(%s) %s' % (date.get_display_time(), note.get_value("note"))) update_info.append('Notes: \n %s' % '\n'.join(note_list)) submit_desc = '\n'.join(update_info) update_desc = my.sobject.get_update_description() command_desc = my.command.get_description() message = '%s\n\nReport from transaction:\n%s\n\n%s\n%s' \ % (message, update_desc, command_desc, submit_desc) return message
def handle_contents(self, set): self.add(HtmlElement.br()) # get all of the reference nodes snapshot = Snapshot.get_latest_by_sobject(set, "publish") if snapshot == None: self.add(HtmlElement.h3("No Contents")) return snapshot_xml = snapshot.get_xml_value("snapshot") ref_nodes = snapshot_xml.get_nodes("snapshot/ref") nav = ItemsNavigatorWdg(self.ITEMS_NAV_LABEL, \ len(ref_nodes), self.MAX_ITEMS_PER_PAGE) items_range = nav.get_value() self.add(nav) introspect = IntrospectWdg() introspect.add_style('padding-bottom: 3px') self.add(introspect) # get the contents in the introspection session = SessionContents.get() start, end = 1 , self.MAX_ITEMS_PER_PAGE try: start, end = items_range.split("-") except Exception: pass ref_nodes = ref_nodes[int(start)-1 : int(end)] sobjects = [] info = [] for node in ref_nodes: search_type = Xml.get_attribute(node,"search_type") search_id = Xml.get_attribute(node,"search_id") instance = Xml.get_attribute(node,"instance") version = Xml.get_attribute(node,"version") latest_context = Xml.get_attribute(node,"context") # get the latest snapshot #TODO: this query can be optimized latest = Snapshot.get_latest(search_type, search_id, \ latest_context) if latest == None: latest_version = 0 else: latest_version = latest.get_value("version") # add an icon if latest != None: sobject = latest.get_sobject() else: sobject = None session_version = session.get_version(instance) session_context = session.get_context(instance) sobjects.append(sobject) info.append({'session_version': session_version, \ 'session_context': session_context, \ 'latest_context': latest_context, \ 'latest_version': latest_version, 'instance': instance}) table = TableWdg('prod/asset','set_items') table.set_sobjects(sobjects) table.set_aux_data(info) self.add(table)
def handle_contents(self, set): self.add(HtmlElement.br()) # get all of the reference nodes snapshot = Snapshot.get_latest_by_sobject(set, "publish") if snapshot == None: self.add(HtmlElement.h3("No Contents")) return snapshot_xml = snapshot.get_xml_value("snapshot") ref_nodes = snapshot_xml.get_nodes("snapshot/ref") nav = ItemsNavigatorWdg(self.ITEMS_NAV_LABEL, \ len(ref_nodes), self.MAX_ITEMS_PER_PAGE) items_range = nav.get_value() self.add(nav) introspect = IntrospectWdg() introspect.add_style('padding-bottom: 3px') self.add(introspect) # get the contents in the introspection session = SessionContents.get() start, end = 1, self.MAX_ITEMS_PER_PAGE try: start, end = items_range.split("-") except Exception: pass ref_nodes = ref_nodes[int(start) - 1:int(end)] sobjects = [] info = [] for node in ref_nodes: search_type = Xml.get_attribute(node, "search_type") search_id = Xml.get_attribute(node, "search_id") instance = Xml.get_attribute(node, "instance") version = Xml.get_attribute(node, "version") latest_context = Xml.get_attribute(node, "context") # get the latest snapshot #TODO: this query can be optimized latest = Snapshot.get_latest(search_type, search_id, \ latest_context) if latest == None: latest_version = 0 else: latest_version = latest.get_value("version") # add an icon if latest != None: sobject = latest.get_sobject() else: sobject = None session_version = session.get_version(instance) session_context = session.get_context(instance) sobjects.append(sobject) info.append({'session_version': session_version, \ 'session_context': session_context, \ 'latest_context': latest_context, \ 'latest_version': latest_version, 'instance': instance}) table = TableWdg('prod/asset', 'set_items') table.set_sobjects(sobjects) table.set_aux_data(info) self.add(table)
def execute(self): web = WebContainer.get_web() search_keys = [] # discovery phase to find the sobject to be rendered. This can be # either a snapshots or sobjects. If it is an sobject, then # the latest snapshot will be rendered search_type = web.get_form_value("parent_search_type") search_id = web.get_form_value("parent_search_id") if search_type: search_keys = ["%s|%s" % (search_type, search_id)] if not search_keys: if self.sobject: search_keys = [self.sobject.get_search_key()] else: search_keys = web.get_form_values("search_key") # get the policy policy = None if self.sobject: policy_code = self.sobject.get_value("policy_code") if policy_code: policy = RenderPolicy.get_by_code(policy_code) # render options options = {} keys = web.get_form_keys() for key in keys: if key.startswith("edit|"): value = web.get_form_value(key) new_key = key.replace("edit|", "") options[new_key] = value # add the xmlrpc server to the package: # WARNING: not that there is no / separating the 2 %s. client_api_url = web.get_client_api_url() options['client_api_url'] = client_api_url # go through each of the search keys found from the interface for search_key in search_keys: # find the sobject associates with this key if not search_key: continue sobject = Search.get_by_search_key(search_key) if not sobject: raise TacticException("Search Key [%s] does not exist" % search_key) # if the search_keys represented a snapshot, then use this as # the snapshot and find the parent if sobject.get_base_search_type() == "sthpw/snapshot": snapshot = sobject sobject = sobject.get_sobject() else: # else use the latest, assuming a context (really doesn't # make much sense????!!!??? # FIXME: will deal with this later context = "publish" snapshot = Snapshot.get_latest_by_sobject(sobject, context) if not snapshot: raise TacticException( "No checkins of context '%s' exist for '%s'. Please look at the chekin history" % (context, sobject.get_code())) # We provide a render package with a bunch of necessary information render_package = RenderPackage() render_package.set_policy(policy) render_package.set_snapshot(snapshot) render_package.set_sobject(sobject) render_package.set_options(options) # submission class submit_class = self.get_option("submit") if not submit_class: submit_class = Config.get_value("services", "render_submit_class", no_exception=True) if not submit_class: submit_class = "pyasm.prod.render.RenderSubmit" # now we have an sobject and a snapshot, we initiate a job submit = Common.create_from_class_path(submit_class, [render_package]) # if this is from the EditWdg for queues then use this queue # entry instead if self.sobject.get_base_search_type() == "sthpw/queue": submit.set_queue(self.sobject) submit.execute() self.description = "Submitted: %s" % ", ".join(search_keys)
def get_display(self): top = self.top layout = self.kwargs.get("layout") or "landscape" search_key = self.kwargs.get("search_key") file = self.kwargs.get("file") if search_key: sobject = Search.get_by_search_key(search_key) if sobject.get_base_search_type() == "sthpw/snapshot": snapshot = sobject else: snapshot = Snapshot.get_latest_by_sobject(sobject) src = snapshot.get_web_path_by_type() elif file: src = file.get_web_path() else: src = self.kwargs.get("src") opacity = 1.0 if not src: src = "/context/icons/logo/tactic_silver.png" opacity = 0.6 height = self.kwargs.get("height") width = self.kwargs.get("width") index = self.kwargs.get("index") if not height: height = "100%" if not width: width = "100%" # don't hard code width and height #width = "100%" #height = "auto" #div = DivWdg() #top.add(div) div = top div.add_class("unselectable") div.add_style("opacity", opacity) div.add_style("overflow-x: hidden") div.add_style("overflow-y: hidden") div.add_style("margin-left: auto") div.add_style("margin-right: auto") div.add_style("text-align: center") if height: div.add_style("height", height) if width: div.add_style("width", width) parts = os.path.splitext(src) ext = parts[1] ext = ext.lower() click = self.kwargs.get("click") if click in [False, 'false']: click = False else: click = True thumb_path = self.kwargs.get("thumb_path") preload = self.kwargs.get("preload") if not preload: preload = "none" ext = ext.lstrip(".") if ext in File.IMAGE_EXT: embed = DivWdg() embed.add_style("display: inline-block") embed.add_style("vertical-align: top") if layout == "landscape": embed.add_style("width: auto") embed.add_style("height: 100%") else: embed.add_style("width: 100%") embed.add_style("height: auto") if src.find("#") != -1: file_range = self.kwargs.get("file_range") for i in range(1, 16): expand = src.replace("####", "%0.4d" % i) item = HtmlElement.img(expand) embed.add(item) item.add_style("width: 25%") embed.add_style("overflow-y: auto") embed.add_style("text-align: left") #embed.add_behavior( { # 'type': 'load', # 'cbjs_action': ''' # new Scrollable(bvr.src_el) # ''' #} ) elif src.find("|") != -1: paths = src.split("|") for path in paths: item = HtmlElement.img(path) embed.add(item) item.add_style("width: 25%") embed.add_style("overflow-y: auto") embed.add_style("text-align: left") else: if isinstance(src, unicode): src = src.encode("utf-8") src = urllib.pathname2url(src) img = HtmlElement.img(src) embed.add(img) if layout == "landscape": img.add_style("width: auto") img.add_style("height: 100%") else: img.add_style("width: 100%") img.add_style("height: auto") elif ext in File.VIDEO_EXT: from tactic.ui.widget import VideoWdg embed = DivWdg() #if not thumb_path: # thumb_path = "/context/icons/logo/tactic_sml.png" controls = self.kwargs.get("controls") video_id = None sources = [src] source_types = ["video/mp4"] poster = thumb_path width = '100%' height = '100%' #width = "640" #height = "480" video = VideoWdg(video_id=video_id, sources=sources, source_types=source_types, poster=poster, preload=preload, controls=controls, width=width, height=height, index=index) embed.add(video) video.get_video().add_class("spt_resizable") click = False else: #embed = HtmlElement.embed(src) if thumb_path: img = HtmlElement.img(thumb_path) else: from pyasm.widget import ThumbWdg link = ThumbWdg.find_icon_link(src) img = HtmlElement.img(link) img.add_style("width: 50%") img.add_style("margin: 20px 20px") embed = DivWdg(img) div.add(embed) if click: embed.add_behavior( { 'type': 'click_up', 'src': src, 'cbjs_action': ''' window.open(bvr.src); ''' } ) embed.add_class("hand") return top