Skip to content

Commit

Permalink
#811: move DLL check logic in _pswindows.py
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Nov 8, 2016
1 parent a2a9de7 commit 6cf0151
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
19 changes: 1 addition & 18 deletions psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,7 @@
pass

elif WINDOWS:
try:
from . import _pswindows as _psplatform
except ImportError as err:
if sys.getwindowsversion()[0] < 6:
# We may get here if:
# 1) we are on an old Windows version
# 2) psutil was installed via pip + wheel
# See: https://github.com/giampaolo/psutil/issues/811
# It must be noted that psutil can still (kind of) work
# on outdated systems if compiled / installed from sources,
# but if we get here it means this this was a wheel (or exe).
msg = "this Windows version is too old (< Windows Vista); "
msg += "psutil 3.4.2 is the latest version which supports Windows "
msg += "2000, XP and 2003 server"
raise RuntimeError(msg)
else:
raise

from . import _pswindows as _psplatform
from ._psutil_windows import ABOVE_NORMAL_PRIORITY_CLASS # NOQA
from ._psutil_windows import BELOW_NORMAL_PRIORITY_CLASS # NOQA
from ._psutil_windows import HIGH_PRIORITY_CLASS # NOQA
Expand Down
20 changes: 19 additions & 1 deletion psutil/_pswindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,25 @@
from collections import namedtuple

from . import _common
from . import _psutil_windows as cext
try:
from . import _psutil_windows as cext
except ImportError as err:
if str(err).lower().startswith("dll load failed") and \
sys.getwindowsversion()[0] < 6:
# We may get here if:
# 1) we are on an old Windows version
# 2) psutil was installed via pip + wheel
# See: https://github.com/giampaolo/psutil/issues/811
# It must be noted that psutil can still (kind of) work
# on outdated systems if compiled / installed from sources,
# but if we get here it means this this was a wheel (or exe).
msg = "this Windows version is too old (< Windows Vista); "
msg += "psutil 3.4.2 is the latest version which supports Windows "
msg += "2000, XP and 2003 server"
raise RuntimeError(msg)
else:
raise

from ._common import conn_tmap
from ._common import isfile_strict
from ._common import parse_environ_block
Expand Down

0 comments on commit 6cf0151

Please sign in to comment.