def checkAuth(host, iUsername, iPassword): client = tinydav.HTTPClient(host) client.setbasicauth(iUsername, iPassword) try: print client.head('/test') except HTTPUserError as e: #logging print e logging.debug(e) return False return True
def loadAuth(iPath): username, password = '', '' try: with open(iPath) as f: content = yaml.load(f) username = base64.decodestring(content[base64.encodestring('username')]) password = base64.decodestring(content[base64.encodestring('password')]) except Exception as e: # logging e logging.debug(e) return username, password