ervikrant06 / Python_basic

Learning Basics of Python
2 stars 1 forks source link

Suggestions: parsing_introspection_data.py #2

Open psachin opened 7 years ago

psachin commented 7 years ago

When script is run w/o argument. It should throw hint that is expects an argument in form if file.

psachin@nubia:[master :) ]$ python parsing_introspection_data.py 
Traceback (most recent call last):
  File "parsing_introspection_data.py", line 14, in <module>
    with open(sys.argv[1]) as data_file:
IndexError: list index out of range

Output not in pretty table form?

psachin@nubia:[master :) ]$ python parsing_introspection_data.py instackenv.json
1: nodes
Enter one numeric value: 1
[{'arch': 'x86_64', 'mac': ['2c:c2:60:57:0f:54'], 'pm_user': 'admin', 'cpu': '2', 'pm_addr': '10.10.10.11', 'pm_type': 'pxe_ipmitool', 'pm_password': 'redhat', 'disk': '25', 'memory': '8192'}, {'arch': 'x86_64', 'mac': ['2c:c2:60:12:57:c4'], 'pm_user': 'admin', 'cpu': '2', 'pm_addr': '10.10.10.12', 'pm_type': 'pxe_ipmitool', 'pm_password': 'redhat', 'disk': '25', 'memory': '8192'}, {'arch': 'x86_64', 'mac': ['2c:c2:60:2f:a4:66'], 'pm_user': 'admin', 'cpu': '2', 'pm_addr': '10.10.10.13', 'pm_type': 'pxe_ipmitool', 'pm_password': 'redhat', 'disk': '25', 'memory': '8192'}]
psachin commented 7 years ago
psachin@nubia:[master :) ]$ python parsing_introspection_data.py instackenv.json
1: nodes
Enter one numeric value: 2
Traceback (most recent call last):
  File "parsing_introspection_data.py", line 110, in <module>
    input_validation()
  File "parsing_introspection_data.py", line 106, in input_validation
    check(int(inputvalues))
  File "parsing_introspection_data.py", line 98, in check
    if (options[input_values] == 'extra' or options[input_values] == 'inventory'):
KeyError: 2