errors.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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)