Exemple #1
0
	def _connectToRemoteServer(self):
		"""Connects to the nvdaSpyServer
		Because we do not know how far through the startup NVDA is, we have to poll
		to check that the server is available. Importing the library immediately seems
		to succeed, but then calling a keyword later fails with RuntimeError:
			"Connection to remote server broken: [Errno 10061]
				No connection could be made because the target machine actively refused it"
		Instead we wait until the remote server is available before importing the library and continuing.
		"""

		builtIn.log("Waiting for nvdaSpy to be available at: {}".format(spyServerURI))
		# Importing the 'Remote' library always succeeds, even when a connection can not be made.
		# If that happens, then some 'Remote' keyword will fail at some later point.
		# therefore we use '_testRemoteServer' to ensure that we can in fact connect before proceeding.
		_blockUntilConditionMet(
			getValue=lambda: _testRemoteServer(spyServerURI, log=False),
			giveUpAfterSeconds=10,
			errorMessage="Unable to connect to nvdaSpy",
		)
		builtIn.log("Connecting to nvdaSpy")
		maxRemoteKeywordDurationSeconds = 30  # If any remote call takes longer than this, the connection will be closed!
		builtIn.import_library(
			"Remote",  # name of library to import
			# Arguments to construct the library instance:
			"uri={}".format(spyServerURI),
			"timeout={}".format(maxRemoteKeywordDurationSeconds),
			# Set an alias for the imported library instance
			"WITH NAME",
			"nvdaSpy",
		)
		builtIn.log("Getting nvdaSpy library instance")
		self.nvdaSpy = builtIn.get_library_instance(spyAlias)
		self._runNvdaSpyKeyword("set_max_keyword_duration", maxSeconds=maxRemoteKeywordDurationSeconds)
Exemple #2
0
    def _connectToRemoteServer(self):
        """Connects to the nvdaSpyServer
		Because we do not know how far through the startup NVDA is, we have to poll
		to check that the server is available. Importing the library immediately seems
		to succeed, but then calling a keyword later fails with RuntimeError:
			"Connection to remote server broken: [Errno 10061]
				No connection could be made because the target machine actively refused it"
		Instead we wait until the remote server is available before importing the library and continuing.
		"""

        builtIn.log(
            "Waiting for nvdaSpy to be available at: {}".format(spyServerURI))
        # Importing the 'Remote' library always succeeds, even when a connection can not be made.
        # If that happens, then some 'Remote' keyword will fail at some later point.
        # therefore we use '_testRemoteServer' to ensure that we can in fact connect before proceeding.
        _blockUntilConditionMet(
            getValue=lambda: _testRemoteServer(spyServerURI, log=False),
            giveUpAfterSeconds=10,
            errorMessage="Unable to connect to nvdaSpy",
        )
        builtIn.log("Connecting to nvdaSpy")
        maxRemoteKeywordDurationSeconds = 30  # If any remote call takes longer than this, the connection will be closed!
        builtIn.import_library(
            "Remote",  # name of library to import
            # Arguments to construct the library instance:
            "uri={}".format(spyServerURI),
            "timeout={}".format(maxRemoteKeywordDurationSeconds),
            # Set an alias for the imported library instance
            "WITH NAME",
            "nvdaSpy",
        )
        builtIn.log("Getting nvdaSpy library instance")
        self.nvdaSpy = builtIn.get_library_instance(spyAlias)
        self._runNvdaSpyKeyword("set_max_keyword_duration",
                                maxSeconds=maxRemoteKeywordDurationSeconds)
Exemple #3
0
    def _connectToRemoteServer(self, connectionTimeoutSecs=10):
        """Connects to the nvdaSpyServer
		Because we do not know how far through the startup NVDA is, we have to poll
		to check that the server is available. Importing the library immediately seems
		to succeed, but then calling a keyword later fails with RuntimeError:
			"Connection to remote server broken: [Errno 10061]
				No connection could be made because the target machine actively refused it"
		Instead we wait until the remote server is available before importing the library and continuing.
		"""

        builtIn.log(
            f"Waiting for {self._spyAlias} to be available at: {self._spyServerURI}",
            level='DEBUG')
        # Importing the 'Remote' library always succeeds, even when a connection can not be made.
        # If that happens, then some 'Remote' keyword will fail at some later point.
        # therefore we use '_testRemoteServer' to ensure that we can in fact connect before proceeding.
        _blockUntilConditionMet(
            getValue=lambda: _testRemoteServer(self._spyServerURI, log=False),
            giveUpAfterSeconds=connectionTimeoutSecs,
            errorMessage=f"Unable to connect to {self._spyAlias}",
        )
        builtIn.log(f"Connecting to {self._spyAlias}", level='DEBUG')
        # If any remote call takes longer than this, the connection will be closed!
        maxRemoteKeywordDurationSeconds = 30
        builtIn.import_library(
            "Remote",  # name of library to import
            # Arguments to construct the library instance:
            f"uri={self._spyServerURI}",
            f"timeout={maxRemoteKeywordDurationSeconds}",
            # Set an alias for the imported library instance
            "WITH NAME",
            self._spyAlias,
        )
        builtIn.log(f"Getting {self._spyAlias} library instance",
                    level='DEBUG')
        self.nvdaSpy = self._addMethodsToSpy(
            builtIn.get_library_instance(self._spyAlias))
        # Ensure that keywords timeout before `timeout` given to `Remote` library,
        # otherwise we lose control over NVDA.
        self.nvdaSpy.init_max_keyword_duration(
            maxSeconds=maxRemoteKeywordDurationSeconds)