switch from os.popen to subprocess.Popen