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
def dict_read_value(src, path, default=None): | |
value = src | |
keys = path.split('.') | |
for key in keys: | |
if isinstance(value, dict) and key in value: | |
value = value[key] | |
else: | |
return default |
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 |