WIP. Porting bash pipeline script to python.

Added code to load environment modules from within a python script. Also general bugfixes and additional functionality. Still a work in progress, so is not yet complete.
and using logging/logbook would be nicer :-)