source: trunk/debathena/config/athinfod-cluster-config/debian/usb-hid.py @ 24987

Revision 24987, 783 bytes checked in by jdreed, 14 years ago (diff)
Remove DOS linebreaks
  • Property svn:executable set to *
Line 
1#!/usr/bin/python
2#
3# HID interface class = 3
4# Interface Protocols:
5# 0 - None
6# 1 - KB
7# 2 - Mouse
8# 3-255 Reserved
9
10import usb
11
12protocols = { 1: 'keyboard',
13              2: 'mouse'}
14
15found = { 'keyboard' : 'no',
16          'mouse' : 'no' }
17
18for b in usb.busses():
19    if 'no' not in found.values():
20        break
21    for d in b.devices:
22        if 'no' not in found.values():
23            break
24        i = d.configurations[0].interfaces[0][0]
25        if i.interfaceClass == 3 and \
26            i.interfaceProtocol in protocols.keys():
27                found[protocols[i.interfaceProtocol]] = 'yes'
28
29if 'no' not in found.values():
30    print "OK - keyboard and mouse present"
31else:
32    errs = []
33    for k,v in found.items():
34        if v == 'no':
35            errs.append(k + " missing")
36    print "ERROR - " + ', '.join(errs)
37   
Note: See TracBrowser for help on using the repository browser.