...
 
Commits (11)
......@@ -2,7 +2,12 @@ language: python
python:
- "3.5"
# command to install dependencies
install: "pip install -r requirements.txt"
# command to run tests
script: nosetests
install:
- pip install -r requirements.txt
- pip install coveralls
script:
coverage run --source=docker_ascii_map setup.py test
after_success:
coveralls
......@@ -4,6 +4,7 @@ RUN apt-get update && apt-get install -y python3 python3-pip
RUN update-ca-certificates -f
RUN pip3 install docker-py
COPY src/docker-ascii-map.py /usr/local/bin/
COPY . /usr/local/src/docker-ascii-map
RUN cd /usr/local/src/docker-ascii-map && python3 setup.py install
CMD python3 /usr/local/bin/docker-ascii-map.py
CMD /usr/local/bin/docker-ascii-map.py
[![Coverage Status](https://coveralls.io/repos/github/ChessCorp/docker-ascii-map/badge.svg?branch=master)](https://coveralls.io/github/ChessCorp/docker-ascii-map?branch=master)
[![Build Status](https://travis-ci.org/ChessCorp/docker-ascii-map.svg?branch=master)](https://travis-ci.org/ChessCorp/docker-ascii-map)
[![PyPI version](https://badge.fury.io/py/docker-ascii-map.svg)](https://badge.fury.io/py/docker-ascii-map)
# docker-ascii-map
A set of python scripts displaying the local docker containers structure and status on an ascii map.
......@@ -13,10 +17,10 @@ You can install this tool from PyPI:
```
alcibiade@mobydick:~$ sudo pip3 install docker-ascii-map
Collecting docker-ascii-map
Downloading docker-ascii-map-0.1.tar.gz
Downloading docker-ascii-map-0.3.tar.gz
Installing collected packages: docker-ascii-map
Running setup.py install for docker-ascii-map ... done
Successfully installed docker-ascii-map-0.1
Successfully installed docker-ascii-map-0.3
```
......
#!/usr/bin/env python3
import argparse
import sys
from docker_ascii_map import __version__
from docker_ascii_map.docker_config import ConfigParser
from docker_ascii_map.ascii_render import Renderer
parser = argparse.ArgumentParser(description='Display the docker host contents on a visual map.')
parser.add_argument('--version', action='version', version='%(prog)s ' + __version__)
if __name__ == '__main__':
args = parser.parse_args()
parser = ConfigParser()
renderer = Renderer()
......
......@@ -20,7 +20,7 @@ class Container:
self.image = image
self.ports = ports
def __str__(self) -> str:
def __repr__(self) -> str:
return '%s - %s - %s %s' % (self.name, self.status, self.networks, self.ports)
......@@ -28,8 +28,8 @@ class Configuration:
def __init__(self, containers: List[Container]):
self.containers = containers
def __str__(self):
return str([str(c) for c in self.containers])
def __repr__(self):
return str([repr(c) for c in self.containers])
class ConfigParser:
......
[aliases]
test=pytest
from distutils.core import setup
#!/usr/bin/env python3
from setuptools import setup
setup(
name='docker-ascii-map',
version='0.2',
version='0.3',
packages=['docker_ascii_map'],
package_dir={'': 'src'},
scripts=['src/docker_ascii_map/docker-ascii-map.py'],
package_dir={'docker_ascii_map': 'docker_ascii_map'},
scripts=['docker_ascii_map/docker-ascii-map.py'],
test_suite='tests',
setup_requires=['pytest-runner'],
install_requires=['docker-py'],
tests_require=['pytest'],
url='https://github.com/ChessCorp/docker-ascii-map',
license='MIT',
author='Yannick Kirschhoffer',
......
import unittest
from unittest.mock import patch
from docker import Client
from docker_ascii_map.docker_config import ConfigParser, PortMapping
class ConfigTests(unittest.TestCase):
def test_portmapping(self):
self.assertEqual('80:8080', str(PortMapping(private_port=8080, public_port=80)))
def test_empty_config(self):
with patch.object(Client, 'containers', return_value=[]) as mock_method:
configuration_parser = ConfigParser()
self.assertEqual([], configuration_parser.get_configuration().containers)
def test_single_container(self):
with patch.object(Client, 'containers', return_value=[
{'Names': ['/im1'], 'State': 'running', 'Image': 'ubuntu:latest',
'NetworkSettings': {'Networks': {}}, 'Ports': []}]) as mock_method:
configuration_parser = ConfigParser()
self.assertEqual('[\'im1 - running - [] []\']', str(configuration_parser.get_configuration()))
mock_method.assert_called_once_with(all=True)