예제 #1
0
    def get_file_info(xml,
                      file_objects,
                      sobject,
                      snapshot,
                      show_versionless=False,
                      is_list=False):
        info = {}
        #TODO: {'file_type': [file_type]: [path], 'base_type': [base_type]: [file|directory|sequence]}

        if is_list:
            info = []
        else:
            repo_info = {}
            info['_repo'] = repo_info

        nodes = xml.get_nodes("snapshot/file")
        for node in nodes:
            type = Xml.get_attribute(node, "type")

            file_code = Xml.get_attribute(node, "file_code")

            file_object = file_objects.get(file_code)
            if not file_object:
                if isinstance(info, dict):
                    info[type] = ThumbWdg.get_no_image()
                else:
                    info.append((type, ThumbWdg.get_no_image()))
                Environment.add_warning(
                    "No file object",
                    "No file object found for file code '%s'" % file_code)
                continue

            file_name = file_object.get_full_file_name()
            web_dir = sobject.get_web_dir(snapshot, file_object=file_object)

            # handle a range if it exists
            file_range = file_object.get_value("file_range")
            if file_range:
                from pyasm.biz import FileGroup, FileRange
                file_range = FileRange.get(file_range)
                file_names = FileGroup.expand_paths(file_name, file_range)
                # just check the first frame
                if file_names:
                    file_name = file_names[0]
            path = "%s/%s" % (web_dir, file_name)

            if isinstance(info, dict):
                info[type] = path
                lib_dir = sobject.get_lib_dir(snapshot,
                                              file_object=file_object)
                repo_info[type] = "%s/%s" % (lib_dir, file_name)
            else:
                info.append((type, path))

        return info
예제 #2
0
파일: file_wdg.py 프로젝트: asmboom/TACTIC
    def get_file_info(xml, file_objects, sobject, snapshot, show_versionless=False, is_list=False, protocol='http'):
        info = {}
        #TODO: {'file_type': [file_type]: [path], 'base_type': [base_type]: [file|directory|sequence]}

        if is_list:
            info = []
        else:
            repo_info = {}
            info['_repo'] = repo_info

        nodes = xml.get_nodes("snapshot/file")
        for node in nodes:
            type = Xml.get_attribute(node, "type")

            file_code = Xml.get_attribute(node, "file_code")

            file_object = file_objects.get(file_code)
            if not file_object:
                if isinstance(info, dict):
                    info[type] = ThumbWdg.get_no_image()
                else:
                    info.append((type, ThumbWdg.get_no_image()))
                Environment.add_warning("No file object", "No file object found for file code '%s'" % file_code)
                continue

            file_name = file_object.get_full_file_name()
            web_dir = sobject.get_web_dir(snapshot, file_object=file_object)

            # handle a range if it exists
            file_range = file_object.get_value("file_range")
            if file_range:
                from pyasm.biz import FileGroup, FileRange
                file_range = FileRange.get(file_range)
                file_names = FileGroup.expand_paths(file_name, file_range)
                # just check the first frame
                if file_names:
                    file_name = file_names[0]
            path = "%s/%s" % (web_dir, file_name)

            if protocol != "file":
                path = urllib.pathname2url(path)

            if isinstance(info, dict):
                info[type] = path
                lib_dir = sobject.get_lib_dir(snapshot, file_object=file_object)
                repo_info[type] = "%s/%s" % (lib_dir, file_name)
            else:
                info.append((type, path))

        return info
예제 #3
0
    def _handle_files(self, snapshot, widget, upstream, recursive=True):

        web_dir = snapshot.get_web_dir()
        xml = snapshot.get_xml_value("snapshot")

        # handle files
        files = xml.get_nodes("snapshot/file")
        for file in files:
            
            file_code = Xml.get_attribute(file, "file_code")
            file_type = Xml.get_attribute(file, "type")
            file_range = Xml.get_attribute(file, "file_range")
            #file_range = "1-4/1"

            dir = snapshot.get_client_lib_dir(file_type=file_type)
            lib_dir = snapshot.get_lib_dir(file_type=file_type)
            open_button = IconButtonWdg( "Explore: %s" % dir, IconWdg.LOAD, False)
            if dir == lib_dir:
                open_button.add_behavior({'type':'click_up', 'cbjs_action': '''var applet = spt.Applet.get();
                                       
                                            spt.alert('You are not allowed to browse directories on a web server.');
                                    '''})
            else:
                open_button.add_behavior({'type':'click_up', 
                                        'dir' : dir,
                                        'cbjs_action': '''
                                        var applet = spt.Applet.get();
                                        
                                        var dir = bvr.dir;
                                      
                                        applet.open_explorer(dir);'''})
            open_button.add_class('small')
            open_button.add_style('float: left')
            widget.add(open_button)

            if file_range:
                file_name = Xml.get_attribute(file, "name")
                widget.add("%s [code = %s, type = %s]" % (file_name, file_code, file_type))
                widget.add(HtmlElement.br(2))

                # display all of the paths
                file_names = FileGroup.expand_paths( file_name, FileRange.get(file_range) )
                for file_name in file_names:
                    #link = HtmlElement.href(file_name, "%s/%s" % (web_dir, file_name), target="_blank" )
                    link = SpanWdg(file_name)
                    link.add_color("color", "color")
                    widget.add(link)
                    widget.add(HtmlElement.br())

            else:
                thumb = DependencyThumbWdg()
                thumb.set_show_filename(True)
                thumb.set_sobject(snapshot)
                thumb.set_icon_size(15)
                thumb.set_image_link_order([file_type])
                thumb.set_option('detail', 'false')

                widget.add(SpanWdg(thumb, css='small'))
                widget.add("[code = %s, type = %s]" % ( file_code, file_type))

            widget.add(HtmlElement.br())
            

            block = DivWdg()
            block.add_style("margin-left: 30px")
            block.add_style("margin-top: 10px")
            nodes = xml.get_nodes("snapshot/file[@file_code='%s']/ref" % file_code)
            widget.add(HtmlElement.br(clear="all"))
            # handle sub refs
            for node in nodes:
                self._handle_ref_node(node, block, upstream, recursive)
                block.add(HtmlElement.br())
            if nodes:
                widget.add(block)

            widget.add(HtmlElement.br())



        files = xml.get_nodes("snapshot/unknown_ref")
        if files:
            widget.add(HtmlElement.b("Unknown ref."))
        for file in files:
            block = DivWdg()
            block.add_style("margin-left: 30px")
            block.add_style("margin-top: 10px")

            block.add( IconWdg( "Unknown", IconWdg.UNKNOWN) )

            path = Xml.get_attribute(file, "path")
            block.add(path)
            widget.add(block)