473,840 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cddb and mci produce an ImportError

Hi,

i am in search of a cddb module for Python on windows. I stumbled upon
http://sourceforge.net/projects/cddb-py but couldn't use it since the
mci.dll is compiled against Python2.0.
So i'm trying to rebuild it using Dev-C++. I've succeeded in building a
dll but when i try a test program it get this error:
http://sourceforge.net/projects/cddb-py

Traceback (most recent call last):
File "cddtest.py ", line 1, in ?
import CDDB, DiscID
File "C:\Python24\li b\DiscID.py", line 15, in ?
import cdrom, sys
File "C:\Python24\li b\cdrom.py", line 8, in ?
import mci
ImportError: dynamic module does not define init function (initmci)

I had already some problems with the CDDB.py program since it used
os.geteuid() and python gave an error for that too. These are the files
i'm using and i'm not sure the content is correct. I used a dll project
and copied and pasted the content of the original files from the cddb
project in there in the hopes of getting it to work.

mci.h
=============== =============== =============== =============== ============
#ifndef _DLL_H_
#define _DLL_H_

#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */

DLLIMPORT void initmci(void);

class DLLIMPORT DllClass
{
public:
DllClass();
virtual ~DllClass(void) ;

private:

};
#endif /* _DLL_H_ */
mci.cpp
=============== =============== =============== =============== ============
/* Replace "dll.h" with the name of your header */
#include "mci.h"
#include <windows.h>
#include <mmsystem.h>
#include <C:\Python24\in clude\Python.h>

DllClass::DllCl ass()
{

}
DllClass::~DllC lass ()
{

}

static PyObject *mci_error;

#define MCI_STRING_LEN 1000

static PyObject *mci_mciSendStr ing(PyObject *self, PyObject *args)
{
char resultStr[MCI_STRING_LEN+ 1];
PyObject *pyStr = 0;
if (!PyArg_ParseTu ple(args, "O!", &PyString_Ty pe, &pyStr))
return NULL;
// windows mciSendString see cdrom.py for Samples (or MSDN for
complete doc)
mciSendString( PyString_AsStri ng(pyStr), resultStr,MCI_S TRING_LEN,0);
return Py_BuildValue(" s", resultStr);
}
static PyMethodDef mci_methods[] = {
{ "mciSendString" , mci_mciSendStri ng, METH_VARARGS },
{ NULL, NULL }
};
void initmci(void)
{
PyObject *module, *dict;

module = Py_InitModule(" mci", mci_methods);
dict = PyModule_GetDic t(module);
mci_error = PyErr_NewExcept ion("mci.error" , NULL, NULL);
PyDict_SetItemS tring(dict, "error", mci_error);
}

BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function
is being called. */ ,
LPVOID reserved /* Not used. */ )
{
switch (reason)
{
case DLL_PROCESS_ATT ACH:
break;

case DLL_PROCESS_DET ACH:
break;

case DLL_THREAD_ATTA CH:
break;

case DLL_THREAD_DETA CH:
break;
}

/* Returns TRUE on success, FALSE on failure */
return TRUE;
}

test program
=============== =============== =============== =============== ============
import CDDB, DiscID

cdrom = DiscID.open()
disc_id = DiscID.disc_id( cdrom)

(query_status, query_info) = CDDB.query(disc _id)
(read_status, read_info) = CDDB.read(query _info['category'],
query_info['disc_id'])

for i in range(disc_id[1]):
print "Track %.02d: %s" % (i, read_info['TTITLE' + `i`])

I've included these libraries (linker options):
--no-export-all-symbols --add-stdcall-alias
C:/Dev-Cpp/lib/libwinmm.a
C:/Python24/libs/python24.lib
C:/Python24/libs/libpython24.a

It compiles fine and makes a mci.dll but as i said, i get the
ImportError when i run it.

Any ideas?

Thanks,
Benedict
Jul 19 '05 #1
1 2070
flupke wrote:
<snip>

I finally succeeded in making a proper mci.dll that works. I will
document what i did in the coming days and place it here. I developed
the dll with DevC++.
Anyway, it all works :)

Benedict
Jul 19 '05 #2

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

Similar topics

0
4558
by: Carsten Gehling | last post by:
Figured out myself - I just removed the line with "from url import Url" -it doesn't seem to be used anywhere ;-) - Carsten > -----Oprindelig meddelelse----- > Fra: python-list-admin@python.org > På vegne af Carsten Gehling > Sendt: 16. juli 2003 16:24
2
17747
by: x-herbert | last post by:
Hi, I have a small test to "compile" al litle script as a WMI-Tester. The script include a wmi-wrapper and "insert" the Win32-modeles. here the code: my "WMI-Tester.py" ----- import wmi
0
5390
by: Wicked | last post by:
Hi all, Has anyone got rpm.py? Is this a class/module for Python? I am getting the following error: File "./extra/scripts/update_release.py", line 42, in ? import rpm ImportError: No module named rpm
0
6326
by: M. Lavasani | last post by:
Hi I am trying to test Python-2.3. Any solution for this problem please: >>>gmake test case $MAKEFLAGS in \ *-s*) LD_LIBRARY_PATH=/net/ia64/lavasani/Python-2.3:/usr/local/lib/hpux32:/usr/local/lib CC='gcc' LDSHARED='gcc -shared' OPT='-DNDEBUG -g -O3 -Wall -Wstrict-prototypes' ./python -E ./setup.py -q build;; \
0
1321
by: Cousin Stanley | last post by:
I __had__ a __working__ installation of the GTK Runtime and PyGTK using Python23 under Win98, but managed to muck it up, I think but couldn't swear to it, with a separate install of wGlade for Windows which has since been un-installed .... I've also un-installed/re-installed both the GTK Runtime and PyGTK from the original packages .... GTK Runtime 2.2.4.1 PyGTK 2.0 win32
6
16651
by: o'seally | last post by:
solaris/linux admins/rookie_developers that battle with this error are probably all frustrated when it happens. i bet you're also somehow frustrated by this seemingly unsolvable error :-) ...take it easy, it'll go away once u've learned how to play around with a few things on your system and reorganised. i'm particulary a solaris junkie, but linux is my admiration. the issue here is Not the OS/Software, but rather the concept. first of all...
1
1477
by: Kent Tenney | last post by:
Howdy, I'm using Python 2.4 on W2K I would love to use the tools at http://cddb-py.sourceforge.net/ the newest Win binaries are for Python 2.0 The dll won't load, I assume this is due to version mismatch.
2
2188
by: Adam Blinkinsop | last post by:
I'm writing a set of modules to monitor remote system services, and I'm having a problem running my test scripts. When I pass the scripts into python, like so: -- $ PYTHONPATH="${TARGET_DIR}" python test.py -- I get an ImportError:
2
4391
by: bubba | last post by:
Has anyone coded a VBA module to access CDDB or freeDB to retrieve album/song info into a music database. Thanks.
0
9703
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
10926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10609
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
10666
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,...
1
7846
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
7024
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
5691
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
5879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4081
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.