I'm trying to parse a list of IP:ports via a command argument to variable called HOSTS, to be used in a function - read_head_block_ints.
parser = argparse.ArgumentParser(description='chain info checker')
parser.add_argument('host', help='host address')
parser.add_argument('function', help='check to run', choices=ALLOWED_FUNCTIONS)
parser.add_argument('--hosts', dest='HOSTS', type=list)
def read_head_block_ints():
for host in HOSTS:
try:
data = requests.get(URLS['get_info'].format(host=host), verify=False).json() # returns data in JSON format
HEAD_BLOCK_INTS.append(float(data['head_block_num'])) # this is the head_block INT
except:
print('Error cannot connect to host {host}'.format(host=host))
When I call the script using --hosts 1.2.3.4:888 5.6.7.8:8888 9.9.9.9:8888
I get the following error: unrecognized arguments: 5.6.7.8:8888 9.9.9.9:8888