def test_secs_to_timestr(self):
     for inp, compact, verbose in [
         (0.001, '1ms', '1 millisecond'),
         (0.002, '2ms', '2 milliseconds'),
         (0.9999, '1s', '1 second'),
         (1, '1s', '1 second'),
         (1.9999, '2s', '2 seconds'),
         (2, '2s', '2 seconds'),
         (60, '1min', '1 minute'),
         (120, '2min', '2 minutes'),
         (3600, '1h', '1 hour'),
         (7200, '2h', '2 hours'),
         (60*60*24, '1d', '1 day'),
         (60*60*48, '2d', '2 days'),
         (171967.667, '1d 23h 46min 7s 667ms',
          '1 day 23 hours 46 minutes 7 seconds 667 milliseconds'),
         (7320, '2h 2min', '2 hours 2 minutes'),
         (7210.05, '2h 10s 50ms', '2 hours 10 seconds 50 milliseconds') ,
         (11.1111111, '11s 111ms', '11 seconds 111 milliseconds'),
         (0.55555555, '556ms', '556 milliseconds'),
         (0, '0s', '0 seconds'),
         (9999.9999, '2h 46min 40s', '2 hours 46 minutes 40 seconds'),
         (10000, '2h 46min 40s', '2 hours 46 minutes 40 seconds'),
         (-1, '- 1s', '- 1 second'),
         (-171967.667, '- 1d 23h 46min 7s 667ms',
          '- 1 day 23 hours 46 minutes 7 seconds 667 milliseconds')]:
         assert_equal(secs_to_timestr(inp, compact=True), compact, inp)
         assert_equal(secs_to_timestr(inp), verbose, inp)
 def test_secs_to_timestr(self):
     for inp, compact, verbose in [
         (0.001, '1ms', '1 millisecond'),
         (0.002, '2ms', '2 milliseconds'),
         (0.9999, '1s', '1 second'),
         (1, '1s', '1 second'),
         (1.9999, '2s', '2 seconds'),
         (2, '2s', '2 seconds'),
         (60, '1min', '1 minute'),
         (120, '2min', '2 minutes'),
         (3600, '1h', '1 hour'),
         (7200, '2h', '2 hours'),
         (60*60*24, '1d', '1 day'),
         (60*60*48, '2d', '2 days'),
         (171967.667, '1d 23h 46min 7s 667ms',
          '1 day 23 hours 46 minutes 7 seconds 667 milliseconds'),
         (7320, '2h 2min', '2 hours 2 minutes'),
         (7210.05, '2h 10s 50ms', '2 hours 10 seconds 50 milliseconds') ,
         (11.1111111, '11s 111ms', '11 seconds 111 milliseconds'),
         (0.55555555, '556ms', '556 milliseconds'),
         (0, '0s', '0 seconds'),
         (9999.9999, '2h 46min 40s', '2 hours 46 minutes 40 seconds'),
         (10000, '2h 46min 40s', '2 hours 46 minutes 40 seconds'),
         (-1, '- 1s', '- 1 second'),
         (-171967.667, '- 1d 23h 46min 7s 667ms',
          '- 1 day 23 hours 46 minutes 7 seconds 667 milliseconds')]:
         assert_equal(secs_to_timestr(inp, compact=True), compact, inp)
         assert_equal(secs_to_timestr(inp), verbose, inp)
    def set_poll_interval(self, poll_interval):
        """Sets the poll interval used in `Wait Until X` keywords to the given
        value.

        `poll_interval` is given in Robot Framework's time format.

        The old poll interval is returend.

        For more details see `Set Timeout`.
        """

        old = getattr(self, '_poll_interval', 1.0)
        self._poll_interval = robottime.timestr_to_secs(poll_interval)
        return robottime.secs_to_timestr(old)
    def set_poll_interval(self, poll_interval):
        """Sets the poll interval used in `Wait Until X` keywords to the given
        value.

        `poll_interval` is given in Robot Framework's time format.

        The old poll interval is returend.

        For more details see `Set Timeout`.
        """

        old = getattr(self, '_poll_interval', 1.0)
        self._poll_interval = robottime.timestr_to_secs(poll_interval)
        return robottime.secs_to_timestr(old)
    def set_timeout(self, timeout):
        """Sets the timeout used in `Wait Until X` keywords to the given value.

        `timeout` is given in Robot Framework's time format
        (e.g. 1 minute 20 seconds) that is explained in the User Guide.

        The old timeout is returned and can be used to restore it later.

        Example.
        | ${tout}= | Set Timeout | 2 minute 30 seconds |
        | Do Something |
        | Set Timeout | ${tout} |
        """

        old = getattr(self, '_timeout', 3.0)
        self._timeout = robottime.timestr_to_secs(timeout)
        return robottime.secs_to_timestr(old)
    def set_timeout(self, timeout):
        """Sets the timeout used in `Wait Until X` keywords to the given value.

        `timeout` is given in Robot Framework's time format
        (e.g. 1 minute 20 seconds) that is explained in the User Guide.

        The old timeout is returned and can be used to restore it later.

        Example.
        | ${tout}= | Set Timeout | 2 minute 30 seconds |
        | Do Something |
        | Set Timeout | ${tout} |
        """

        old = getattr(self, '_timeout', 3.0)
        self._timeout = robottime.timestr_to_secs(timeout)
        return robottime.secs_to_timestr(old)
    def wait_until_rmcp_is_ready(self, timeout=45):
        """Waits until the host can handle RMCP packets.

        `timeout` is given in Robot Framework's time format
        (e.g. 1 minute 20 seconds) that is explained in the User Guide.
        """

        timeout = robottime.timestr_to_secs(timeout)

        start_time = time.time()
        while time.time() < start_time + timeout:
            try:
                self._ipmi.session.rmcp_ping()
                return
            except TimeoutError:
                pass
            time.sleep(self._poll_interval)

        raise AssertionError('RMCP not ready in %s.' %
                             (robottime.secs_to_timestr(timeout)))
    def wait_until_rmcp_is_ready(self, timeout=45):
        """Waits until the host can handle RMCP packets.

        `timeout` is given in Robot Framework's time format
        (e.g. 1 minute 20 seconds) that is explained in the User Guide.
        """

        timeout = robottime.timestr_to_secs(timeout)

        start_time = time.time()
        while time.time() < start_time + timeout:
            try:
                self._ipmi.session.rmcp_ping()
                return
            except TimeoutError:
                pass
            time.sleep(self._poll_interval)

        raise AssertionError('RMCP not ready in %s.'
                % (robottime.secs_to_timestr(timeout)))
Beispiel #9
0
def format_robot_time(timestr):
    secs = timestr_to_secs(timestr)
    return secs_to_timestr(secs)