errors.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. from __future__ import absolute_import
  2. from textwrap import dedent
  3. class UserError(Exception):
  4. def __init__(self, msg):
  5. self.msg = dedent(msg).strip()
  6. def __unicode__(self):
  7. return self.msg
  8. __str__ = __unicode__
  9. class DockerNotFoundMac(UserError):
  10. def __init__(self):
  11. super(DockerNotFoundMac, self).__init__("""
  12. Couldn't connect to Docker daemon. You might need to install docker-osx:
  13. https://github.com/noplay/docker-osx
  14. """)
  15. class DockerNotFoundUbuntu(UserError):
  16. def __init__(self):
  17. super(DockerNotFoundUbuntu, self).__init__("""
  18. Couldn't connect to Docker daemon. You might need to install Docker:
  19. http://docs.docker.io/en/latest/installation/ubuntulinux/
  20. """)
  21. class DockerNotFoundGeneric(UserError):
  22. def __init__(self):
  23. super(DockerNotFoundGeneric, self).__init__("""
  24. Couldn't connect to Docker daemon. You might need to install Docker:
  25. http://docs.docker.io/en/latest/installation/
  26. """)
  27. class ConnectionErrorBoot2Docker(UserError):
  28. def __init__(self):
  29. super(ConnectionErrorBoot2Docker, self).__init__("""
  30. Couldn't connect to Docker daemon - you might need to run `boot2docker up`.
  31. """)
  32. class ConnectionErrorGeneric(UserError):
  33. def __init__(self, url):
  34. super(ConnectionErrorGeneric, self).__init__("""
  35. Couldn't connect to Docker daemon at %s - is it running?
  36. If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
  37. """ % url)
  38. class ComposeFileNotFound(UserError):
  39. def __init__(self, supported_filenames):
  40. super(ComposeFileNotFound, self).__init__("""
  41. Can't find a suitable configuration file in this directory or any parent. Are you in the right directory?
  42. Supported filenames: %s
  43. """ % ", ".join(supported_filenames))