Issue 498 in psutil: Filter detected device type

1 view
Skip to first unread message

psu...@googlecode.com

unread,
Apr 22, 2014, 10:07:19 PM4/22/14
to psutil-...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Enhancement Priority-Medium

New issue 498 by feedback...@gmail.com: Filter detected device type
http://code.google.com/p/psutil/issues/detail?id=498

This is a feature request.
Is it possible to detect only connected usb disk drives (like pendrive)
with psutils?

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

psu...@googlecode.com

unread,
Apr 22, 2014, 10:13:13 PM4/22/14
to psutil-...@googlegroups.com

Comment #1 on issue 498 by g.rodola: Filter detected device type
http://code.google.com/p/psutil/issues/detail?id=498

I think you should see what psutil.disk_partitions()
(https://pythonhosted.org/psutil/#psutil.disk_partitions) returns when you
have an USB disk connected then simply filter for "fstype".

psu...@googlecode.com

unread,
Apr 22, 2014, 10:16:44 PM4/22/14
to psutil-...@googlegroups.com

Comment #2 on issue 498 by feedback...@gmail.com: Filter detected device
type
http://code.google.com/p/psutil/issues/detail?id=498

Read it. The way it is written, it seems to work under windows only.

Anyway, Will test and report back. If working, you may want to update the
doc.

psu...@googlecode.com

unread,
Apr 22, 2014, 10:20:05 PM4/22/14
to psutil-...@googlegroups.com

Comment #3 on issue 498 by g.rodola: Filter detected device type
http://code.google.com/p/psutil/issues/detail?id=498

What do you mean? What is returned if an USB disk is connected and how
should I update the doc?

psu...@googlecode.com

unread,
Apr 23, 2014, 9:14:57 AM4/23/14
to psutil-...@googlegroups.com

Comment #4 on issue 498 by feedback...@gmail.com: Filter detected device
type
http://code.google.com/p/psutil/issues/detail?id=498

Sorry for the delay.
Here is the simple sample code:-

import psutil
for device in psutil.disk_partitions(all=False):
print device[0]

It producess an output like this:-
/dev/sda5
/dev/sda8
/dev/sda7
/dev/sda6
/dev/sdb1

Now, how do I detemine if "/dev/sdb1" is a USB device?

psu...@googlecode.com

unread,
Apr 23, 2014, 4:07:49 PM4/23/14
to psutil-...@googlegroups.com

Comment #5 on issue 498 by g.rodola: Filter detected device type
http://code.google.com/p/psutil/issues/detail?id=498

Try to paste the whole namedtuple as in:

import psutil
for device in psutil.disk_partitions(all=False):
print device

psu...@googlecode.com

unread,
Apr 23, 2014, 11:24:29 PM4/23/14
to psutil-...@googlegroups.com

Comment #6 on issue 498 by feedback...@gmail.com: Filter detected device
type
http://code.google.com/p/psutil/issues/detail?id=498

Here is the nametuple you asked for:-

sdiskpart(device='/dev/sda5', mountpoint='/', fstype='ext4',
opts='rw,relatime,data=ordered')
sdiskpart(device='/dev/sda6', mountpoint='/media/DEBIAN', fstype='ext4',
opts='rw,relatime,data=ordered')
sdiskpart(device='/dev/sda8', mountpoint='/media/FUN', fstype='vfat',
opts='rw,nosuid,nodev,noexec,relatime,gid=100,fmask=0002,dmask=0002,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro')
sdiskpart(device='/dev/sda7', mountpoint='/media/DATA', fstype='vfat',
opts='rw,nosuid,nodev,noexec,relatime,gid=100,fmask=0002,dmask=0002,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro')
sdiskpart(device='/dev/sdb1', mountpoint='/run/media/sundar/SUNDAR',
fstype='vfat',
opts='rw,nosuid,nodev,relatime,uid=1000,gid=100,fmask=0022,dmask=0077,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro')

psu...@googlecode.com

unread,
May 26, 2014, 11:08:04 AM5/26/14
to psutil-...@googlegroups.com

Comment #7 on issue 498 by g.rodola: Filter detected device type
http://code.google.com/p/psutil/issues/detail?id=498

psutil has been migrated from Google Code to Github (see:
http://grodola.blogspot.com/2014/05/goodbye-google-code-im-moving-to-github.html).
Please do NOT reply here but use this instead:
https://github.com/giampaolo/psutil/issues/498
Reply all
Reply to author
Forward
0 new messages