You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@libcloud.apache.org by Alex Amies <al...@gmail.com> on 2012/07/09 07:04:01 UTC

[dev] Fwd: IBM SCE list images

Switching this to the dev thread for a fix because I did not see any
replies since last week.

Tomaž,

I get the same thing with Python 3.  I am pretty sure that it is the old
string formatting method used.  Here is what I think is the cause and fix
for the problem.

Cause
>From base.py (line 308):
class NodeImage(UuidMixin):
    def __repr__(self):
        return (('<NodeImage: id=%s, name=%s, driver=%s  ...>')
                % (self.id, self.name, self.driver.name))

Fix:
    def __repr__(self):
        return (('<NodeImage: id=%s, name=%s, driver=%s  ...>'.format(
self.id, self.name, self.driver.name)))

I tried it and it works for me. The main issue will be inconsistency with
the uses of old string format methods elsewhere in base.py and elsewhere in
the project.  I think that they are important to replace as well for
internationalization reasons.  However, it would be nice to fix it here
first because users are already hitting the problem in this case.

I am not a comitter.  I would appreciate it if someone else can commit the
code.

Thanks

Alex

---------- Forwarded message ----------
From: Claudiu Popescu <cl...@pidginhost.com>
Date: Fri, Jul 6, 2012 at 2:28 PM
Subject: Re: IBM SCE list images
To: Tomaž Muraus <to...@apache.org>
Cc: "users@libcloud.apache.org" <us...@libcloud.apache.org>


Hi Muraus,

Python 2.6.6, an it happens when I list image.name
Probably this problem is for description as well, not sure tho


On 05.07.2012, at 00:05, Tomaž Muraus <to...@apache.org> wrote:

> Hi,
>
> Some questions:
>
> 1. Which version of Python are you using?
> 2. When do you get this error? When printing a list of images?
>
> If the answer to the second question is yes, than that's probably a bug
with __repr__ method. If an object representation contains unicode
characters, Python throws an exception when you try printing this object.
>
> I will try to get fix into trunk as soon as possible.
>
> On Wed, Jul 4, 2012 at 3:29 AM, Claudiu Popescu <cl...@pidginhost.com>
wrote:
> Hi,
>
> IBM is using UTF-8 characters in it's image names and this seems to be a
> problem with libcloud/python.
> When I try to list all images I get: UnicodeEncodeError: 'ascii' codec
> can't encode character u'\u2013' in position 79: ordinal not in range(128)
> Is there a workaround for this situation?
>
> Thanks,
> Claudiu
>