Part of my code:
import subprocess
import logging
logging.basicConfig(filename='daily_backup_run.log', level=logging.DEBUG)
try:
git_command = subprocess.Popen("git status", shell="true")
git_status_output = git_command.stdout.readline()
except subprocess.CalledProcessError, e:
git_status_output = e.output
logging.debug(' Output of git status: ' + git_status_output)
exit()
When I attempt to run this, my output is:
[~/experiment_folder]# python git.py
Traceback (most recent call last):
File "git.py", line 35, in ?
except subprocess.CalledProcessError, e:
AttributeError: 'module' object has no attribute 'CalledProcessError'
fatal: Not a git repository (or any of the parent directories): .git
I am not concerned with the Python errors at the moment, but I need all output sent by git to go into the daily_backup_run.log - even the fatal: Not a repo error. How do I ensure this?