From 18c99b6e776456074506306e707826e60374ab3a Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sun, 2 Dec 2012 12:04:45 +0000 Subject: [PATCH] * morituri/common/drive.py: * morituri/rip/drive.py: Extract getDeviceInfo function. --- ChangeLog | 6 ++++++ morituri/common/drive.py | 12 ++++++++++++ morituri/rip/drive.py | 6 +++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3dd695..ce6bc6a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-12-02 Thomas Vander Stichele + + * morituri/common/drive.py: + * morituri/rip/drive.py: + Extract getDeviceInfo function. + 2012-12-02 Thomas Vander Stichele * morituri/common/config.py (added): diff --git a/morituri/common/drive.py b/morituri/common/drive.py index 95c9452..8037efb 100644 --- a/morituri/common/drive.py +++ b/morituri/common/drive.py @@ -58,3 +58,15 @@ def _getAllDevicePathsStatic(): ret.append(c) return ret + +def getDeviceInfo(path): + try: + import cdio + except ImportError: + return None + + device = cdio.Device(path) + ok, vendor, model, release = device.get_hwinfo() + + return (vendor, model, release) + diff --git a/morituri/rip/drive.py b/morituri/rip/drive.py index cae3873..b5f2b6c 100644 --- a/morituri/rip/drive.py +++ b/morituri/rip/drive.py @@ -40,12 +40,12 @@ class List(logcommand.LogCommand): try: import cdio except ImportError: - print 'Install pycdio for vendor/model/release detection.' + self.stdout.write( + 'Install pycdio for vendor/model/release detection.\n') return for path in paths: - device = cdio.Device(path) - ok, vendor, model, release = device.get_hwinfo() + vendor, model, release = drive.getDeviceInfo(path) print "drive: %s, vendor: %s, model: %s, release: %s" % ( path, vendor, model, release)