ifosch / accloudtant

AWS cost calculator
59 stars 19 forks source link

Fails with Python 3 #79

Closed xsb closed 8 years ago

xsb commented 8 years ago

My system have Python 3 installed by default (Archlinux). This is the output of accloudtant report:

Traceback (most recent call last):
  File "/usr/bin/accloudtant", line 22, in <module>
    cli()
  File "/usr/lib/python3.5/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.5/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.5/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3.5/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.5/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/bin/accloudtant", line 19, in report
    click.echo(Reports())
  File "/usr/lib/python3.5/site-packages/click/utils.py", line 221, in echo
    message = text_type(message)
  File "/usr/lib/python3.5/site-packages/accloudtant/aws/reports.py", line 69, in __repr__
    instance.name,
  File "/usr/lib/python3.5/site-packages/accloudtant/aws/instance.py", line 68, in name
    return names[0]['Value']
IndexError: list index out of range

I can't verify that it works well on Python 2 so fell free to close this issue and open a new one if the problem is not caused by the Python version.

ifosch commented 8 years ago

I think this is not related with Python version, but a bug located in https://github.com/ifosch/accloudtant/blob/master/accloudtant/aws/instance.py#L65 where names is not None but an empty list ([]), which doesn't have the first element. Could this happen because you have some unnamed instances?

xsb commented 8 years ago

@ifosch exactly, we don't add names to instances inside autoscaling groups.