On Sat, Aug 15, 2009 at 11:18 AM, fruity<[email protected]> wrote: > Hi everyone,
Hello, glad you are trying out washtub > This is not my code, but the code of washtub the liquidsoap controller > made with django so for I've mailed both ML, django and liquidsoap I write that, so hopefully I can help. > I have a directory full of any kind of files, some of this filenames are > in latin1 and when I run my django app I get UnicodeDecodeError like this > > Request Method: GET > Request URL: http://myhost/washtub/mediapool/scan > Exception Type: DjangoUnicodeDecodeError > Exception Value: > > ('utf8', '/MUSIC/bettie/music2/Buena Vista Social Club - Veinte > A\xf1os.mp3', 73, 77, 'invalid data') > > Exception Location: > /usr/lib/python2.6/dist-packages/django/utils/encoding.py in > force_unicode, line 92 > Python Executable: /usr/bin/python > Python Version: 2.6.2 > I actually tested against python 2.5.2. That might be an issue, but I would have to test it out. > > This are the 2 snippets that should generate the file list of a given > directory FYI: I have built two versions of build_file_list(). One that will preserve filenames across scans to collect data and update tags (if changed/modified) and one that is quick and dirty and just deletes/rescans every time. The first is expensive and can time-out over web server connections, while the second is quick and executes with less chance of a timeout. > I tryed to change it like this: > for root, dirs, files in list: > for f in files: > f = f.decode=('latin1').encode('utf-8') > ext = path.splitext(f)[1] > > the chars are computed correctly but then it does not match anymore the > file on the filesystem. > I'm now tryng to write a tuple to match the decoded filename with the > file on the filesystem but I thought there might be an easier way to do this > Couple of thoughts: -should be saving the character encoding in the database for each file, so we can convert it back? -should we use something like a file handle for accessing the file? -create a washtub option to be able to change the database encoding? Are all your files Latin encoding? Or only some of them? Have you gotten any other encoding errors? Also, we could create a Model Method to retrieve the filename (decoded in Latin). -- Chris Everest ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Savonet-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/savonet-users
