softlayer-python icon indicating copy to clipboard operation
softlayer-python copied to clipboard

call-api Formatting issues

Open allmightyspiff opened this issue 3 years ago • 1 comments

$ ./slcli -vvv --format=json call-api SoftLayer_Account getNasNetworkStorage --mask="mask[id,replicatingVolume,replicationPartners]"
Calling: SoftLayer_Account::getNasNetworkStorage(id=None, mask='mask[id,replicatingVolume,replicationPartners]', filter='{}', args=(), limit=None, offset=None))
Starting new HTTPS connection (1): api.softlayer.com:443
https://api.softlayer.com:443 "GET /rest/v3.1/SoftLayer_Account/getNasNetworkStorage.json?objectMask=mask%5Bid%2CreplicatingVolume%2CreplicationPartners%5D HTTP/1.1" 200 797
Returned Data:
[{'id': 4917309, 'replicationPartners': [{'id': 21021427, 'replicatingVolume': None, 'replicationPartners': []}]}, {'id': 22031701, 'replicationPartners': []}, {'id': 48489025, 'replicationPartners': []}, {'id': 121100770, 'replicationPartners': []}, {'id': 122113170, 'replicationPartners': []}, {'id': 133441542, 'replicationPartners': []}, {'id': 133453202, 'replicationPartners': []}, {'id': 133483212, 'replicationPartners': []}, {'id': 133593224, 'replicationPartners': []}, {'id': 183422848, 'replicationPartners': []}, {'id': 183434028, 'replicationPartners': []}, {'id': 183443408, 'replicationPartners': []}, {'id': 183463032, 'replicationPartners': []}, {'id': 21021427, 'replicatingVolume': {'id': 4917309, 'replicationPartners': [None]}, 'replicationPartners': []}, {'id': 250707946, 'replicationPartners': []}, {'id': 147860452, 'replicationPartners': []}]
An unexpected error has occured:
Traceback (most recent call last):
  File "C:\Users\allmi\Source\softlayer-python\SoftLayer\CLI\core.py", line 182, in main
    cli.main(**kwargs)
  File "C:\Users\allmi\Source\py38\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\allmi\Source\py38\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\allmi\Source\py38\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\allmi\Source\py38\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\allmi\Source\py38\lib\site-packages\click\decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "C:\Users\allmi\Source\py38\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\allmi\Source\softlayer-python\SoftLayer\CLI\call_api.py", line 178, in cli
    env.fout(formatting.iter_to_table(result))
  File "C:\Users\allmi\Source\softlayer-python\SoftLayer\CLI\formatting.py", line 384, in iter_to_table
    return _format_list(value)
  File "C:\Users\allmi\Source\softlayer-python\SoftLayer\CLI\formatting.py", line 413, in _format_list
    return _format_list_objects(new_result)
  File "C:\Users\allmi\Source\softlayer-python\SoftLayer\CLI\formatting.py", line 437, in _format_list_objects
    value = iter_to_table(item.get(key))
  File "C:\Users\allmi\Source\softlayer-python\SoftLayer\CLI\formatting.py", line 386, in iter_to_table
    return _format_dict(value)
  File "C:\Users\allmi\Source\softlayer-python\SoftLayer\CLI\formatting.py", line 398, in _format_dict
    value = iter_to_table(value)
  File "C:\Users\allmi\Source\softlayer-python\SoftLayer\CLI\formatting.py", line 384, in iter_to_table
    return _format_list(value)
  File "C:\Users\allmi\Source\softlayer-python\SoftLayer\CLI\formatting.py", line 412, in _format_list
    if isinstance(new_result[0], dict):
IndexError: list index out of range

Feel free to report this error as it is likely a bug:
    https://github.com/softlayer/softlayer-python/issues
The following snippet should be able to reproduce the error

allmightyspiff avatar Aug 05 '22 16:08 allmightyspiff

I couldn't reproduce the problem, this is my result. image

But I found other issue in this command: slcli -vvv call-api SoftLayer_Account getNasNetworkStorage --mask="mask[id,replicatingVolume,replicationPartners]"

image

caberos avatar Aug 10 '22 15:08 caberos

Hi @allmightyspiff,

When I executed this command: ./slcli -vvv --format=json call-api SoftLayer_Account getNasNetworkStorage --mask="mask[id,replicatingVolume,replicationPartners]"

it seems to be fine, no issues.

Screen Shot: Screenshot 2023-06-21 at 1 12 39 PM

When I executed this command: slcli -vvv call-api SoftLayer_Account getNasNetworkStorage --mask="mask[id,replicatingVolume,replicationPartners]"

it seems to be fine, no issues.

Screen Shot: Screenshot 2023-06-21 at 1 17 03 PM

Please review it.

Thanks, Ramkishor Chaladi.

ramkishor-ch avatar Jun 26 '23 11:06 ramkishor-ch

Looks like this isn't a bug anymore, closing

allmightyspiff avatar Jun 26 '23 14:06 allmightyspiff