mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
29f55baa97
commit
f5370b7acf
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
static int _com_initialized = 0;
|
static int _com_initialized = 0;
|
||||||
static PyObject *WPDError = NULL;
|
static PyObject *WPDError = NULL;
|
||||||
|
static PyObject *NoWPD = NULL;
|
||||||
static IPortableDeviceManager *portable_device_manager = NULL;
|
static IPortableDeviceManager *portable_device_manager = NULL;
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
@ -33,7 +34,7 @@ wpd_init(PyObject *self, PyObject *args) {
|
|||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
portable_device_manager = NULL;
|
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." :
|
"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");
|
"Failed to create the WPD device manager interface");
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -81,6 +82,8 @@ initwpd(void) {
|
|||||||
WPDError = PyErr_NewException("wpd.WPDError", NULL, NULL);
|
WPDError = PyErr_NewException("wpd.WPDError", NULL, NULL);
|
||||||
if (WPDError == NULL) return;
|
if (WPDError == NULL) return;
|
||||||
|
|
||||||
|
NoWPD = PyErr_NewException("wpd.NoWPD", NULL, NULL);
|
||||||
|
if (NoWPD == NULL) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,6 +100,15 @@ def test_icu():
|
|||||||
raise RuntimeError('ICU module not loaded/valid')
|
raise RuntimeError('ICU module not loaded/valid')
|
||||||
print ('ICU OK!')
|
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():
|
def test():
|
||||||
test_plugins()
|
test_plugins()
|
||||||
test_lxml()
|
test_lxml()
|
||||||
@ -112,6 +121,7 @@ def test():
|
|||||||
if iswindows:
|
if iswindows:
|
||||||
test_win32()
|
test_win32()
|
||||||
test_winutil()
|
test_winutil()
|
||||||
|
test_wpd()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
test()
|
test()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user