diff --git a/src/calibre/devices/mtp/windows/wpd.cpp b/src/calibre/devices/mtp/windows/wpd.cpp index d7d1a11eaa..e2397a5797 100644 --- a/src/calibre/devices/mtp/windows/wpd.cpp +++ b/src/calibre/devices/mtp/windows/wpd.cpp @@ -15,6 +15,7 @@ static int _com_initialized = 0; static PyObject *WPDError = NULL; +static PyObject *NoWPD = NULL; static IPortableDeviceManager *portable_device_manager = NULL; static PyObject * @@ -33,7 +34,7 @@ wpd_init(PyObject *self, PyObject *args) { if (FAILED(hr)) { portable_device_manager = NULL; - PyErr_SetString(WPDError, (hr == REGDB_E_CLASSNOTREG) ? + PyErr_SetString((hr == REGDB_E_CLASSNOTREG) ? NoWPD : WPDError, (hr == REGDB_E_CLASSNOTREG) ? "This computer is not running the Windows Portable Device framework. You may need to install Windows Media Player 11 or newer." : "Failed to create the WPD device manager interface"); return NULL; @@ -81,6 +82,8 @@ initwpd(void) { WPDError = PyErr_NewException("wpd.WPDError", NULL, NULL); if (WPDError == NULL) return; + NoWPD = PyErr_NewException("wpd.NoWPD", NULL, NULL); + if (NoWPD == NULL) return; } diff --git a/src/calibre/test_build.py b/src/calibre/test_build.py index a21458cc02..35e050cf19 100644 --- a/src/calibre/test_build.py +++ b/src/calibre/test_build.py @@ -100,6 +100,15 @@ def test_icu(): raise RuntimeError('ICU module not loaded/valid') print ('ICU OK!') +def test_wpd(): + wpd = plugins['wpd'][0] + try: + wpd.init() + except wpd.NoWPD: + print ('This computer does not have WPD') + else: + wpd.uninit() + def test(): test_plugins() test_lxml() @@ -112,6 +121,7 @@ def test(): if iswindows: test_win32() test_winutil() + test_wpd() if __name__ == '__main__': test()