ae.sys_core_sh
SiHOT PMS system core xml interface
This portion is very old and needs refactoring and much more unit tests.
The classes provided by this portion are allowing the implementation of client and server components to communicate with the Sihot PMS system.
- TODO:
use other xml library because xml.etree the xml modules in the Python standard library are not secure against maliciously constructed data - the problem here is that the xml generated by the Sihot system is not 100% conform to the xml standards.
refactor SihotXmlParser and inherited classes: migrating the attributes oc, tn, id, rc, hn, … to a dict.
inject cae app instance into _SihotTcpClient, RequestXmlHandler and TcpServer (replacing ae.core.print_out()).
Module Attributes
Sihot System Interface Id |
|
default search field for external systems (used by sys_data_sh.cl_field_data()) |
|
Sihot Server address or ip |
|
Sihot Kernel Interface port |
|
Sihot Web interfaces port |
|
Sihot Server client port |
|
encoding used by the Sihot xml interface |
|
error message prefix for ignorable errors |
|
error message fragment added if connection is broken |
Functions
|
convert element string to attribute string by converting into lower-case and replacing hyphens with underscores. |
Classes
|
build xml request and send it to get available room categories from the Sihot server. |
|
processing response of CATINFO operation code of the WEB interface |
|
parser for Sihot room category responses. |
|
built room category request and send it to Sihot server. |
|
build and send request for the Sihot configuration settings. |
|
parser to process Sihot configuration setting responses. |
|
build and send request to add a message into the Sihot system message/notification queue. |
|
xml parser for generic requests from SIHOT. |
|
server component base class to receive xml data from the Sihot system. |
|
xml parser to process Sihot server reservation change notifications. |
|
build and send generic request to the Sihot kernel interface. |
|
response to the RESERVATION-GET oc/request of the KERNEL interface. |
|
xml parser for kernel or web interface responses. |
|
xml parser to process Sihot server room change notifications. |
|
connector class for the Sihot system. |
|
generic class to build and send Sihot xml requests. |
|
XMLParser interface used by client to parse the responses from the Sihot server. |
|
tcp server class to process xml sent by the Sihot client. |
- SDI_SH = 'Sh'
Sihot System Interface Id
- SH_DEF_SEARCH_FIELD = 'ShId'
default search field for external systems (used by sys_data_sh.cl_field_data())
- SDF_SH_SERVER_ADDRESS = 'shServerIP'
Sihot Server address or ip
- SDF_SH_KERNEL_PORT = 'shServerKernelPort'
Sihot Kernel Interface port
- SDF_SH_WEB_PORT = 'shServerPort'
Sihot Web interfaces port
- SDF_SH_CLIENT_PORT = 'shClientPort'
Sihot Server client port
- SXML_DEF_ENCODING = 'cp1252'
encoding used by the Sihot xml interface
- ERR_MESSAGE_PREFIX_CONTINUE = 'CONTINUE:'
error message prefix for ignorable errors
- TCP_CONNECTION_BROKEN_MSG = 'socket connection broken!'
error message fragment added if connection is broken
- _TCP_MAXBUFLEN = 8192
tcp buffer length
- _TCP_END_OF_MSG_CHAR = b'\x04'
end-of-message character of the Sihot xml interface
- _DEBUG_RUNNING_CHARS = '|/-\\'
progress animation characters for console output
- elem_to_attr(elem)[source]
convert element string to attribute string by converting into lower-case and replacing hyphens with underscores.
- class _SihotTcpClient(server_ip, server_port, timeout=3.6, encoding='utf-8', debug_level=0)[source]
Bases:
objectlocal sihot tcp client used by
SihotXmlBuilder.send_to_server().- error_message = ''
- received_xml = ''
- class RequestXmlHandler(request, client_address, server)[source]
Bases:
BaseRequestHandlerserver component base class to receive xml data from the Sihot system.
- error_message = ''
- class _ThreadedServer(server_address, RequestHandlerClass, bind_and_activate=True)[source]
Bases:
ThreadingMixIn,TCPServerlocal tcp server threading mixin class used by
TcpServerclass.
- class TcpServer(ip, port, cls_xml_handler, debug_level=0)[source]
Bases:
objecttcp server class to process xml sent by the Sihot client.
- class SihotXmlParser(cae)[source]
Bases:
objectXMLParser interface used by client to parse the responses from the Sihot server.
- data(data)[source]
process parsed data string; called on each chunk (separated by XMLParser on spaces, special chars, …).
- close()[source]
end of xml string reached; called when all data has been parsed.
- Return type:
- Returns:
this
SihotXmlParserinstance.
- class Request(cae)[source]
Bases:
SihotXmlParserxml parser for generic requests from SIHOT.
- class RoomChange(cae)[source]
Bases:
SihotXmlParserxml parser to process Sihot server room change notifications.
- class ResChange(cae)[source]
Bases:
SihotXmlParserxml parser to process Sihot server reservation change notifications.
- class ResResponse(cae)[source]
Bases:
SihotXmlParserxml parser for kernel or web interface responses.
- class AvailCatInfoResponse(cae)[source]
Bases:
SihotXmlParserprocessing response of CATINFO operation code of the WEB interface
- class CatRoomResponse(cae)[source]
Bases:
SihotXmlParserparser for Sihot room category responses.
- class ConfigDictResponse(cae)[source]
Bases:
SihotXmlParserparser to process Sihot configuration setting responses.
- class ResKernelResponse(cae)[source]
Bases:
SihotXmlParserresponse to the RESERVATION-GET oc/request of the KERNEL interface.
- class SihotXmlBuilder(cae, use_kernel=False)[source]
Bases:
objectgeneric class to build and send Sihot xml requests.
- __init__(cae, use_kernel=False)[source]
create an instance of this class.
- Parameters:
cae¶ (
ConsoleApp) – instance of the runningConsoleAppapp.use_kernel¶ (
bool) – pass True to use the Sihot kernel interface (False==use Sihot sxml interface).
- response: SihotXmlParser | None
- beg_xml(operation_code, add_inner_xml='', transaction_number='')[source]
create a new xml request string including xml header, operation code and transaction number.
- send_to_server(response_parser=None)[source]
send the built xml request to the Sihot server.
- Parameters:
response_parser¶ (
Optional[SihotXmlParser]) – used parser to parse the response from the Sihot server (def=SihotXmlParser).- Return type:
- Returns:
error string or empty string if no errors occurred.
- static new_tag(tag, val='', opening=True, closing=True)[source]
create new xml element with the passed tag and value.
- class AvailCatInfo(cae, use_kernel=False)[source]
Bases:
SihotXmlBuilderbuild xml request and send it to get available room categories from the Sihot server.
- avail_rooms(hotel_id='', room_cat='', from_date=datetime.date(2026, 5, 30), to_date=datetime.date(2026, 5, 30))[source]
determine available rooms for the specified hotel, room category and date range.
- Parameters:
hotel_id¶ (
str) – Sihot hotel id or empty string to get available rooms of all hotels.room_cat¶ (
str) – Sihot room category or empty string to get available rooms of all categories.from_date¶ (
date) – start date of the date range: defaulting to today.to_date¶ (
date) – end date of the date range; defaulting to today.
- Return type:
- Returns:
Sihot response as dict created by
AvailCatInfoResponsewith the results or an error message string if an error occurred.
- class CatRooms(cae, use_kernel=False)[source]
Bases:
SihotXmlBuilderbuilt room category request and send it to Sihot server.
- get_cat_rooms(hotel_id='1', from_date=datetime.date(2026, 5, 30), to_date=datetime.date(2026, 5, 30), scope='')[source]
determine configured room categories of the Sihot system for the specified hotel and date range.
- Parameters:
- Return type:
- Returns:
Sihot response as dict created by
CatRoomResponsewith the results or an error message string if an error occurred.
- class ConfigDict(cae, use_kernel=False)[source]
Bases:
SihotXmlBuilderbuild and send request for the Sihot configuration settings.
- get_key_values(config_type, hotel_id='1', language='EN')[source]
determine a configuration setting of the Sihot system for the specified hotel and language.
- Parameters:
- Return type:
- Returns:
Sihot response as dict created by
ConfigDictResponsewith the results or an error message string if an error occurred.
- class PostMessage(cae, use_kernel=False)[source]
Bases:
SihotXmlBuilderbuild and send request to add a message into the Sihot system message/notification queue.
- class ResKernelGet(cae)[source]
Bases:
SihotXmlBuilderbuild and send generic request to the Sihot kernel interface.
- __init__(cae)[source]
create an instance of this class.
- Parameters:
cae¶ (
ConsoleApp) – instance of the runningConsoleAppapp.use_kernel¶ – pass True to use the Sihot kernel interface (False==use Sihot sxml interface).
- class ShSysConnector(system)[source]
Bases:
SystemConnectorBaseconnector class for the Sihot system.