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 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 8 | def get_sensor(module_name, value): |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 9 | m = imp.load_source('module.name', module_name) |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 10 | |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 11 | for i in m.ID_LOOKUP['SENSOR']: |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 12 | |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 13 | if m.ID_LOOKUP['SENSOR'][i] == value: |
| 14 | return i |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 15 | |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 16 | return 0xFF |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 17 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 18 | |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 19 | def get_inventory_sensor(module_name, value): |
| 20 | m = imp.load_source('module.name', module_name) |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 21 | |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 22 | value = string.replace(value, m.INVENTORY_ROOT, '<inventory_root>') |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 23 | |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 24 | for i in m.ID_LOOKUP['SENSOR']: |
| 25 | |
| 26 | if m.ID_LOOKUP['SENSOR'][i] == value: |
| 27 | return i |
| 28 | |
| 29 | return 0xFF |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 30 | |
| 31 | |
| 32 | def get_inventory_list(module_name): |
| 33 | |
Joy Onyerikwu | 004ad3c | 2018-06-11 16:29:56 -0500 | [diff] [blame] | 34 | inventory_list = [] |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 35 | m = imp.load_source('module.name', module_name) |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 36 | |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 37 | for i in m.ID_LOOKUP['FRU']: |
| 38 | s = m.ID_LOOKUP['FRU'][i] |
| 39 | s = s.replace('<inventory_root>', m.INVENTORY_ROOT) |
Joy Onyerikwu | 004ad3c | 2018-06-11 16:29:56 -0500 | [diff] [blame] | 40 | inventory_list.append(s) |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 41 | |
Joy Onyerikwu | 004ad3c | 2018-06-11 16:29:56 -0500 | [diff] [blame] | 42 | return inventory_list |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 43 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 44 | |
| 45 | def get_inventory_fru_type_list(module_name, fru_type): |
| 46 | |
Joy Onyerikwu | 004ad3c | 2018-06-11 16:29:56 -0500 | [diff] [blame] | 47 | inventory_list = [] |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 48 | m = imp.load_source('module.name', module_name) |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 49 | |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 50 | for i in m.FRU_INSTANCES.keys(): |
| 51 | if m.FRU_INSTANCES[i]['fru_type'] == fru_type: |
| 52 | print 'found one' |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 53 | |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 54 | s = i.replace('<inventory_root>', m.INVENTORY_ROOT) |
Joy Onyerikwu | 004ad3c | 2018-06-11 16:29:56 -0500 | [diff] [blame] | 55 | inventory_list.append(s) |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 56 | |
Joy Onyerikwu | 004ad3c | 2018-06-11 16:29:56 -0500 | [diff] [blame] | 57 | return inventory_list |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 58 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 59 | |
| 60 | def call_keyword(keyword): |
Gunnar Mills | dca3579 | 2018-03-26 10:05:38 -0500 | [diff] [blame] | 61 | return BuiltIn().run_keyword(keyword) |