Advertisement
Guest User

Untitled

a guest
Jun 7th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import socket
  3. from kombu import Connection
  4. host = "localhost"
  5. port = 5672
  6. user = "username"
  7. password = "secret"
  8. vhost = "/"
  9. url = 'amqp://{0}:{1}@{2}:{3}/{4}'.format(user, password, host, port, vhost)
  10. with Connection(url) as c:
  11. try:
  12. c.connect()
  13. except socket.error:
  14. raise ValueError("Received socket.error, "
  15. "rabbitmq server probably isn't running")
  16. except IOError:
  17. raise ValueError("Received IOError, probably bad credentials")
  18. else:
  19. print "Credentials are valid"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement