示例#1
0
    def open_xml(self, file_path: str, start: bool = False) -> core_pb2.OpenXmlResponse:
        """
        Load a local scenario XML file to open as a new session.

        :param file_path: path of scenario XML file
        :param start: True to start session, False otherwise
        :return: response with opened session id
        """
        with open(file_path, "r") as xml_file:
            data = xml_file.read()
        request = core_pb2.OpenXmlRequest(data=data, start=start, file=file_path)
        return self.stub.OpenXml(request)
示例#2
0
    def open_xml(self, file_path):
        """
        Load a local scenario XML file to open as a new session.

        :param str file_path: path of scenario XML file
        :return: response with opened session id
        :rtype: core_pb2.OpenXmlResponse
        """
        with open(file_path, "r") as xml_file:
            data = xml_file.read()
        request = core_pb2.OpenXmlRequest(data=data)
        return self.stub.OpenXml(request)
示例#3
0
    def open_xml(self,
                 file_path: Path,
                 start: bool = False) -> Tuple[bool, int]:
        """
        Load a local scenario XML file to open as a new session.

        :param file_path: path of scenario XML file
        :param start: tuple of result and session id when successful
        :return: tuple of result and session id
        """
        with file_path.open("r") as f:
            data = f.read()
        request = core_pb2.OpenXmlRequest(data=data,
                                          start=start,
                                          file=str(file_path))
        response = self.stub.OpenXml(request)
        return response.result, response.session_id