how to write automation scripts in python