def OnTimer(timestamp=0):
    global seconds
    seconds += 1
    if not tester.test_is_active and seconds < 2:
        maybe_start_testing()
    elif seconds >= max_run_time:
        print("FAIL   The test maximum runtime of %d seconds was reached. Stopping the hub..." % max_run_time)
        sys.stdout.flush()
        tester.finish_testing(0)
        vh.StopHub(2)
def maybe_start_testing():
    hub_name = vh.GetConfig("config", "hub_name")
    if hub_name == special_hub_name:
        ver = vh.__version__
        if ver[0] == 1 and (ver[1] > 2 or ver[1] == 2 and ver[2] > 3):
            tester.start_testing(my_test)
        else:
            print("ERROR: Cannot run VH Integration Test. Expected version <2.0.0 and >1.2.3, but got %s" % str(ver))
            sys.stdout.flush()
            vh.StopHub(1)
 def finish_testing(self, exit_code):
     if self.test_is_active:
         now = time.time()
         if self.failed_tests_count == 0 and self.all_tests_count > 0:
             s = "All %d tests succeeded! " % self.all_tests_count
         else:
             s = "%d out of %d tests failed. " % (self.failed_tests_count, self.all_tests_count)
         s += "Testing took %s seconds" % (now - self.start_time)
         self.test(s)
         self.test_is_active = False
         print("\n================= Ending VH Integration Test =================\n")
         sys.stdout.flush()
         vh.StopHub(exit_code)