move all python code into the bash helper function

much tidy, fewer quoting, wow
Merge pull request #25 from jehiah/consolidate_python_25

Consolidate python code