|
9 | 9 |
|
10 | 10 | def parse_args():
|
11 | 11 | parser = argparse.ArgumentParser()
|
12 |
| -parser.add_argument('-x', '--xforce', required=True, type=argparse.FileType('r'), help='Path to a file containing ' |
13 |
| -'your X-Force credentials.') |
14 |
| -parser.add_argument('address', nargs='?', help='An IP address to be checked via X-Force') |
| 12 | +parser.add_argument('api_authN_file', type=argparse.FileType('r'), |
| 13 | +help='Path to a file containing your X-Force credentials, key and password on first and second ' |
| 14 | +'lines, respectively.') |
| 15 | +parser.add_argument('address', nargs='?', metavar='ip_address', help='An IP address to be checked via X-Force. If ' |
| 16 | +'the IP address is omitted or invalid, the ' |
| 17 | +'user will be prompted for one.') |
15 | 18 | return parser.parse_args()
|
16 | 19 |
|
17 | 20 |
|
@@ -55,9 +58,12 @@ def main():
|
55 | 58 | url = "{}/{}/{}".format(XFORCE_API_BASE, XFORCE_API_IP_REP, ip)
|
56 | 59 |
|
57 | 60 | # get X-Force API keys
|
58 |
| -creds = read_in_xforce_keys(args.xforce) |
| 61 | +creds = read_in_xforce_keys(args.api_authN_file) |
59 | 62 | result = requests.get(url, auth=(creds[0], creds[1]))
|
| 63 | +# maybe user swapped key and password in api creds file? |
| 64 | +# if result.status_code == '401': |
60 | 65 | pprint.pprint(result.json())
|
| 66 | + |
61 | 67 | return 0
|
62 | 68 |
|
63 | 69 |
|
|
0 commit comments