Created
January 11, 2017 10:27
-
-
Save richard-mihalovic/61f9d52f77280130469a69498d481a5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
def has_mongodb(host, port=27017): | |
try: | |
host_addr = socket.gethostbyname(host) | |
if not host_addr: | |
return False | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.settimeout(1) | |
s.connect((host, port)) | |
s.close() | |
except KeyboardInterrupt: | |
raise | |
except: | |
return False | |
return True | |
print(has_mongodb('domain.tld') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment