comparison python/mountusb.py @ 737:8806a699ff94

wip, untested
author Jeff Hammel <k0scist@gmail.com>
date Fri, 13 Mar 2015 10:40:59 -0700
parents 0eff3f3658ed
children 81d2f5c20ceb
comparison
equal deleted inserted replaced
736:0dd3144d3bdc 737:8806a699ff94
32 default='/mnt/media', 32 default='/mnt/media',
33 help="mount point") 33 help="mount point")
34 options = parser.parse_args(args) 34 options = parser.parse_args(args)
35 35
36 dmesg = subprocess.check_output(['dmesg']).splitlines() 36 dmesg = subprocess.check_output(['dmesg']).splitlines()
37 string = 'usbcore: registered new interface driver usb-storage' 37 for string in ('usbcore: registered new interface driver usb-storage',
38 for index in reversed(range(len(dmesg))): 38 'USB Mass Storage device detecte'):
39 line = dmesg[index] 39 for index in reversed(range(len(dmesg))):
40 if string in line: 40 line = dmesg[index]
41 break 41 if string in line:
42 break
43 else:
44 continue
45 break
42 else: 46 else:
43 sys.exit(1) # nothing found 47 sys.exit(1)
44 48
45 for line in dmesg[index:]: 49 for line in dmesg[index:]:
46 line = line.split(']', 1)[-1].strip() 50 line = line.split(']', 1)[-1].strip()
47 if ':' in line: 51 if ':' in line:
48 try: 52 try: