Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/util.py
Show First 20 Lines • Show All 365 Lines • ▼ Show 20 Lines | if os.path.isfile(os.path.join(datadir, "bitcoin.conf")): | ||||
for line in f: | for line in f: | ||||
if line.startswith("rpcuser="): | if line.startswith("rpcuser="): | ||||
assert user is None # Ensure that there is only one rpcuser line | assert user is None # Ensure that there is only one rpcuser line | ||||
user = line.split("=")[1].strip("\n") | user = line.split("=")[1].strip("\n") | ||||
if line.startswith("rpcpassword="): | if line.startswith("rpcpassword="): | ||||
assert password is None # Ensure that there is only one rpcpassword line | assert password is None # Ensure that there is only one rpcpassword line | ||||
password = line.split("=")[1].strip("\n") | password = line.split("=")[1].strip("\n") | ||||
if os.path.isfile(os.path.join(datadir, "regtest", ".cookie")): | if os.path.isfile(os.path.join(datadir, "regtest", ".cookie")): | ||||
with open(os.path.join(datadir, "regtest", ".cookie"), 'r') as f: | with open(os.path.join(datadir, "regtest", ".cookie"), 'r', encoding="ascii") as f: | ||||
userpass = f.read() | userpass = f.read() | ||||
split_userpass = userpass.split(':') | split_userpass = userpass.split(':') | ||||
user = split_userpass[0] | user = split_userpass[0] | ||||
password = split_userpass[1] | password = split_userpass[1] | ||||
if user is None or password is None: | if user is None or password is None: | ||||
raise ValueError("No RPC credentials") | raise ValueError("No RPC credentials") | ||||
return user, password | return user, password | ||||
▲ Show 20 Lines • Show All 249 Lines • Show Last 20 Lines |