Zsolt Haraszti | dafefe1 | 2016-11-14 21:29:58 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | """ |
| 3 | Write adapter data without any custom fields |
| 4 | """ |
| 5 | import sys |
| 6 | |
| 7 | import ext1_pb2 |
| 8 | from voltha.protos import adapter_pb2 |
| 9 | from google.protobuf import any_pb2 |
| 10 | |
| 11 | def custom_config(): |
| 12 | any = any_pb2.Any() |
| 13 | any.Pack(ext1_pb2.AdapterConfig( |
| 14 | volume=20, |
| 15 | bass=50, |
| 16 | treble=50 |
| 17 | )) |
| 18 | return any |
| 19 | |
| 20 | |
| 21 | def custom_description(): |
| 22 | any = any_pb2.Any() |
| 23 | any.Pack(ext1_pb2.AdapterDescription( |
| 24 | internal_name='hulu', |
| 25 | internal_code='foo', |
| 26 | price=42 |
| 27 | )) |
| 28 | return any |
| 29 | |
| 30 | |
| 31 | adapter = adapter_pb2.Adapter( |
| 32 | id='42', |
| 33 | config=adapter_pb2.AdapterConfig( |
| 34 | additional_config=custom_config() |
| 35 | ), |
| 36 | additional_description=custom_description() |
| 37 | ) |
| 38 | |
| 39 | sys.stdout.write(adapter.SerializeToString()) |
| 40 | |