예제 #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)
예제 #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)
예제 #3
0
	def wait_for_NVDA_startup_to_complete(self):
		_blockUntilConditionMet(
			getValue=lambda: self._spy.isNvdaStartupComplete,
			giveUpAfterSeconds=self._minTimeout(10),
			errorMessage="Unable to connect to nvdaSpy",
		)
		if self._spy.isNvdaStartupComplete:
			self.reset_all_speech_index()
예제 #4
0
	def wait_for_specific_speech(self, speech, sinceIndex=None, maxWaitSeconds=5):
		sinceIndex = 0 if not sinceIndex else sinceIndex
		success, speechIndex = _blockUntilConditionMet(
			getValue=lambda: self._spy.getIndexOfSpeech(speech, sinceIndex),
			giveUpAfterSeconds=self._minTimeout(maxWaitSeconds),
			shouldStopEvaluator=lambda speechIndex: speechIndex >= 0,
			intervalBetweenSeconds=0.1,
			errorMessage=None
		)
		if not success:
			self._spy.dumpSpeechToLog()
			raise AssertionError(
				"Specific speech did not occur before timeout: {}\n"
				"See NVDA log for dump of all speech.".format(speech)
			)
		return speechIndex
예제 #5
0
	def wait_for_speech_to_finish(self, maxWaitSeconds=5.0):
		_blockUntilConditionMet(
			getValue=self._spy.hasSpeechFinished,
			giveUpAfterSeconds=self._minTimeout(maxWaitSeconds),
			errorMessage="Speech did not finish before timeout"
		)