Changeset View
Changeset View
Standalone View
Standalone View
contrib/linearize/linearize-hashes.py
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | while height < settings['max_height'] + 1: | ||||
resp_obj['result'] = hex_switchEndian(resp_obj['result']) | resp_obj['result'] = hex_switchEndian(resp_obj['result']) | ||||
print(resp_obj['result']) | print(resp_obj['result']) | ||||
height += num_blocks | height += num_blocks | ||||
def get_rpc_cookie(): | def get_rpc_cookie(): | ||||
# Open the cookie file | # Open the cookie file | ||||
with open(os.path.join(os.path.expanduser(settings['datadir']), '.cookie'), 'r') as f: | with open(os.path.join(os.path.expanduser(settings['datadir']), '.cookie'), 'r', encoding="ascii") as f: | ||||
combined = f.readline() | combined = f.readline() | ||||
combined_split = combined.split(":") | combined_split = combined.split(":") | ||||
settings['rpcuser'] = combined_split[0] | settings['rpcuser'] = combined_split[0] | ||||
settings['rpcpassword'] = combined_split[1] | settings['rpcpassword'] = combined_split[1] | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
if len(sys.argv) != 2: | if len(sys.argv) != 2: | ||||
print("Usage: linearize-hashes.py CONFIG-FILE") | print("Usage: linearize-hashes.py CONFIG-FILE") | ||||
sys.exit(1) | sys.exit(1) | ||||
f = open(sys.argv[1]) | f = open(sys.argv[1], encoding="utf8") | ||||
for line in f: | for line in f: | ||||
# skip comment lines | # skip comment lines | ||||
m = re.search(r'^\s*#', line) | m = re.search(r'^\s*#', line) | ||||
if m: | if m: | ||||
continue | continue | ||||
# parse key=value lines | # parse key=value lines | ||||
m = re.search(r'^(\w+)\s*=\s*(\S.*)$', line) | m = re.search(r'^(\w+)\s*=\s*(\S.*)$', line) | ||||
Show All 38 Lines |