From b2447d9d56c6ec832eb1dcb7e701d890db6e2075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 19 May 2015 01:16:26 +0200 Subject: [PATCH] Add script that find mass storage devices on a computer --- playground/README.md | 1 + playground/usb_lookup.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 playground/README.md create mode 100644 playground/usb_lookup.py diff --git a/playground/README.md b/playground/README.md new file mode 100644 index 0000000..d8c0928 --- /dev/null +++ b/playground/README.md @@ -0,0 +1 @@ +This directory contains files that may of may not be used in the project diff --git a/playground/usb_lookup.py b/playground/usb_lookup.py new file mode 100644 index 0000000..76f14d7 --- /dev/null +++ b/playground/usb_lookup.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from usb.core import find +import usb.control + + +def is_mass_storage(dev): + import usb.util + for cfg in dev: + if usb.util.find_descriptor(cfg, bInterfaceClass=8) is not None: + return True + + +for mass in find(find_all=True, custom_match=is_mass_storage): + print(mass)