command.py 718 B

1234567891011121314151617181920212223242526272829
  1. from docker import Client
  2. import logging
  3. import os
  4. import yaml
  5. from ..service_collection import ServiceCollection
  6. from .docopt_command import DocoptCommand
  7. from .formatter import Formatter
  8. from .utils import cached_property, mkdir
  9. log = logging.getLogger(__name__)
  10. class Command(DocoptCommand):
  11. @cached_property
  12. def client(self):
  13. if os.environ.get('DOCKER_URL'):
  14. return Client(os.environ['DOCKER_URL'])
  15. else:
  16. return Client()
  17. @cached_property
  18. def service_collection(self):
  19. config = yaml.load(open('plum.yml'))
  20. return ServiceCollection.from_config(self.client, config)
  21. @cached_property
  22. def formatter(self):
  23. return Formatter()