[XBOX] T3CH Upgrader (Python Script)

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
blittan Offline
Team-XBMC Handyman
Posts: 1,739
Joined: Jun 2004
Reputation: 11
Location: Sweden
Post: #16
jmarshall: potential risk there, but then again, whatever you do with bootstuff might break.. wont say its safe to do anything, but agree it would be made optional.


BBB: think you need to change the fileformat to UTF-8 for it to work..

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
If you don't have the time to read them, please don't take the time to post in this forum!
For troubleshooting and bug reporting please make sure you read this first.
find quote
BigBellyBilly Offline
Skilled Python Coder
Posts: 900
Joined: Feb 2005
Reputation: 2
Location: UK
Post: #17
blitten: the XML file does already have encoding="utf-8" Is that what you meant ?


In the language.py I've added this function:

Code:
def unicodeToAscii(txt, charset='utf8'):
    print "unicodeToAscii()"
    try:
        newtxt = txt.decode(charset)
        newtxt = unicodedata.normalize('NFKD', newtxt).encode('ASCII','replace')
        return newtxt
    except:
        print "unicodeToAscii() except"
        traceback.print_exc()
        return txt

and changed the language.py to load the doc throu it:

Code:
uni_doc = unicodeToAscii( file(language_path).read(), charset='latin-1' )
doc = xml.dom.minidom.parseString( uni_doc )
Now it does read the file, but substitutes accented chars with '?' (cos of the enocde replace)

Is there a better way ?

My Addons (myTV, T3CH Upgrader, DVDProfiler, BBCPodRadio, Comics, Football, GoogleReader, reeplay.it, Metacritic, Phonebin, FileViewer,SVN Repo Installer (contributor)) available at Box.net
find quote
BigBellyBilly Offline
Skilled Python Coder
Posts: 900
Joined: Feb 2005
Reputation: 2
Location: UK
Post: #18
I've amended the shortcut creation to now create both _old and _new

Then prompts user if they wish to Switch to new, only if they choose to is the new copied to the bootable shortcut name.

Some new msgs as a result, could you translate these for me, then I'll post the amended code up here.

<string id="404">Switch</string>
<string id="405">Manual</string>


<string id="507">Copy existing data to T3CH ?</string>


<string id="519">_NEW and _OLD Shortcuts Created.</string>
<string id="520">_Switch to it NEW Now ?</string>
<string id="521">(Manual rename required otherwise)</string>


Thanks

My Addons (myTV, T3CH Upgrader, DVDProfiler, BBCPodRadio, Comics, Football, GoogleReader, reeplay.it, Metacritic, Phonebin, FileViewer,SVN Repo Installer (contributor)) available at Box.net
find quote
matthuisman Offline
Skilled Python Coder
Posts: 597
Joined: Sep 2006
Reputation: 4
Location: Chch, New Zealand
Post: #19
try this:

XML

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<string id="10">Päävalikko</string> #this is finnish not swedish tho
etc etc.

return yourstring.decode("utf-8")

i find doing this for english does funny things tho.
So i added:

if self.language == "swedish":
return yourstring.decode("utf-8")
find quote
Nuka1195 Offline
Skilled Python Coder
Posts: 3,910
Joined: Dec 2004
Reputation: 18
Post: #20
BBB, blittans new file imports fine. make sure you saved it as utf-8 and not utf-8 cookie if your editor has that.

Also make sure you don't print or output to a device that only supports ascii, like xbmc debug window, with any of those characters in it.

And you can take my name out of the script and language file, but thanks for the mention.

I'll wait for your pm, but you could put other scripts in svn too, so if you want added. let me know.

Stanley, that decode() should not be necessary unless your doing as I said and outputting language strings to the debug window.

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
blittan Offline
Team-XBMC Handyman
Posts: 1,739
Joined: Jun 2004
Reputation: 11
Location: Sweden
Post: #21
BigBellyBilly Wrote:I've amended the shortcut creation to now create both _old and _new

Then prompts user if they wish to Switch to new, only if they choose to is the new copied to the bootable shortcut name.

Some new msgs as a result, could you translate these for me, then I'll post the amended code up here.

<string id="404">Byt</string>
<string id="405">Manuellt</string>

<string id="507">Kopiera existerande data till T3CH ?</string>

<string id="519">_NEW and _OLD genvägar skapade.</string>
<string id="520">_Byt till NEW genväg nu ?</string>
<string id="521">(Manuell omdöpning krävs annars)</string>


Thanks

There you go (Där har du *translated too*) Wink

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
If you don't have the time to read them, please don't take the time to post in this forum!
For troubleshooting and bug reporting please make sure you read this first.
find quote
BigBellyBilly Offline
Skilled Python Coder
Posts: 900
Joined: Feb 2005
Reputation: 2
Location: UK
Post: #22
Tweaked v1.0 b9 from HERE

Changes are:
Swedish language updated by Blitten
Finnish language updated by mikko70
(I hope the translations don't read 'I like shaggin sheep!' )

New shortcut now written to c:\<dash_name>.cfg_new instead of directly over current shortcut.
Then user prompted if they wish to switch. If they do, shortcut copied from .cfg_new to .cfg otherwise user will have to ftp in and rename it.

Slight mod to language.py for as it was throwing an exception with some accented chars. Unfortunately this encoding causes the accented chars to be replaced with '?' It was either that or the minidom parser threw an exception. If you know of a better solution, please let me know (or better still send a working mod)

A couple of other minor changes.

Seems quite stable now. Unless something creeps out over the weekend, then I'll ask Nuka to help me with submitting to SVN.

My Addons (myTV, T3CH Upgrader, DVDProfiler, BBCPodRadio, Comics, Football, GoogleReader, reeplay.it, Metacritic, Phonebin, FileViewer,SVN Repo Installer (contributor)) available at Box.net
find quote
Nuka1195 Offline
Skilled Python Coder
Posts: 3,910
Joined: Dec 2004
Reputation: 18
Post: #23
Nuka1195 Wrote:BBB, blittans new file imports fine. make sure you saved it as utf-8 and not utf-8 cookie if your editor has that.

Also make sure you don't print or output to a device that only supports ascii, like xbmc debug window, with any of those characters in it.

And you can take my name out of the script and language file, but thanks for the mention.

I'll wait for your pm, but you could put other scripts in svn too, so if you want added. let me know.

Stanley, that decode() should not be necessary unless your doing as I said and outputting language strings to the debug window.

As i stated already.

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
BigBellyBilly Offline
Skilled Python Coder
Posts: 900
Joined: Feb 2005
Reputation: 2
Location: UK
Post: #24
sorry I didnt seem to get notification of your post, so I missed a few.

Editor: I guess that wouldnt include Notepad then !? can you recommend a suitable one ?

thanks

My Addons (myTV, T3CH Upgrader, DVDProfiler, BBCPodRadio, Comics, Football, GoogleReader, reeplay.it, Metacritic, Phonebin, FileViewer,SVN Repo Installer (contributor)) available at Box.net
(This post was last modified: 2007-10-27 00:35 by BigBellyBilly.)
find quote
CrazyIvan Offline
Senior Member
Posts: 159
Joined: Dec 2004
Reputation: 0
Post: #25
BigBellyBilly Wrote:Editor: I guess that wouldnt include Notepad then !? can you recommend a suitable one ?
thanks

http://notepad-plus.sourceforge.net/uk/site.htm

cheers,

crazyivan
find quote
Nuka1195 Offline
Skilled Python Coder
Posts: 3,910
Joined: Dec 2004
Reputation: 18
Post: #26
you use windows notepad? for editing scripts?

If you do grab scite, i have an updated version that colors all xbmc, xbmcgui and xbmcplugin methods their own color. Plus most python keywords are highlighted.

Let me know if you want to use it and i can post the updates.

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
matthuisman Offline
Skilled Python Coder
Posts: 597
Joined: Sep 2006
Reputation: 4
Location: Chch, New Zealand
Post: #27
Without that .decode, it shows in-correct characters in list items and labels etc :-(

Actually, scrap that - I changed my language file over to your one (nuka1195) in xbmc lyrics and works great.
This might solve all those bloody language issues i had :-D

Oh, permission to use your language class? credit of course!
(This post was last modified: 2007-10-27 06:57 by matthuisman.)
find quote
mikko70 Offline
Member
Posts: 80
Joined: Mar 2007
Reputation: 0
Post: #28
Both Finnish and Swedish strings is saved ansi format.
Strings need save UTF-8 format, then works right.
find quote
BigBellyBilly Offline
Skilled Python Coder
Posts: 900
Joined: Feb 2005
Reputation: 2
Location: UK
Post: #29
no, just notepad for editing the xml. I use Pythonwin IDE for scripts

I downloaded blitten language xml file from pastebin and ftp'd it over without it touching an editor, and it still caused the parser to throw an exception. removing the accents and it was ok.

I'll grab that editor and try again.

My Addons (myTV, T3CH Upgrader, DVDProfiler, BBCPodRadio, Comics, Football, GoogleReader, reeplay.it, Metacritic, Phonebin, FileViewer,SVN Repo Installer (contributor)) available at Box.net
(This post was last modified: 2007-10-27 09:48 by BigBellyBilly.)
find quote
BigBellyBilly Offline
Skilled Python Coder
Posts: 900
Joined: Feb 2005
Reputation: 2
Location: UK
Post: #30
ok. I installed scite
Loaded Swedish xml and changed encoding to utf-8 (not cookie) and saved.
Using Filezilla, ftp'd it and an original unmodified language.py to xbmc and I still got this exception in the log:

ERROR: Language file Q:\scripts\T3CH Upgrader\resources\language\swedish\strings.xml can't be parsed!

?

My Addons (myTV, T3CH Upgrader, DVDProfiler, BBCPodRadio, Comics, Football, GoogleReader, reeplay.it, Metacritic, Phonebin, FileViewer,SVN Repo Installer (contributor)) available at Box.net
find quote
Post Reply