hello,
I am very new to python scripting and would require some help. Thers a product
called Ajaxterm which makes use of python scripts and Ajax that I am using. It's a web based unix terminal emulator. I have set this up to work correctly. But there are some unicode related issues thats coming when using this product.
Let me elaborate much on this product for better understanding. this product makes python to interact with the Unix os, takes the output, generates an xml and displays it on a webpage by making use of ajax. so, to use this product we need to run a python file which acts as the server and a user can use http//myserver:myport from a client machine and access the unix box.
This is what I am trying to do: After logging in with my user id, I am trying to do a database login in my unix box. when i use putty, the login screen comes up as the pic1 in the attachment (Expected). but, when i use the terminal emulator (ajaxterm), it comes up like in the pics (Actual).
I have pinpointed to the code where this happens. the code is:
t=(self.proc[fd]['term'])
str= os.read(fd,65536)
t.write(str)
As far as i understood, 't' makes an instance of the current terminal, 'str' contains the reply that the python script takes from the unix os to pass it to the web terminal. till now, 'str' would still give me the wrong line drawing character (checked by printing str on the console)
but, I changed the code for 'str' to the following
str= unicode(os.read(fd,65536), "UTF-8")
and could see that 'str' prints the proper unicode line drawing characters as expected on the console.
the line 3 in the original code makes the 'str' to write to the webterminal. but, when i print 't'
on the console, it does still have the incorrect line drawing characters ('t' finally gets printed on the web console).
What am i doing wrong? I assume that 'str' automatically gets changed to the encoding that 't' is using when 't.write(str)' is encountered. I tried doing a
reload(sys)
sys.setdefaultencoding('UTF-8')
in the python code and i could see that prining the defaultencoding is giving me 'UTF-8'.
I am not sure what I am doing wrong. maybe i am not understanding what exactly
the lines
t=(self.proc[fd]) and t.write(str) does or how i could manipulate it to make it work as expected. I tried to seach on this on the web, but didnt get much of help.
Sorry for the long description, but I'd really appreciate if anyone could help me on this.
Thank you.