Пример #1
0
def tool_list(account):
    """Get the list of tools existing in the tool directories"""

    def parse_tool(tool_file):
        """Parse the tool file and return a Tool object"""
        lines = open(tool_file).read().splitlines()
        return Tool(**dict(
            [[y.strip() for y in x.split('=')] for x in lines if x]))

    paths = {}
    if webfrontConfig.has_option('toolbox', 'path'):
        paths = webfrontConfig.get('toolbox', 'path').split(os.pathsep)
    else:
        return None
    
    tool_list = []
    for path in paths:
        if os.access(path, os.F_OK):
            filelist = os.listdir(path)
            for filename in filelist:
                if filename[-5:] == '.tool':
                    fullpath = os.path.join(path, filename)
                    try:
                        tool = parse_tool(fullpath)
                    except Exception, error:
                        _logger.error('Error parsing tool in %s: %s',
                                      filename, error)
                        continue

                    if account.has_perm('web_access', tool.uri):
                        tool_list.append(tool)
Пример #2
0
def tool_list(account):
    """Get the list of tools existing in the tool directories"""

    def parse_tool(tool_file):
        """Parse the tool file and return a Tool object"""
        attrs = (
            line.split('=', 1)
            for line in io.open(tool_file, encoding='utf-8')
            if line.strip()
        )
        attrs = {key.strip(): value.strip() for key, value in attrs}
        return Tool(**attrs)

    paths = [os.path.join(path, 'toolbox') for path in CONFIG_LOCATIONS]
    if webfrontConfig.has_option('toolbox', 'path'):
        paths = webfrontConfig.get('toolbox', 'path').split(os.pathsep)

    _tool_list = []
    for path in paths:
        if os.access(path, os.F_OK):
            filelist = os.listdir(path)
            for filename in filelist:
                if filename[-5:] == '.tool':
                    fullpath = os.path.join(path, filename)
                    try:
                        tool = parse_tool(fullpath)
                    except Exception as error:
                        _logger.error('Error parsing tool in %s: %s', filename, error)
                        continue

                    if account.has_perm('web_access', tool.uri):
                        _tool_list.append(tool)
    _tool_list.sort()
    return _tool_list
Пример #3
0
def tool_list(account):
    """Get the list of tools existing in the tool directories"""
    def parse_tool(tool_file):
        """Parse the tool file and return a Tool object"""
        lines = open(tool_file).read().splitlines()
        return Tool(**dict([[y.strip() for y in x.split('=')] for x in lines
                            if x]))

    paths = {}
    if webfrontConfig.has_option('toolbox', 'path'):
        paths = webfrontConfig.get('toolbox', 'path').split(os.pathsep)
    else:
        return None

    _tool_list = []
    for path in paths:
        if os.access(path, os.F_OK):
            filelist = os.listdir(path)
            for filename in filelist:
                if filename[-5:] == '.tool':
                    fullpath = os.path.join(path, filename)
                    try:
                        tool = parse_tool(fullpath)
                    except Exception as error:
                        _logger.error('Error parsing tool in %s: %s', filename,
                                      error)
                        continue

                    if account.has_perm('web_access', tool.uri):
                        _tool_list.append(tool)
    _tool_list.sort()
    return _tool_list