if dialed_number is not None: number_string += str(dialed_number) if len(number_string) == 1: sys.stdout.write("(%d" % dialed_number) elif len(number_string) == 2: sys.stdout.write(str(dialed_number)) elif len(number_string) == 3: sys.stdout.write("%d) " % dialed_number) elif len(number_string) <= 6: sys.stdout.write(str(dialed_number)) elif len(number_string) == 7: sys.stdout.write("-%d" % dialed_number) else: sys.stdout.write(str(dialed_number)) sys.stdout.flush() spinner.min_rotation = 360.0 screen.fill([0, 0, 0]) # blank the screen. screen.blit(bg, bg.get_rect()) screen.blit(spinner.image, spinner.loc, spinner.image.get_rect()) screen.blit(needle, needle.get_rect()) pygame.display.update() except: logging.exception("recv loop") finally: sock.close() if len(number_string) == 10: try: client = TwilioRestClient()