Sansung YH-920 + Linux + yh-925-db-0.1.py = AttributeError: 'module'object has no attribute 'decode'

R

rsd

Hi,

I'm trying get Samsung YH-920 mp3 player to work with Debian GNU/Linux.
To do that I need to run
http://www.paul.sladen.org/toys/samsung-yh-925/yh-925-db-0.1.py
script, the idea behind the script is described at
http://www.paul.sladen.org/toys/samsung-yh-925/

I'm getting errors and hoping someone could give me some hints, for I
have no python background.

This is what I've done:
1. mounted YH-920 as /mnt/usb and transfered my MP3s to
/mnt/usb/System/music/mp3 folder. That was easy.

2. Now, I need to run "yh-925-db-0.1.py" to update the database.

test:/mnt/usb# ls -l
total 64
drwxr-xr-x 3 root root 16384 2006-07-22 10:31 backup
drwxr-xr-x 8 root root 16384 2006-07-22 10:33 System
drwxr-xr-x 2 root root 16384 2002-01-01 11:00 tmp


test:/mnt/usb/System# ls -l
total 2480
drwxr-xr-x 2 root root 16384 2006-06-26 16:31 audible
drwxr-xr-x 2 root root 16384 2006-06-26 16:31 data
drwxr-xr-x 6 root root 16384 2006-06-26 16:31 music
drwxr-xr-x 2 root root 16384 2006-06-26 16:31 Parms
drwxr-xr-x 2 root root 16384 2006-06-26 16:31 playlist
-rwxr-xr-x 1 root root 2424832 2004-07-31 10:47 pp5020.mi4
drwxr-xr-x 2 root root 16384 2006-06-26 16:31 Recordings
-rwxr-xr-x 1 root root 7305 2006-07-22 10:34 yh-925-db-0.1.py


test:/mnt/usb/System# ./yh-925-db-0.1.py
Traceback (most recent call last):
File "./yh-925-db-0.1.py", line 195, in ?
de.add_from_dict(e.unpack3(f))
File "./yh-925-db-0.1.py", line 53, in unpack3
u = utf_16_le.decode(fp.read(size))
AttributeError: 'module' object has no attribute 'decode'

Any ideas? Thanks
 
J

John Machin

rsd said:
Hi,

I'm trying get Samsung YH-920 mp3 player to work with Debian GNU/Linux.
To do that I need to run
http://www.paul.sladen.org/toys/samsung-yh-925/yh-925-db-0.1.py
script, the idea behind the script is described at
http://www.paul.sladen.org/toys/samsung-yh-925/

I'm getting errors and hoping someone could give me some hints, for I
have no python background.

This is what I've done:
1. mounted YH-920 as /mnt/usb and transfered my MP3s to
/mnt/usb/System/music/mp3 folder. That was easy.

2. Now, I need to run "yh-925-db-0.1.py" to update the database.
[snip]



test:/mnt/usb/System# ./yh-925-db-0.1.py
Traceback (most recent call last):
File "./yh-925-db-0.1.py", line 195, in ?
de.add_from_dict(e.unpack3(f))
File "./yh-925-db-0.1.py", line 53, in unpack3
u = utf_16_le.decode(fp.read(size))
AttributeError: 'module' object has no attribute 'decode'

Any ideas? Thanks

You don't say which version of Python you are running ... but my guess
is that it's 2.3 or earlier.

What the author is doing appears to be undocumented in Python 2.4 and
not supported in 2.3 & earlier.


Option (1): Upgrade your Python to 2.4 (visit www.python.org).
Option (2): Pass this problem description on to the author:

C:\junk>python
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.

|>> from encodings import utf_16_le
# The above is not documented.

# get some sample data in utf-16-le encoding:
|>> u = u'abcdef'
|>> u
u'abcdef'
|>> le16 = u.encode('utf-16-le')
|>> le16
'a\x00b\x00c\x00d\x00e\x00f\x00'

|>> utf_16_le.decode(le16)
(u'abcdef', 12)
# Doesn't work on Python 2.3 and earlier -- the decode() and encode()
functions are not exposed.
# Note: returns a tuple containing (unicode_object, length_in_bytes).
In the Python script for the music player, the length is not used and
the unicode object has to be extracted by doing the_tuple[0]

# One documented way of decoding a string strg using encoding enc is
strg.decode(enc)
|>> le16.decode('utf-16-le')
u'abcdef'
# ... but this was introduced in 2.2. The builtin unicode(strg, enc)
function (also documented) does the same thing & works all the way back
to Python 2.1 at least (I didn't keep copies of 1.6 & 2.0) . I've heard
of Linux users stuck on 2.1 for whatever reason but not on earlier
versions.

C:\junk>c:\python21\python
Python 2.1.3 (#35, Apr 8 2002, 17:47:50) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
|>> from encodings import utf_16_le
|>> u = u'abcdef'
|>> u
u'abcdef'
|>> le16 = u.encode('utf-16-le')
|>> le16
'a\x00b\x00c\x00d\x00e\x00f\x00'
|>> utf_16_le.decode(le16)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'encodings.utf_16_le' module has no attribute 'decode'
|>> unicode(le16, 'utf-16-le')
u'abcdef'
|>>

Option (3): hack the source code along the above lines ...
Option (4): hope somebody will hack it for you ....

HTH,
John
 
R

rsd

You don't say which version of Python you are running ... but my guess
is that it's 2.3 or earlier.

Yes, you're right. I was using version 2.3.5

I'll see if I can get it working with 2.4

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top