| 1 |
#------------------------------------------------------------------------- |
| 2 |
# Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 |
# Licensed under the MIT License. See License.txt in the project root for |
| 4 |
# license information. |
| 5 |
#-------------------------------------------------------------------------- |
| 6 |
|
| 7 |
# Python imports |
| 8 |
import logging |
| 9 |
|
| 10 |
# C imports |
| 11 |
cimport c_strings |
| 12 |
cimport c_platform |
| 13 |
cimport c_xio |
| 14 |
cimport c_tlsio |
| 15 |
|
| 16 |
|
| 17 |
_logger = logging.getLogger(__name__) |
| 18 |
|
| 19 |
|
| 20 |
class PlatformInfoOption(Enum): |
| 21 |
DefaultOption = c_platform.PLATFORM_INFO_OPTION_TAG.PLATFORM_INFO_OPTION_DEFAULT |
| 22 |
RetrieveSQMOption = c_platform.PLATFORM_INFO_OPTION_TAG.PLATFORM_INFO_OPTION_RETRIEVE_SQM |
| 23 |
|
| 24 |
|
| 25 |
cpdef platform_init(): |
| 26 |
if c_platform.platform_init() != 0: |
| 27 |
raise ValueError("Failed to initialize platform.") |
| 28 |
|
| 29 |
|
| 30 |
cpdef platform_deinit(): |
| 31 |
_logger.debug("Deinitializing platform") |
| 32 |
c_platform.platform_deinit() |
| 33 |
|
| 34 |
|
| 35 |
cpdef get_info(): |
| 36 |
cdef c_strings.STRING_HANDLE str_info |
| 37 |
str_info = c_platform.platform_get_platform_info(PlatformInfoOption.DefaultOption) |
| 38 |
info = AMQPString() |
| 39 |
info.wrap(str_info) |
| 40 |
return info |
| 41 |
|
| 42 |
|
| 43 |
cpdef get_default_tlsio(): |
| 44 |
cdef const c_xio.IO_INTERFACE_DESCRIPTION* io_desc |
| 45 |
io_desc = c_platform.platform_get_default_tlsio() |
| 46 |
if <void*>io_desc == NULL: |
| 47 |
raise ValueError("Failed to create tlsio description.") |
| 48 |
|
| 49 |
interface = IOInterfaceDescription() |
| 50 |
interface.wrap(io_desc) |
| 51 |
return interface |