コード例 #1
0
ファイル: maya_set_wdg.py プロジェクト: mincau/TACTIC
    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)
コード例 #2
0
ファイル: visual_notes_wdg.py プロジェクト: rajubuddha/TACTIC
    def get_display(my):
        top = DivWdg()
        top.add_class("spt_visual_notes_top")

        my.search_key = my.kwargs.get("search_key")
        my.context = my.kwargs.get("context")
        assert my.search_key
        assert my.context


        sobject = Search.get_by_search_key(my.search_key)
        sobj_search_type = sobject.get_search_type()
        sobj_id = sobject.get_id()
        assert sobject

        snapshot = Snapshot.get_latest(sobj_search_type, sobj_id, my.context)
        if not snapshot:
            my.path = ''
            top.add("<b>No snapshot found</b>")
            return top
        else:
            files = snapshot.get_files_by_type("main")
            
            file = files[0]
            my.path = "/assets/%s/%s" % (file.get_value("relative_dir"), file.get_value("file_name") )

            #my.path = "/assets/cg/asset/chr/chr001/icon/hawaii01_web_icon_v001.jpg"


        my.note_context = my.context + '|note'


        # put in a title
        title_div = DivWdg()
        title_div.add_class("maq_search_bar")
        title_div.add("Visual Notes Editor")
        top.add(title_div)


        # add in the buttons bar
        buttons_wdg = my.get_buttons_wdg()
        top.add(buttons_wdg)




        flash_vars = "file=" + my.path;

        #'swf_url': '/assets/sthpw/widget/visual_notes_wdg/VisualNotesWdg.swf',
        kwargs = {
              'swf_url': '/context/visual_notes_wdg.swf',
              'title': 'Flash Test',
              'flash_vars': flash_vars,
              'width': '800',
              'height': '600'
        }
        #spt.panel.load('spt_flash', 'tactic.ui.panel.SwfWdg', kwargs);

        from tactic.ui.panel import SwfWdg
        swf = SwfWdg(**kwargs)
        top.add(swf)


        return top
コード例 #3
0
    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)
コード例 #4
0
    def get_display(self):
        
        if self.mode == 'detail':
            upstream = True
            div = DivWdg()
            self.snapshot_code = self.kwargs.get('snapshot_code')
            ref_snapshot = Snapshot.get_by_code(self.snapshot_code)
            self._handle_snapshot(ref_snapshot, div, upstream, recursive=False)
            return div


        self.web = WebContainer.get_web()

        if self.sobjects:
            snapshot = self.sobjects[0]
        else:
            search_type = self.kwargs.get("search_type")
            search_id = self.kwargs.get("search_id")

            snapshot = None
            if search_type == Snapshot.SEARCH_TYPE:
                snapshot = Search.get_by_id(search_type, search_id)
            else:
                snapshot = Snapshot.get_latest(search_type, search_id)
        if not snapshot:
            self.add(HtmlElement.h3("No snapshot found"))
            return super(DependencyWdg,self).get_display()



        widget = DivWdg()
        widget.add_style('min-width: 700px')
        
      
        if self.show_title:
            self.add(HtmlElement.h3("Asset Dependency"))

        from tactic.ui.panel import TableLayoutWdg
        table = TableLayoutWdg(search_type="sthpw/snapshot", mode='simple', view='table', width='700px')
        table.add_style('min-width: 700px')
        table.set_sobject(snapshot)
        widget.add(table)


        sobject = snapshot.get_sobject()
        search_type_obj = sobject.get_search_type_obj()

        #file_div = DivWdg(css='left_content discussion_child')
        file_div = DivWdg()
        file_div.add_color("background", "background", -20)
        file_div.add_color("color", "color")
        file_div.add_style("padding: 5px")
        file_div.add_border()




        #file_div.add_style('margin','0 10px 0 10px')
        file_div.add_style('padding','10px 0 0 10px')
        #file_div.add_style('-moz-border-radius: 6px')
        title = DivWdg()
        title.add_style("font-weight: bold")
        title.add_style("font-size: 1.2em")
        #title.add_style('margin-left', '10px')

        if self.show_title:
            title.add(search_type_obj.get_title() )
            title.add(" - ")
            title.add(sobject.get_code() )
            if sobject.has_value("description"):
                title.add(" : ")
                title.add(sobject.get_value("description") )

            file_div.add(title)
            file_div.add(HtmlElement.br())

        # find out how many 1st level ref nodes we are dealing with
        xml = snapshot.get_xml_value("snapshot")
        
        #self.total_ref_count = len(xml.get_nodes("snapshot/file/ref | snapshot/ref |snapshot/input_ref| snapshot/fref"))

        self._handle_snapshot(snapshot, file_div, upstream=True, recursive=True )
        self._handle_snapshot(snapshot, file_div,  upstream=False, recursive=True )

        #widget.add(widget)
        widget.add(file_div)
        widget.add(HtmlElement.br(2))

        #return super(DependencyWdg,self).get_display()
        return widget
コード例 #5
0
ファイル: flash_render_cmd.py プロジェクト: rajubuddha/TACTIC
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