473,898 Members | 3,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_dic t(e.unpack3(f))
File "./yh-925-db-0.1.py", line 53, in unpack3
u = utf_16_le.decod e(fp.read(size) )
AttributeError: 'module' object has no attribute 'decode'

Any ideas? Thanks
Jul 22 '06 #1
2 3436
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_dic t(e.unpack3(f))
File "./yh-925-db-0.1.py", line 53, in unpack3
u = utf_16_le.decod e(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\x0 0d\x00e\x00f\x0 0'

|>utf_16_le.dec ode(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:\pyth on21\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\x0 0d\x00e\x00f\x0 0'
|>utf_16_le.dec ode(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
3678
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. And i have things to offer, and to request. And a lot of ideas, but who needs them.... here's an example (from type_struct.py):
0
2060
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__ = <bound method AttributeError.__getitem__ of <exceptions.AttributeError instance at 0x8187984>> __init__ = <bound method AttributeError.__init__ of <exceptions.AttributeError instance at 0x8187984>> __module__ = 'exceptions'
0
1327
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 index file.""" def __init__(self, pos, filenameroot): self.pos = pos self.file = open(_indexFilePathname(filenameroot), _FILE_OPEN_MODE) self.offsetLineCache = {} # Table of (pathname, offset) -> (line,
4
2600
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, as fun as it is, may have side-effects on intellectual abilities...) *The context:*
3
12149
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 instance has no attribute '__len__' Following the traceback,I see that the offending line is self.x = arg1 + len(self.y) + 1
0
1349
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 attribute error like this: AttributeError: 'unicode' object has no attribute 'decode' The code and data I am preparing is to work on postgres as well a sqlite so there are a couple of things I could do. I could always store any data as unicode...
5
1486
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 usage before creation. Check this out: >>> class foo(object): .... I = 1 .... def __init__(self): .... print self.__dict__ .... self.I += 1
3
1166
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
5789
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 example: answer_str = raw_input(' Enter answer ') Herr
0
9839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10853
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10943
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10480
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8034
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7187
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5876
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3303
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.