Bash commands replaced by python functions