summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2016-10-04 22:19:24 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2016-10-04 22:19:24 +0200
commit97a0c246d65c6adff2600d98e70dfbebe1dbdc84 (patch)
tree29e95964e86060d2fdfc3c39a5fb2ca3b5206238
parent9599456623efc09c9d9c2b6f2788eef269fad7f6 (diff)
downloadpsutil-97a0c246d65c6adff2600d98e70dfbebe1dbdc84.tar.gz
fix #906 / disk_partitions(): ignore 'all' parameter and return all partitions
-rw-r--r--HISTORY.rst2
-rw-r--r--docs/index.rst7
-rw-r--r--psutil/_psbsd.py9
3 files changed, 11 insertions, 7 deletions
diff --git a/HISTORY.rst b/HISTORY.rst
index a429ce65..128fdadc 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -22,6 +22,8 @@ Bug tracker at https://github.com/giampaolo/psutil/issues
functions.
- #892: [Linux] Process.cpu_affinity([-1]) raise SystemError with no error
set; now ValueError is raised.
+- #906: [BSD] disk_partitions(all=False) returned an empty list. Now the
+ argument is ignored and all partitions are always returned.
4.3.1 - 2016-09-01
diff --git a/docs/index.rst b/docs/index.rst
index c5d7c749..cfd3ab37 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -254,9 +254,12 @@ Disks
Return all mounted disk partitions as a list of namedtuples including device,
mount point and filesystem type, similarly to "df" command on UNIX. If *all*
- parameter is ``False`` return physical devices only (e.g. hard disks, cd-rom
- drives, USB keys) and ignore all others (e.g. memory partitions such as
+ parameter is ``False`` it tries to distinguish and return physical devices
+ only (e.g. hard disks, cd-rom drives, USB keys) and ignore all others
+ (e.g. memory partitions such as
`/dev/shm <http://www.cyberciti.biz/tips/what-is-devshm-and-its-practical-usage.html>`__).
+ Note that this may not be fully reliable on all systems (e.g. on BSD this
+ parameter is ignored).
Namedtuple's **fstype** field is a string which varies depending on the
platform.
On Linux it can be one of the values found in /proc/filesystems (e.g.
diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py
index f868a212..daa140ed 100644
--- a/psutil/_psbsd.py
+++ b/psutil/_psbsd.py
@@ -283,15 +283,14 @@ def cpu_stats():
def disk_partitions(all=False):
+ """Return mounted disk partitions as a list of namedtuples.
+ 'all' argument is ignored, see:
+ https://github.com/giampaolo/psutil/issues/906
+ """
retlist = []
partitions = cext.disk_partitions()
for partition in partitions:
device, mountpoint, fstype, opts = partition
- if device == 'none':
- device = ''
- if not all:
- if not os.path.isabs(device) or not os.path.exists(device):
- continue
ntuple = _common.sdiskpart(device, mountpoint, fstype, opts)
retlist.append(ntuple)
return retlist