test_docker.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:aardvark 作者: Netflix-Skunkworks 项目源码 文件源码
def get_docker_container_list(*expected_containers):
        '''Get the output from "docker ps -a" for specified container names.'''

        container_listing_pattern = (
            r'(?P<id>[0-9a-f]+)\s+'
            r'(?P<image>[^\s]+)\s+'
            r'(?P<command>"[^"]+")\s+'
            r'(?P<created>.+ago)\s+'
            r'(?P<status>(Created|Exited.*ago|Up \d+ \S+))\s+'
            r'(?P<ports>[^\s]+)?\s+'
            r'(?P<name>[a-z]+_[a-z]+)'
            # r'\s*$'
            )
        container_listing_re = re.compile(container_listing_pattern)

        docker_containers_response = pexpect.run('docker ps -a')

        container_list = []
        # expected_container_nametag_pairs = [
        #     (x.split(':') + ['latest'])[0:2] for x in expected_containers
        #     ] if expected_containers else []

        for line in docker_containers_response.split('\n'):
            match = container_listing_re.match(line)
            if match:
                container_list.append(match.groupdict())

        return container_list

    # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号