Remove the last use of win32process

This commit is contained in:
Kovid Goyal 2020-10-15 10:23:27 +05:30
parent 32bbcd092d
commit 56b1554c1e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 12 additions and 6 deletions

View File

@ -180,19 +180,17 @@ def print_basic_debug_info(out=None):
out = sys.stdout out = sys.stdout
out = functools.partial(prints, file=out) out = functools.partial(prints, file=out)
import platform import platform
from contextlib import suppress
from calibre.constants import (__appname__, get_version, isportable, ismacos, from calibre.constants import (__appname__, get_version, isportable, ismacos,
isfrozen, is64bit) isfrozen, is64bit, plugins)
from calibre.utils.localization import set_translators from calibre.utils.localization import set_translators
out(__appname__, get_version(), 'Portable' if isportable else '', out(__appname__, get_version(), 'Portable' if isportable else '',
'embedded-python:', isfrozen, 'is64bit:', is64bit) 'embedded-python:', isfrozen, 'is64bit:', is64bit)
out(platform.platform(), platform.system(), platform.architecture()) out(platform.platform(), platform.system(), platform.architecture())
if iswindows and not is64bit: if iswindows and not is64bit:
try: with suppress(Exception):
import win32process if plugins['winutil'][0].is_wow64_process():
if win32process.IsWow64Process():
out('32bit process running on 64bit windows') out('32bit process running on 64bit windows')
except:
pass
out(platform.system_alias(platform.system(), platform.release(), out(platform.system_alias(platform.system(), platform.release(),
platform.version())) platform.version()))
out('Python', platform.python_version()) out('Python', platform.python_version())

View File

@ -835,6 +835,13 @@ run_cmdline(PyObject *self, PyObject *args) {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
static PyObject*
is_wow64_process(PyObject *self, PyObject *args) {
BOOL ans;
if (!IsWow64Process(GetCurrentProcess(), &ans)) return PyErr_SetFromWindowsErr(0);
return Py_BuildValue("O", ans ? Py_True : Py_False);
}
// Icon loading {{{ // Icon loading {{{
#pragma pack( push ) #pragma pack( push )
#pragma pack( 2 ) #pragma pack( 2 )
@ -969,6 +976,7 @@ static const char winutil_doc[] = "Defines utility methods to interface with win
#define M(name, args) { #name, name, args, ""} #define M(name, args) { #name, name, args, ""}
static PyMethodDef winutil_methods[] = { static PyMethodDef winutil_methods[] = {
M(run_cmdline, METH_VARARGS), M(run_cmdline, METH_VARARGS),
M(is_wow64_process, METH_NOARGS),
M(get_dll_directory, METH_NOARGS), M(get_dll_directory, METH_NOARGS),
M(create_mutex, METH_VARARGS), M(create_mutex, METH_VARARGS),
M(get_async_key_state, METH_VARARGS), M(get_async_key_state, METH_VARARGS),