measure_call_setup_time.py: make the output more readable
authorAntonio Ospite <ao2@ao2.it>
Mon, 21 Dec 2015 18:41:00 +0000 (19:41 +0100)
committerAntonio Ospite <ao2@ao2.it>
Mon, 21 Dec 2015 18:41:00 +0000 (19:41 +0100)
Sleep _after_ having printed the info about the call, the output flow is
more understandable this way.

While at it also avoid the "First ring" message which is misleading
besides, it was a leftover from measure_ring_distance.py

src/measure_call_setup_time.py

index 4de937c..f69bb15 100755 (executable)
@@ -28,9 +28,8 @@ class Ring(object):
 
 def on_ring():
     if Ring.time == -1:
 
 def on_ring():
     if Ring.time == -1:
-        print("First ring")
         Ring.time = time.time()
         Ring.time = time.time()
-        raise StopIteration("We just want the first ring")
+        raise StopIteration("Got the ring we were waiting for")
 
 
 def measure_call_setup_time(ingoing_port, outgoing_port, destination_number):
 
 
 def measure_call_setup_time(ingoing_port, outgoing_port, destination_number):
@@ -61,14 +60,6 @@ def measure_call_setup_time(ingoing_port, outgoing_port, destination_number):
 
         hangup_time = time.time()
 
 
         hangup_time = time.time()
 
-        # When dialing with an analog modem I noticed that if calls are
-        # separated one from another they take less time to set up, this
-        # may be due to how an analog modem works: getting it on-hook and
-        # off-hook takes quite some time.
-        inter_call_sleep = 5.2
-        print("After hangup sleeping %.2f sec..." % inter_call_sleep)
-        time.sleep(inter_call_sleep)
-
         call_setup_time = Ring.time - dial_time
         min_call_setup_time = min(min_call_setup_time, call_setup_time)
         max_call_setup_time = max(max_call_setup_time, call_setup_time)
         call_setup_time = Ring.time - dial_time
         min_call_setup_time = min(min_call_setup_time, call_setup_time)
         max_call_setup_time = max(max_call_setup_time, call_setup_time)
@@ -90,8 +81,17 @@ def measure_call_setup_time(ingoing_port, outgoing_port, destination_number):
         print("Min call time: %f" % min_call_time)
         print("Max call time: %f" % max_call_time)
         print()
         print("Min call time: %f" % min_call_time)
         print("Max call time: %f" % max_call_time)
         print()
+
         Ring.time = -1
 
         Ring.time = -1
 
+        # When dialing with an analog modem I noticed that if calls are
+        # separated one from another they take less time to set up, this
+        # may be due to how an analog modem works: getting it on-hook and
+        # off-hook takes quite some time.
+        inter_call_sleep = 5.2
+        print("Sleeping %.2f sec before the next call..." % inter_call_sleep)
+        time.sleep(inter_call_sleep)
+
 
 def main():
     import sys
 
 def main():
     import sys