Replaced the cmd.stdout and cmd.stderr usage with the output of cmd.communicate()