summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-02-01 15:29:47 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2017-02-01 15:29:47 +0100
commit86fc3ee3acb2d2ae0e8186b1ae8a55567417759a (patch)
tree9f7c8293e49b4cc47eddadb6366ce0eef9406b3e
parentdf9250cdee1c241324e71e7f68e1602eaf82d2c9 (diff)
parentf49c29bc22ce323c8965d342b15e824d91d59227 (diff)
downloadpsutil-86fc3ee3acb2d2ae0e8186b1ae8a55567417759a.tar.gz
Merge branch '371-temperatures' of github.com:giampaolo/psutil into 371-temperatures
-rw-r--r--HISTORY.rst2
-rw-r--r--psutil/arch/windows/services.c6
-rwxr-xr-xpsutil/tests/test_process.py5
-rwxr-xr-xscripts/winservices.py2
4 files changed, 13 insertions, 2 deletions
diff --git a/HISTORY.rst b/HISTORY.rst
index 755a6d7f..52cb04d0 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -17,6 +17,8 @@
- 948_: cannot install psutil with PYTHONOPTIMIZE=2.
- 950_: [Windows] Process.cpu_percent() was calculated incorrectly and showed
higher number than real usage.
+- 961_: [Windows] WindowsService.description() may fail with
+ ERROR_MUI_FILE_NOT_FOUND.
5.0.1
diff --git a/psutil/arch/windows/services.c b/psutil/arch/windows/services.c
index 7923ddc2..8e7fff33 100644
--- a/psutil/arch/windows/services.c
+++ b/psutil/arch/windows/services.c
@@ -376,6 +376,12 @@ psutil_winservice_query_descr(PyObject *self, PyObject *args) {
bytesNeeded = 0;
QueryServiceConfig2(hService, SERVICE_CONFIG_DESCRIPTION, NULL, 0,
&bytesNeeded);
+ if (GetLastError() == ERROR_MUI_FILE_NOT_FOUND) {
+ // Also services.msc fails in the same manner, so we return an
+ // empty string.
+ CloseServiceHandle(hService);
+ return Py_BuildValue("s", "");
+ }
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
PyErr_SetFromWindowsErr(0);
goto error;
diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py
index 74750473..fdb9f03d 100755
--- a/psutil/tests/test_process.py
+++ b/psutil/tests/test_process.py
@@ -1799,8 +1799,11 @@ class TestFetchAllProcesses(unittest.TestCase):
try:
st = os.stat(ret)
except OSError as err:
+ if WINDOWS and err.errno in \
+ psutil._psplatform.ACCESS_DENIED_SET:
+ pass
# directory has been removed in mean time
- if err.errno != errno.ENOENT:
+ elif err.errno != errno.ENOENT:
raise
else:
self.assertTrue(stat.S_ISDIR(st.st_mode))
diff --git a/scripts/winservices.py b/scripts/winservices.py
index fed6a734..1a65adce 100755
--- a/scripts/winservices.py
+++ b/scripts/winservices.py
@@ -45,7 +45,7 @@ if os.name != 'nt':
def main():
for service in psutil.win_service_iter():
info = service.as_dict()
- print("%s (%s)" % (info['name'], info['display_name']))
+ print("%r (%r)" % (info['name'], info['display_name']))
print("status: %s, start: %s, username: %s, pid: %s" % (
info['status'], info['start_type'], info['username'], info['pid']))
print("binpath: %s" % info['binpath'])