summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola' <g.rodola@gmail.com>2013-04-12 06:20:56 -0700
committerGiampaolo Rodola' <g.rodola@gmail.com>2013-04-12 06:20:56 -0700
commit59bb8ed88956b9084c41ac2c9ee2239ffedff2a4 (patch)
tree7d0604742338e7557346ec14489aac5ef5f3e000
parent916385f46d666fbcfab3847155b8af101cdd6d92 (diff)
downloadpsutil-59bb8ed88956b9084c41ac2c9ee2239ffedff2a4.tar.gz
Fix issue 351 (Windows): disk_io_counters() can file with RuntimeError if psutil is compiled with mingw32
-rw-r--r--CREDITS4
-rw-r--r--HISTORY6
-rw-r--r--psutil/__init__.py3
-rw-r--r--psutil/_psutil_mswindows.c21
4 files changed, 29 insertions, 5 deletions
diff --git a/CREDITS b/CREDITS
index 67c22016..0fadc1e0 100644
--- a/CREDITS
+++ b/CREDITS
@@ -150,3 +150,7 @@ I: 361
N: clackwell
E: clackwell@gmail.com
I: 356
+
+N: m.malycha
+E: m.malycha@gmail.com
+I: 351
diff --git a/HISTORY b/HISTORY
index 0ec584c7..91fbb337 100644
--- a/HISTORY
+++ b/HISTORY
@@ -41,6 +41,8 @@ BUG FIXES
* #344: [FreeBSD] swap_memory() might return incorrect results due to
kvm_open(3) not being called. (patch by Jean Sebastien)
* #338: [Linux] disk_io_counters() fails to find some disks.
+ * #351: [Windows] if psutil is compiled with mingw32 (provided installers for
+ py2.4 and py2.5 are) disk_io_counters() will fail. (Patch by m.malycha)
* #353: [OSX] get_users() returns an empty list on OSX 10.8.
* #356: Process.parent now checks whether parent PID has been reused in which
case returns None.
@@ -51,11 +53,11 @@ BUG FIXES
API CHANGES
+ * Process.cmdline property is no longer cached after first access.
+ * Process.ppid property is no longer cached after first access.
* [Linux] Process methods not working because of a poor /proc implementation
will raise NotImplementedError instead of RuntimeError.
- * Process.cmdline property is no longer cached after first access.
* psutil.error module is deprecated and scheduled for removal.
- * Process.ppid property is no longer cached
0.6.1 - 2012-08-16
diff --git a/psutil/__init__.py b/psutil/__init__.py
index dd5725b4..1d03d8af 100644
--- a/psutil/__init__.py
+++ b/psutil/__init__.py
@@ -1204,6 +1204,9 @@ def disk_io_counters(perdisk=False):
physical disk installed on the system as a dictionary
with partition names as the keys and the namedutuple
described above as the values.
+
+ On recent Windows versions 'diskperf -y' command may need to be
+ executed first otherwise this function won't find any disk.
"""
rawdict = _psplatform.disk_io_counters()
if not rawdict:
diff --git a/psutil/_psutil_mswindows.c b/psutil/_psutil_mswindows.c
index fb7b6ad8..208c1184 100644
--- a/psutil/_psutil_mswindows.c
+++ b/psutil/_psutil_mswindows.c
@@ -2323,6 +2323,22 @@ error:
return NULL;
}
+// fix for mingw32, see
+// https://code.google.com/p/psutil/issues/detail?id=351#c2
+typedef struct _DISK_PERFORMANCE_WIN_2008 {
+ LARGE_INTEGER BytesRead;
+ LARGE_INTEGER BytesWritten;
+ LARGE_INTEGER ReadTime;
+ LARGE_INTEGER WriteTime;
+ LARGE_INTEGER IdleTime;
+ DWORD ReadCount;
+ DWORD WriteCount;
+ DWORD QueueDepth;
+ DWORD SplitCount;
+ LARGE_INTEGER QueryTime;
+ DWORD StorageDeviceNumber;
+ WCHAR StorageManagerName[8];
+} DISK_PERFORMANCE_WIN_2008;
/*
* Return a Python dict of tuples for disk I/O information
@@ -2330,7 +2346,7 @@ error:
static PyObject*
get_disk_io_counters(PyObject* self, PyObject* args)
{
- DISK_PERFORMANCE diskPerformance;
+ DISK_PERFORMANCE_WIN_2008 diskPerformance;
DWORD dwSize;
HANDLE hDevice = NULL;
char szDevice[MAX_PATH];
@@ -2355,9 +2371,8 @@ get_disk_io_counters(PyObject* self, PyObject* args)
if (hDevice == INVALID_HANDLE_VALUE) {
continue;
}
-
if (DeviceIoControl(hDevice, IOCTL_DISK_PERFORMANCE, NULL, 0,
- &diskPerformance, sizeof(DISK_PERFORMANCE),
+ &diskPerformance, sizeof(diskPerformance),
&dwSize, NULL))
{
sprintf(szDeviceDisplay, "PhysicalDrive%d", devNum);