labpack/platforms/docker.py
def network_ls(self):
        
        '''
            a method to list the available networks
            
        :return: list of dictionaries with docker network fields

        [{
            'NETWORK ID': '3007476acfe5',
            'NAME': 'bridge',
            'DRIVER': 'bridge',
            'SCOPE': 'local'
        }]
        '''

        import re
        gap_pattern = re.compile('\t|\s{2,}')
        network_list = []
        sys_command = 'docker network ls'
        output_lines = self.command(sys_command).split('\n')
        column_headers = gap_pattern.split(output_lines[0])
        for i in range(1,len(output_lines)):
            columns = gap_pattern.split(output_lines[i])
            network_details = {}
            if len(columns) > 1:
                for j in range(len(column_headers)):
                    network_details[column_headers[j]] = ''
                    if j <= len(columns) - 1:
                        network_details[column_headers[j]] = columns[j]
                network_list.append(network_details)

        return network_list

            a method to list the available networks
            
        :return: list of dictionaries with docker network fields

        [{
            'NETWORK ID': '3007476acfe5',
            'NAME': 'bridge',
            'DRIVER': 'bridge',
            'SCOPE': 'local'
        }]
        
a method to list the available networks
a method to list the available networks
def network_ls(self):
        import re
        gap_pattern = re.compile('\t|\s{2,}')
        network_list = []
        sys_command = 'docker network ls'
        output_lines = self.command(sys_command).split('\n')
        column_headers = gap_pattern.split(output_lines[0])
        for i in range(1,len(output_lines)):
            columns = gap_pattern.split(output_lines[i])
            network_details = {}
            if len(columns) > 1:
                for j in range(len(column_headers)):
                    network_details[column_headers[j]] = ''
                    if j <= len(columns) - 1:
                        network_details[column_headers[j]] = columns[j]
                network_list.append(network_details)
        return network_list
def network_ls ( self ) : import re gap_pattern = re . compile ( '\t|\s{2,}' ) network_list = [ ] sys_command = 'docker network ls' output_lines = self . command ( sys_command ) . split ( '\n' ) column_headers = gap_pattern . split ( output_lines [ 0 ] ) for i in range ( 1 , len ( output_lines ) ) : columns = gap_pattern . split ( output_lines [ i ] ) network_details = { } if len ( columns ) > 1 : for j in range ( len ( column_headers ) ) : network_details [ column_headers [ j ] ] = '' if j <= len ( columns ) - 1 : network_details [ column_headers [ j ] ] = columns [ j ] network_list . append ( network_details ) return network_list
a method to list the available networks
a method to list the available networks
'''
            a method to list the available networks
            
        :return: list of dictionaries with docker network fields

        [{
            'NETWORK ID': '3007476acfe5',
            'NAME': 'bridge',
            'DRIVER': 'bridge',
            'SCOPE': 'local'
        }]
        '''
list of dictionaries with docker network fields
[{
'NETWORK ID': '3007476acfe5',
'NAME': 'bridge',
'DRIVER': 'bridge',
'SCOPE': 'local'
}]
list of dictionaries with docker network fields [ { ' NETWORK ID ' : ' 3007476acfe5 ' ' NAME ' : ' bridge ' ' DRIVER ' : ' bridge ' ' SCOPE ' : ' local ' } ]
self