quixey / python-aliyun

Python API client for Aliyun, the Alibaba Cloud.
Apache License 2.0
37 stars 24 forks source link

describe_images() doesn't work for me ? #21

Open wzymaster opened 9 years ago

wzymaster commented 9 years ago

I have successfully created ECS connection with 'cn-beijing' and all other functions work fine, like create_and_start_instance(), stop_instance(), delete_instance() , etc.

However, it always failed to list all images and here is what I get :

_conn.describe_images() [Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'ascii' codec can't encode character u'\u4f4d' in position 119: ordinal not in range(128)

Can you help with it ?

heikkiquixey commented 9 years ago

Unfortunately the package isn't playing well with non-ASCII strings. Creating and deleting instances seems to work, luckily, but anytime there is any string building or displaying it is likely to blow up due to non-ASCII characters in some field.

wzymaster commented 9 years ago

@heikkiquixey any work around to let me get list of all available images ?

heikkiquixey commented 9 years ago

I don't think I have needed to do that yet, so I don't know. You might want to see where exactly in the code it is blowing up and then you should be able to convert the strings properly (rather than just assuming str() or unicode() will work).

addumb commented 9 years ago

Mebbe something like this?

imgs = _conn.describe_images()
for i in imgs: print i.name

The method grabs the objects from the API, it can't __repr__() them to the interactive interpreter UI, though...

addumb commented 9 years ago

This can work if the bad strings are printed out to a console rather than the interactive terminal I think. I no longer have access credentials, so it's a little more difficult for me to troubleshoot this.