Elive

  • Status Closed
  • Percent Complete
    100%
  • Task Type Bug Report
  • Category Any
  • Assigned To
    LinuxNIT
  • Operating System All
  • Severity Medium
  • Priority Very Low
  • Reported Version 1.x Gem+ (beta's)
  • Due in Version 2.0
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: Elive
Opened by thanatermesis - 2009-08-19
Last edited by thanatermesis - 2009-09-14

FS#459 - net-connector: Connect button screwed up

Thanks to the report of DronAn[BY], aparently the connect and disconnect buttons has dissapeared, there’s a few screenshots:

http://bayimg.com/BaDfkaAcf http://bayimg.com/BADFnAacF

The reason of this is the russian language that screws something somewhere... there’s an error message found in the terminal:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

I don’t know the reason of why this affects the button and no other parts of the interface (see screenshot), but for now, since this is a very important bug (some ppl will not connect!), i have just disabled from gettext the message that broke this :) (note: the broking thing is not the button message but other element, please see the commit in this ticket comments)

Closed by  thanatermesis
14.09.2009 21:47
Reason for closing:  Fixed
Admin

Temporal fix (verified) of this problem at: http://dev.elivecd.org/changeset/1334

DronAn: Can you try translate again (remove and write it again) the sentence "Status for" on eltrans ? (section net-connector), maybe the problem is a wrong caracter from this word, do the translation and use it on your system to see if works (if im not wrong, eltrans allow you to use your own made translations, not only to send it)

Admin

The problem was NOT from net-connector, but by an automatic-translated word from my tools (after DronAn has rewrited the default word, it does works), but I don't found any way to check if the utf8 characters are correctly encoded, I don't see any error by any way that Ill try... the only way that looks like to work is just like the error showed with this python error, with UnicodeDecode, so:

try:
     unicodetext = bytestring.decode('utf-8')
     # it is very likely that bytestring is utf-8 encoded
except UnicodeDecodeException:
     # this is not UTF-8 encoded

LinuxNIT can you possible to write a very small python to do this check ? (yes, just these 4 lines), that will work in pipe mode and if the result is wrong, then return/exit with the value 1, if is OK, return/exit with the value 0. So, for include this tool on my scripts in order to do something like that:

if echo "$translated_message" | utf8-checker.py ; then
   echo "ok"
else
   remove_translated_message
fi

Note: attached examples of real buggy messages/files (see the wrong-line-example.txt more exactly where is the real line that fails)

(application/octet-stream)    utf.tgz (4.5 KiB)
Admin

Somebody has make me a small python tool to verify characters, but this tool doesn't looks like to show me any error with my tests :(

#!/usr/bin/env python



import sys

import select



def main():

   r, w, x = select.select([sys.stdin], [], [], 0)

   if r:

      # if there is, set stdin as content

      string = sys.stdin.read()

   else:

      # if filename is not set and there is nothing on stdin, make an empty entry like zenity does

      print "Nothing entered."

      sys.exit(1)



   try:

      unicodetext = string.decode('utf-8')

      print "all ok"

   except UnicodeDecodeException:

      print "error"

      sys.exit(1)



   sys.exit(0)



sys.exit(main())


commands tried:

cat "utf/wrong-line-example.txt" | python foo.py ; echo $?
0
foo="$(cat utf/wrong-line-example.txt)"
echo "$foo" | python foo.py ; echo $?
0

Update: This tool does strange random things ? sometimes it shows me "Nothing entered" message and sometimes no with the same command tried consecutively, WTF?

Admin

The same person has tell me that the code needs to have something like:

gettext.install('myapplication', '/usr/share/locale', unicode=1)

http://docs.python.org/library/gettext.html

He's the author of shellementary (python version of zenity using elementary), he uses this gettext code on it: http://trac.enlightenment.org/e/browser/trunk/PROTO/shellementary/shellementary.in

Admin

LinuxNIT: After to do a lot of changes, like changing totally the sentence to different ones, like changing the way gettext is managed in the code... I still not understanding anything, these are the actual changes to the code: http://dev.elivecd.org/changeset/1351

I have see that the problem is NOT the automated translations (DronAn has made its own translations too for this word and still the problem)

The only actual solution right now was to disable the message for translation (just like a plain text), remember that the problem looks like to be there but the visual problem is that another thing (connect/disconnect button) dissapears

Admin

DronAn[BY] has again problems with russian translations, now with other thing (maybe the same section), please contact him to do tests and stuff

Admin

Some comments from a dev of python-efl bindings:

<k-s> are you handling it as str or unicode types?
<k-s> I never touched etk too much, but the problem may come if one converts to unicode
<k-s> then it's abstract
<Thanatermesis> yes, its a problem of convert
<k-s> and whenever you need to handle it to evas (to show, used internally) or to "print thing", then it need to be codified into a proper encoding
<k-s> python defaults to "ASCII", so nothing outside that is converted... not even the basic LATIN1!
<Thanatermesis> <DronAn[BY]> UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 20: ordinal not in range(128)
<Thanatermesis> that's an error example
<k-s> exactly
<k-s> now you need to know if this is in python-etk or your code
<k-s> the solution is always to check the type and if unicode then convert to str using utf-8
<k-s> example:
<k-s> print "%r" % (thing,)
<k-s> or
<k-s> print repr(thing)
<k-s> if it shows: "bla", then it's string
<k-s> if it shows: u"bla", then it's unicode
<k-s> if unicode, then: thing.encode("utf-8") will fix it
<k-s> but if thing is str already, it will convert to unicode then str! probably breaking stuff
<k-s> need to know what gettext returns
<k-s> i did not touch gettext in python for ages, I can't remember
<k-s> probably there is a way to configure if you want it str or unicode
<k-s> man, I have problems with unicode/str in python since 2002 :-)
<k-s> 7 years for now :-)
<k-s> it brings me nightmares...
<Thanatermesis> that not sounds very promissing lol
<k-s> ehehe
<k-s> it's simple
<k-s> but easy to get wrong
<k-s> it is analogous to convert between double and int
<k-s> you just believe it will work
<Thanatermesis> heh
<k-s> until you handle a double and int switched into "printf", then va_args() reads wrongly and your stack is messed
<k-s> but at least python brings you some facilities, like traceback
<k-s> you need to know at the traceback time what is str and what is unicode
<Thanatermesis> http://debian.pastebin.com/m471f15f7 
<k-s> in the comments people are telling you to convert to unicode
<k-s> but if the problem is really with etk, then it's the oposite
<k-s> what is "status" there?
<k-s> in that line: status=status+"<font color=#a6a6a6>"+_("Device")+" "+item+":            \n"+self.interfaces_info[item]["state"]+"</>\n\n"
<k-s> just print out repr(XXXX) for XXXX being every variable
<k-s> like print repr(status)
<k-s> print repr(_("Device")
<k-s> print repr(+self.interfaces_info[item]["state"])
<k-s> print those and send to me
<Thanatermesis> mmh, let me see
<k-s> the thing is, you're doing dbus
<k-s> and dbus strings by default are converted to unicode AFAIR
<k-s> so maybe you're looking into the wrong bug source
<k-s> not the _("Device:"), but the incomming strings
<k-s> possibly self.interfaces_info[item]["state"]
Date User Effort (H:M) Comment
watch my effort tracking timers

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing