473,394 Members | 1,674 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,394 software developers and data experts.

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\lib\DiscID.py", line 15, in ?
import cdrom, sys
File "C:\Python24\lib\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\include\Python.h>

DllClass::DllClass()
{

}
DllClass::~DllClass ()
{

}

static PyObject *mci_error;

#define MCI_STRING_LEN 1000

static PyObject *mci_mciSendString(PyObject *self, PyObject *args)
{
char resultStr[MCI_STRING_LEN+1];
PyObject *pyStr = 0;
if (!PyArg_ParseTuple(args, "O!", &PyString_Type, &pyStr))
return NULL;
// windows mciSendString see cdrom.py for Samples (or MSDN for
complete doc)
mciSendString( PyString_AsString(pyStr), resultStr,MCI_STRING_LEN,0);
return Py_BuildValue("s", resultStr);
}
static PyMethodDef mci_methods[] = {
{ "mciSendString", mci_mciSendString, METH_VARARGS },
{ NULL, NULL }
};
void initmci(void)
{
PyObject *module, *dict;

module = Py_InitModule("mci", mci_methods);
dict = PyModule_GetDict(module);
mci_error = PyErr_NewException("mci.error", NULL, NULL);
PyDict_SetItemString(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_ATTACH:
break;

case DLL_PROCESS_DETACH:
break;

case DLL_THREAD_ATTACH:
break;

case DLL_THREAD_DETACH:
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 2046
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
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:...
2
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
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...
0
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*)...
0
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 ...
6
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...
1
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...
2
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}"...
2
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
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
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...
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...

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.