Page 1 of 1

national special characters in username (vista64) fail for sabnzbd 4.11

Posted: July 8th, 2009, 6:27 pm
by guru1968
Hello...
I am from Germany and my name is "Jörg", so my Profile-dirs (Vista64) start with 'C:\\Users\\Jörg'
this special character 'ö' makes SABnzbd 4.11 fail to show the config page because the treatment of special characters in the GetProfileInfo function is wrong:
first bug: the 8bit ASCII conversion needed for CherryPy is only done when the Get_User_ShellFolders() failed - it must be done in any case, because this function also could have delivered UNICODE character(s) necessary to be converted...
second bug: when all failed, win32api.GetShortPathName() is called, BUT: with DEF_WORKDIR already appended - that function only works for existing pathnames, so when this directory doesn't exist yet (first call after installation) it fails!

here's how I changed it to work at least for me:

    elif os.name == 'nt':
        specials = Get_User_ShellFolders()
        try:
            sabnzbd.DIR_APPDATA = '%s' % specials['AppData']
            sabnzbd.DIR_LCLDATA = '%s' % specials['Local AppData']
            sabnzbd.DIR_HOME = specials['Personal']
        except:
            try:
                if vista:
                    root = os.environ['AppData']
                    user = os.environ['USERPROFILE']
                    sabnzbd.DIR_APPDATA = '%s' % root.replace('\\Roaming', '\\Local')
                    sabnzbd.DIR_HOME    = '%s\\Documents' % user
                else:
                    root = os.environ['USERPROFILE']
                    sabnzbd.DIR_APPDATA = '%s' % root
                    sabnzbd.DIR_HOME = root

            except:
                pass

        try:
            # Conversion to 8bit ASCII required for CherryPy
            sabnzbd.DIR_APPDATA = sabnzbd.DIR_APPDATA.encode('latin-1')
            sabnzbd.DIR_HOME = sabnzbd.DIR_HOME.encode('latin-1')
            ok = True
        except:
            # If unconvertible characters exist, use MSDOS name
            try:
                sabnzbd.DIR_APPDATA = win32api.GetShortPathName(sabnzbd.DIR_APPDATA)
                sabnzbd.DIR_HOME = win32api.GetShortPathName(sabnzbd.DIR_HOME)
                ok = True
            except:
                pass
        sabnzbd.DIR_APPDATA = '%s\\%s' % (sabnzbd.DIR_APPDATA, DEF_WORKDIR.encode('latin-1'))
        sabnzbd.DIR_HOME = '%s\\%s' % (sabnzbd.DIR_HOME, DEF_WORKDIR.encode('latin-1'))
        sabnzbd.DIR_LCLDATA = sabnzbd.DIR_APPDATA

Re: national special characters in username (vista64) fail for sabnzbd 4.11

Posted: July 9th, 2009, 1:23 am
by shypike
Looks like sensible changes, will take that up asap.
Thanks.

The odd things is that we did test with accented characters in profile names.
An error must have crept in later.

One day (when enough third-party modules have been ported) we'll switch to
Python 3 and create a full Unicode app.

Re: national special characters in username (vista64) fail for sabnzbd 4.11

Posted: July 10th, 2009, 4:33 am
by shypike
A work-around is to use the -f parameter.
Modify the shortcut to SABnzbd to read:

Code: Select all

"c:\program files\SAbnzbd\SABnzbd.exe -f c:\users\ORG~1\sabnzbd.ini
The "ORG~1" part is the 8.3 limited part of the path that you will see
when you type this in a command prompt:

Code: Select all

dir /x c:\users
It could be slightly different.

Re: national special characters in username (vista64) fail for sabnzbd 4.11

Posted: July 14th, 2009, 3:44 pm
by shypike
guru1968 wrote: first bug: the 8bit ASCII conversion needed for CherryPy is only done when the Get_User_ShellFolders() failed - it must be done in any case, because this function also could have delivered UNICODE character(s) necessary to be converted...
second bug: when all failed, win32api.GetShortPathName() is called, BUT: with DEF_WORKDIR already appended - that function only works for existing pathnames, so when this directory doesn't exist yet (first call after installation) it fails!
The first bug does not exist.
The function Get_User_ShellFolders() always returns 8bit ASCII strings, the 'latin-1' conversion is already done there.

The second bug is real, so this must be the one you're bitten by.
The odd thing is that the 'ö' should be encodable in 8bit ASCII, unless you chose a different representation that can only be encoded in Unicode.
Does SABnzbd show short paths in Config->General?

Re: national special characters in username (vista64) fail for sabnzbd 4.11

Posted: July 14th, 2009, 4:14 pm
by shypike
Actually when I test on Vista with account names "Jörg" and "€uro", its works fine.
"Jörg" works fine and it shows properly in Config.
"€uro" cannot be converted to 8bit ASCII and therefore shows up in Config as "C:\Users\URO~1\...".
Neither account name makes SABnzbd fail.

Which codepage do you use on your system and how is the "ö" encoded?
Has it been entered using Alt-0246?