unicode utf8 ...

Posted on
Sun Apr 26, 2015 11:22 am
kw123 offline
User avatar
Posts: 5599
Joined: May 12, 2013
Location: Dallas, TX

unicode utf8 ...

the following code:
Code: Select all
p = subprocess.Popen("ps -ef  | grep 'for ((i=0' | grep /usr/bin/curl | grep -v grep",shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
resp=p.communicate()[0]
indigo.server.log(resp)

In python in an indigo plugin and in a python shell launched from the indigo menu (should be both the same python version i.e. 2.6) produces different results:

in the first case I get
>>> " ....ther/grM-CM-<nTempera..."

and in the seconds case:
>>> "...ther/grünTempera..."

why is this different? and how can I get the 2. result in an indigoplugin?


I am stuck ..

Karl

Posted on
Sun Apr 26, 2015 12:10 pm
matt (support) offline
Site Admin
User avatar
Posts: 18458
Joined: Jan 27, 2003
Location: Texas

Re: unicode utf8 ...

Not so sure this will help, but try changing the 2nd line to:

resp = unicode(p.communicate()[0])

Image

Posted on
Sun Apr 26, 2015 12:28 pm
kw123 offline
User avatar
Posts: 5599
Joined: May 12, 2013
Location: Dallas, TX

Re: unicode utf8 ...

nop...

the python shell launched from indigo should have the same python environment as the plugin :?: :?: :?: Or is there any environmental difference?

it is the SAME code


Anyway .. I am switching to a unique ascii identifier for the file names


Karl

Posted on
Sun Apr 26, 2015 12:29 pm
matt (support) offline
Site Admin
User avatar
Posts: 18458
Joined: Jan 27, 2003
Location: Texas

Re: unicode utf8 ...

I'd think they would be the same, but clearly they are not. I'll look into it...

Image

Posted on
Sun Apr 26, 2015 7:22 pm
RogueProeliator offline
User avatar
Posts: 1976
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: unicode utf8 ...

in the first case I get
>>> " ....ther/grM-CM-<nTempera..."

and in the seconds case:
>>> "...ther/grünTempera..."

That somewhat looks like it could be unicode in a different or unknown encoding format... it could be that your external Python has a different default encoding that is not coming through the Indigo Python environment? Again, this is a wild shot-in-the-dark, but try explicitly setting the default encoding:

Code: Select all
sys.setdefaultencoding('UTF8')
Adam

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests