Jun-05-2017, 08:40 PM
Ok at this time Requests does not enable the use of Digest Auth with ~/.netrc
So i came up with simple function do to the job for me
So i came up with simple function do to the job for me
def password_from_netrc(remote_url): rec = re.compile(r"https?://(www\.)?") url_no_proto = rec.sub('',remote_url).strip().strip('/') try: auth = netrc.netrc().authenticators(url_no_proto) except IOError: print('~/.netrc does not exist.') quit(1) if auth is None: print('%s not found in ~/.netrc' % url_no_proto) print('example: machine %s login <Username> password <Password>' % url_no_proto) quit(1) username = (auth[0]) password = auth[2] return username, password