File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### Python Challenge
2+
3+
```
4+
Usage: xfipchk.py [-h] api_authN_file [ip_address]
5+
6+
positional arguments:
7+
api_authN_file Path to a file containing your X-Force credentials, key and
8+
password on first and second lines, respectively.
9+
10+
ip_address An IP address to be checked via X-Force. If the IP address
11+
is omitted or invalid, the user will be prompted for one.
12+
13+
optional arguments:
14+
-h, --help show this help message and exit
15+
```
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99

1010
def parse_args():
1111
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.')
1518
return parser.parse_args()
1619

1720

@@ -55,9 +58,12 @@ def main():
5558
url = "{}/{}/{}".format(XFORCE_API_BASE, XFORCE_API_IP_REP, ip)
5659

5760
# get X-Force API keys
58-
creds = read_in_xforce_keys(args.xforce)
61+
creds = read_in_xforce_keys(args.api_authN_file)
5962
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':
6065
pprint.pprint(result.json())
66+
6167
return 0
6268

6369

0 commit comments

Comments
 (0)