Move import pexpect, import time to beginning of main instead of in each called function