Пример #1
0
    def hasReceivedScreen(self, timeout=10.0, text=None):
        """
		Waits to receive "screen" event until the end of the timeout

		@param timeout: time max to wait to receive event in second (default=10s)
		@type timeout: float			
		
		@param text: text expected
		@type text: string/operators/none	

		@return: an event matching with the template or None otherwise
		@rtype: templatemessage	
		"""
        if not (isinstance(timeout, int)
                or isinstance(timeout, float)) or isinstance(timeout, bool):
            raise TestAdapterLib.ValueException(
                TestAdapterLib.caller(),
                "timeout argument is not a float or integer (%s)" %
                type(timeout))

        # construct the expected template
        expected = self.getExpectedTemplate(event=templates_term.term_data(
            data=text))

        # try to match the template
        evt = self.received(expected=expected, timeout=timeout)
        return evt
Пример #2
0
    def onWatchScreen(self):
        """
		"""
        current = "%s" % "\n".join(self.screen.display)

        if current != self.snapshot_screen:
            if not self.connected:
                self.connected = True
                self.handleScreen(screen=("opened",
                                          templates_term.term_opened(
                                              data="success")))
                self.handleScreen(screen=("screen",
                                          templates_term.term_data(
                                              data=current.strip())))
            else:
                self.handleScreen(screen=("screen",
                                          templates_term.term_data(
                                              data=current.strip())))
            self.snapshot_screen = current
Пример #3
0
    def doClear(self):
        """
		Clear the terminal

		@return: True on success, False otherwise
		@rtype: boolean	
		"""
        ret = False
        if self.ssh().connected:
            tpl = self.ssh().sendData(dataRaw="clear\n")

            new_tpl = self.encapsule(
                lower_event=tpl,
                layer_term=templates_term.term_data(data="clear\n"))

            if self.logEventSent:
                self.logSentEvent(shortEvt="clear screen", tplEvt=new_tpl)
            ret = True
        return ret
Пример #4
0
    def doText(self, text):
        """
		Type text on terminal

		@param text: the text to type
		@type text: str			
		
		@return: True on success, False otherwise
		@rtype: boolean	
		"""
        ret = False
        if self.ssh().connected:
            tpl = self.ssh().sendData(dataRaw=text + "\n")
            new_tpl = self.encapsule(
                lower_event=tpl,
                layer_term=templates_term.term_data(data=text + "\n"))
            new_tpl.addRaw(text)
            if self.logEventSent:
                self.logSentEvent(shortEvt="send text", tplEvt=new_tpl)
            ret = True
        return ret
Пример #5
0
    def doShorcut(self, key):
        """
		Type key on terminal
		
		@param key: SutAdapters.SSH.KEY_CTRLC|SutAdapters.SSH.KEY_ENTER
		@type key: str		
		
		@return: True on success, False otherwise
		@rtype: boolean	
		"""
        ret = False
        if self.ssh().connected:
            tpl = self.ssh().sendData(dataRaw=key + "\n")

            new_tpl = self.encapsule(
                lower_event=tpl, layer_term=templates_term.term_data(data=key))
            new_tpl.addRaw(key)
            # log event
            if self.logEventSent:
                self.logSentEvent(shortEvt="send key", tplEvt=new_tpl)
            ret = True
        return ret
Пример #6
0
    def hasReceivedScreen(self, timeout=10.0, text=None):
        """
		Waits to receive "screen" event until the end of the timeout

		@param timeout: time max to wait to receive event in second (default=10s)
		@type timeout: float			
		
		@param text: text expected
		@type text: string/operators/none	

		@return: an event matching with the template or None otherwise
		@rtype: templatemessage	
		"""
        TestAdapter.check_timeout(caller=TestAdapter.caller(), timeout=timeout)

        # construct the expected template
        expected = self.getExpectedTemplate(event=templates_term.term_data(
            data=text))

        # try to match the template
        evt = self.received(expected=expected, timeout=timeout)
        return evt