Use os.rename() instead of popen()