switch from using shell script to python