Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 1 | #!/usr/bin/python -u |
| 2 | import sys |
| 3 | from robot.libraries.BuiltIn import BuiltIn |
| 4 | import imp |
| 5 | import string |
| 6 | |
| 7 | |
| 8 | |
| 9 | def get_sensor(module_name, value): |
| 10 | m = imp.load_source('module.name', module_name) |
| 11 | |
| 12 | for i in m.ID_LOOKUP['SENSOR']: |
| 13 | |
| 14 | if m.ID_LOOKUP['SENSOR'][i] == value: |
| 15 | return i |
| 16 | |
| 17 | return 0xFF |
| 18 | |
| 19 | def get_inventory_sensor (module_name, value): |
| 20 | m = imp.load_source('module.name', module_name) |
| 21 | |
| 22 | value = string.replace(value, m.INVENTORY_ROOT, '<inventory_root>') |
| 23 | |
| 24 | for i in m.ID_LOOKUP['SENSOR']: |
| 25 | |
| 26 | if m.ID_LOOKUP['SENSOR'][i] == value: |
| 27 | return i |
| 28 | |
| 29 | return 0xFF |
| 30 | |
| 31 | |
| 32 | def get_inventory_list(module_name): |
| 33 | |
| 34 | l = [] |
| 35 | m = imp.load_source('module.name', module_name) |
| 36 | |
| 37 | for i in m.ID_LOOKUP['FRU']: |
| 38 | s = m.ID_LOOKUP['FRU'][i] |
| 39 | s = s.replace('<inventory_root>',m.INVENTORY_ROOT) |
| 40 | l.append(s) |
| 41 | |
| 42 | return l |
| 43 | |
| 44 | def get_inventory_fru_type_list(module_name, fru_type): |
| 45 | |
| 46 | l = [] |
| 47 | m = imp.load_source('module.name', module_name) |
| 48 | |
| 49 | for i in m.FRU_INSTANCES.keys(): |
| 50 | if m.FRU_INSTANCES[i]['fru_type'] == fru_type: |
| 51 | print 'found one' |
| 52 | |
| 53 | s = i.replace('<inventory_root>',m.INVENTORY_ROOT) |
| 54 | l.append(s) |
| 55 | |
| 56 | return l |
| 57 | |
| 58 | def call_keyword(keyword): |
| 59 | return BuiltIn().run_keyword(keyword) |