Convert detect from bash script to python script

Convert as much of the tool chain to the language that this community understands best.