Re: [Openstack-operators] python and nice utf ö ü :)

2016-08-31 Thread Saverio Proto
Yes it worked !
I pushed a new patchset, thank you !

https://review.openstack.org/361308

Saverio

2016-08-31 15:25 GMT+02:00 Matt Jarvis :
> I'm no python guru, but if you're getting unicode output from the python
> openstack tools then don't you want to prepend your strings with u in the
> print statements ?
>
> On 31 August 2016 at 14:03, Saverio Proto  wrote:
>>
>> Oh,
>> to stick with the subject of the email you can also call the instance
>> for example
>>
>> füöô
>>
>> and this will trigger the bug anyway :)
>>
>> Saverio
>>
>>
>>
>>
>> 2016-08-31 14:54 GMT+02:00 Saverio Proto :
>> > Hello Matt,
>> >
>> > I am sorry, I realize now I sent a very dumb email :) I will try to
>> > explain my self better.
>> >
>> > The script fails to print some resources. To reproduce the bug do the
>> > following,
>> >
>> > Create a instance and name it:
>> >
>> > آشپزی ایتالیایی
>> >
>> > then just call
>> >
>> > python user-info.py 
>> >
>> > (of course the username is the one that created the instance)
>> >
>> > this will print all the instances, including the one with the
>> > problematic name. Of course you will get an Error. It will raise an
>> > exception and will fail.
>> >
>> > the patch I proposed shows how to get a traceback that makes sense,
>> > you will get something like:
>> >
>> > UnicodeEncodeError: 'ascii' codec can't encode characters in position
>> > 0-3: ordinal not in range(128)
>> >
>> >
>> > Adding this two lines:
>> > reload(sys)
>> > sys.setdefaultencoding("utf-8")
>> >
>> > fixes the problem, I dont have anymore the exception
>> > UnicodeEncodeError and I see printed:
>> >
>> > Server: نواع-پاستاها-و-طرز-ط [3f26242c-440b-4a2e-b3ca-cb6c6c7ee8b2] -
>> > ACTIVE
>> >
>> > But on stackoverflow people say that these two lines I added are bad,
>> > so what should I do ? :)
>> >
>> > thank you !
>> >
>> > Saverio
>> >
>> >
>> >
>> > 2016-08-31 14:13 GMT+02:00 Matt Jarvis :
>> >> What was your problem to start with ?
>> >>
>> >> On 31 August 2016 at 12:56, Saverio Proto  wrote:
>> >>>
>> >>> Hello ops,
>> >>>
>> >>> this patch fixed my problem:
>> >>>
>> >>> https://review.openstack.org/#/c/361308/
>> >>>
>> >>> but it is an ugly hack according to:
>> >>>
>> >>>
>> >>>
>> >>> http://stackoverflow.com/questions/3828723/why-should-we-not-use-sys-setdefaultencodingutf-8-in-a-py-script
>> >>>
>> >>> anyone knows how to make it better ?
>> >>>
>> >>> Saverio
>> >>>
>> >>> ___
>> >>> OpenStack-operators mailing list
>> >>> OpenStack-operators@lists.openstack.org
>> >>>
>> >>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-operators
>> >>
>> >>
>> >>
>> >> DataCentred Limited registered in England and Wales no. 05611763
>
>
>
> DataCentred Limited registered in England and Wales no. 05611763

___
OpenStack-operators mailing list
OpenStack-operators@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-operators


Re: [Openstack-operators] python and nice utf ö ü :)

2016-08-31 Thread Matt Jarvis
I'm no python guru, but if you're getting unicode output from the python
openstack tools then don't you want to prepend your strings with u in the
print statements ?

On 31 August 2016 at 14:03, Saverio Proto  wrote:

> Oh,
> to stick with the subject of the email you can also call the instance
> for example
>
> füöô
>
> and this will trigger the bug anyway :)
>
> Saverio
>
>
>
>
> 2016-08-31 14:54 GMT+02:00 Saverio Proto :
> > Hello Matt,
> >
> > I am sorry, I realize now I sent a very dumb email :) I will try to
> > explain my self better.
> >
> > The script fails to print some resources. To reproduce the bug do the
> following,
> >
> > Create a instance and name it:
> >
> > آشپزی ایتالیایی
> >
> > then just call
> >
> > python user-info.py 
> >
> > (of course the username is the one that created the instance)
> >
> > this will print all the instances, including the one with the
> > problematic name. Of course you will get an Error. It will raise an
> > exception and will fail.
> >
> > the patch I proposed shows how to get a traceback that makes sense,
> > you will get something like:
> >
> > UnicodeEncodeError: 'ascii' codec can't encode characters in position
> > 0-3: ordinal not in range(128)
> >
> >
> > Adding this two lines:
> > reload(sys)
> > sys.setdefaultencoding("utf-8")
> >
> > fixes the problem, I dont have anymore the exception
> > UnicodeEncodeError and I see printed:
> >
> > Server: نواع-پاستاها-و-طرز-ط [3f26242c-440b-4a2e-b3ca-cb6c6c7ee8b2] -
> ACTIVE
> >
> > But on stackoverflow people say that these two lines I added are bad,
> > so what should I do ? :)
> >
> > thank you !
> >
> > Saverio
> >
> >
> >
> > 2016-08-31 14:13 GMT+02:00 Matt Jarvis :
> >> What was your problem to start with ?
> >>
> >> On 31 August 2016 at 12:56, Saverio Proto  wrote:
> >>>
> >>> Hello ops,
> >>>
> >>> this patch fixed my problem:
> >>>
> >>> https://review.openstack.org/#/c/361308/
> >>>
> >>> but it is an ugly hack according to:
> >>>
> >>>
> >>> http://stackoverflow.com/questions/3828723/why-should-we-not-use-sys-
> setdefaultencodingutf-8-in-a-py-script
> >>>
> >>> anyone knows how to make it better ?
> >>>
> >>> Saverio
> >>>
> >>> ___
> >>> OpenStack-operators mailing list
> >>> OpenStack-operators@lists.openstack.org
> >>> http://lists.openstack.org/cgi-bin/mailman/listinfo/
> openstack-operators
> >>
> >>
> >>
> >> DataCentred Limited registered in England and Wales no. 05611763
>

-- 
DataCentred Limited registered in England and Wales no. 05611763
___
OpenStack-operators mailing list
OpenStack-operators@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-operators


Re: [Openstack-operators] python and nice utf ö ü :)

2016-08-31 Thread Saverio Proto
Oh,
to stick with the subject of the email you can also call the instance
for example

füöô

and this will trigger the bug anyway :)

Saverio




2016-08-31 14:54 GMT+02:00 Saverio Proto :
> Hello Matt,
>
> I am sorry, I realize now I sent a very dumb email :) I will try to
> explain my self better.
>
> The script fails to print some resources. To reproduce the bug do the 
> following,
>
> Create a instance and name it:
>
> آشپزی ایتالیایی
>
> then just call
>
> python user-info.py 
>
> (of course the username is the one that created the instance)
>
> this will print all the instances, including the one with the
> problematic name. Of course you will get an Error. It will raise an
> exception and will fail.
>
> the patch I proposed shows how to get a traceback that makes sense,
> you will get something like:
>
> UnicodeEncodeError: 'ascii' codec can't encode characters in position
> 0-3: ordinal not in range(128)
>
>
> Adding this two lines:
> reload(sys)
> sys.setdefaultencoding("utf-8")
>
> fixes the problem, I dont have anymore the exception
> UnicodeEncodeError and I see printed:
>
> Server: نواع-پاستاها-و-طرز-ط [3f26242c-440b-4a2e-b3ca-cb6c6c7ee8b2] - ACTIVE
>
> But on stackoverflow people say that these two lines I added are bad,
> so what should I do ? :)
>
> thank you !
>
> Saverio
>
>
>
> 2016-08-31 14:13 GMT+02:00 Matt Jarvis :
>> What was your problem to start with ?
>>
>> On 31 August 2016 at 12:56, Saverio Proto  wrote:
>>>
>>> Hello ops,
>>>
>>> this patch fixed my problem:
>>>
>>> https://review.openstack.org/#/c/361308/
>>>
>>> but it is an ugly hack according to:
>>>
>>>
>>> http://stackoverflow.com/questions/3828723/why-should-we-not-use-sys-setdefaultencodingutf-8-in-a-py-script
>>>
>>> anyone knows how to make it better ?
>>>
>>> Saverio
>>>
>>> ___
>>> OpenStack-operators mailing list
>>> OpenStack-operators@lists.openstack.org
>>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-operators
>>
>>
>>
>> DataCentred Limited registered in England and Wales no. 05611763

___
OpenStack-operators mailing list
OpenStack-operators@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-operators


Re: [Openstack-operators] python and nice utf ö ü :)

2016-08-31 Thread Saverio Proto
Hello Matt,

I am sorry, I realize now I sent a very dumb email :) I will try to
explain my self better.

The script fails to print some resources. To reproduce the bug do the following,

Create a instance and name it:

آشپزی ایتالیایی

then just call

python user-info.py 

(of course the username is the one that created the instance)

this will print all the instances, including the one with the
problematic name. Of course you will get an Error. It will raise an
exception and will fail.

the patch I proposed shows how to get a traceback that makes sense,
you will get something like:

UnicodeEncodeError: 'ascii' codec can't encode characters in position
0-3: ordinal not in range(128)


Adding this two lines:
reload(sys)
sys.setdefaultencoding("utf-8")

fixes the problem, I dont have anymore the exception
UnicodeEncodeError and I see printed:

Server: نواع-پاستاها-و-طرز-ط [3f26242c-440b-4a2e-b3ca-cb6c6c7ee8b2] - ACTIVE

But on stackoverflow people say that these two lines I added are bad,
so what should I do ? :)

thank you !

Saverio



2016-08-31 14:13 GMT+02:00 Matt Jarvis :
> What was your problem to start with ?
>
> On 31 August 2016 at 12:56, Saverio Proto  wrote:
>>
>> Hello ops,
>>
>> this patch fixed my problem:
>>
>> https://review.openstack.org/#/c/361308/
>>
>> but it is an ugly hack according to:
>>
>>
>> http://stackoverflow.com/questions/3828723/why-should-we-not-use-sys-setdefaultencodingutf-8-in-a-py-script
>>
>> anyone knows how to make it better ?
>>
>> Saverio
>>
>> ___
>> OpenStack-operators mailing list
>> OpenStack-operators@lists.openstack.org
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-operators
>
>
>
> DataCentred Limited registered in England and Wales no. 05611763

___
OpenStack-operators mailing list
OpenStack-operators@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-operators


Re: [Openstack-operators] python and nice utf ö ü :)

2016-08-31 Thread Matt Jarvis
What was your problem to start with ?

On 31 August 2016 at 12:56, Saverio Proto  wrote:

> Hello ops,
>
> this patch fixed my problem:
>
> https://review.openstack.org/#/c/361308/
>
> but it is an ugly hack according to:
>
> http://stackoverflow.com/questions/3828723/why-should-we-not-use-sys-
> setdefaultencodingutf-8-in-a-py-script
>
> anyone knows how to make it better ?
>
> Saverio
>
> ___
> OpenStack-operators mailing list
> OpenStack-operators@lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-operators
>

-- 
DataCentred Limited registered in England and Wales no. 05611763
___
OpenStack-operators mailing list
OpenStack-operators@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-operators