473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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

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/sams...-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
Jul 22 '06 #1
2 3385
rsd wrote:
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/sams...-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

Jul 22 '06 #2
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
Jul 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc....
0
by: Erlend Fuglum | last post by:
I have tried and tried, but cannot figure out the source of the following error: AttributeError: 'module' object has no attribute 'menyHMTL' __doc__ = 'Attribute not found.' __getitem__ =...
0
by: warren ali | last post by:
Anyone have any idea why this is failing with the following error class _IndexFile: """An _IndexFile is an implementation class that presents a Sequence and Dictionary interface to a sorted...
4
by: bruno modulix | last post by:
Hi How can I make a *class* attribute read-only ? The answer must be pretty obvious but I just can't find it (it's late and I've spent all day on metaclasses, descriptors and the like, which,...
3
by: MackS | last post by:
I'm new to Python. In general I manage to understand what is happening when things go wrong. However, the small program I am writing now fails with the following message: AttributeError: ClassA...
0
by: David Pratt | last post by:
Recently I have run into an issue with sqlite where I encode strings going into sqlite3 as utf-8. I guess by default sqlite3 is converting this to unicode since when I try to decode I get an...
5
by: Russell Warren | last post by:
I just ran across a case which seems like an odd exception to either what I understand as the "normal" variable lookup scheme in an instance/object heirarchy, or to the rules regarding variable...
3
by: Brian | last post by:
I have a very small script: import re text = open('eq.txt','r').read() regex = '{3}(){3}' pattern = re.compile(regex) match = pattern.findall(text) print ''.join(match)
1
by: anonymous | last post by:
1 Objective to write little programs to help me learn German. See code after numbered comments. //Thanks in advance for any direction or suggestions. tk 2 Want keyboard answer input, for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.