diff options
author | Josh Blum <josh@joshknows.com> | 2010-05-21 17:30:05 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-05-21 17:30:05 -0700 |
commit | 76ce1d824a41beacdb5bd603549c9b0e3f64d98f (patch) | |
tree | 009c97ad3d3ffa309f3a1ca1b0162cc4ceedacf6 /host/utils | |
parent | 98bd3e1ddc0189f45f209c02b7dc7877ab377960 (diff) | |
download | uhd-76ce1d824a41beacdb5bd603549c9b0e3f64d98f.tar.gz uhd-76ce1d824a41beacdb5bd603549c9b0e3f64d98f.tar.bz2 uhd-76ce1d824a41beacdb5bd603549c9b0e3f64d98f.zip |
mac os x card burner support and documentation notes
Diffstat (limited to 'host/utils')
-rwxr-xr-x | host/utils/usrp2_card_burner.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/host/utils/usrp2_card_burner.py b/host/utils/usrp2_card_burner.py index 60aca9133..d47a4f5f4 100755 --- a/host/utils/usrp2_card_burner.py +++ b/host/utils/usrp2_card_burner.py @@ -22,6 +22,7 @@ import subprocess import urllib import optparse import os +import re ######################################################################## # constants @@ -107,6 +108,26 @@ def get_raw_device_hints(): return sorted(set(devs)) #################################################################### + # Platform Mac OS X: parse diskutil list and info commands + #################################################################### + if platform.system() == 'Darwin': + devs = map(lambda d: d.split()[0], filter(lambda l: l.startswith('/dev'), command('diskutil', 'list').splitlines())) + def output_to_info(output): + return dict([map(str.strip, pair.lower().split(':')) for pair in filter(lambda l: ':' in l, output.splitlines())]) + def is_dev_valid(dev): + info = output_to_info(command('diskutil', 'info', dev)) + try: + if info.has_key('internal'): assert info['internal'] == 'no' + if info.has_key('ejectable'): assert info['ejectable'] == 'yes' + if info.has_key('total size'): + size_match = re.match('^.*\((\d+)\s*bytes\).*$', info['total size']) + if size_match: assert int(size_match.groups()[0]) <= MAX_SD_CARD_SIZE + return True + except: return False + + return sorted(set(filter(is_dev_valid, devs))) + + #################################################################### # Platform Others: #################################################################### return () |