0

I have some code that uses subprocess to look at the logs from a git directory. My code seems to work fine when executed in a local django dev environment. Once deployed however (with Apache / mode_wsgi) the output from stdout read() comes back empty. My development and production machine are the same right now, and I also tried making sure every file was readable.

Does anybody have an idea why Popen is not returning any output once deployed here? Thanks.

def getGitLogs(projectName, searchTerm=None, since):
    os.chdir(os.path.join(settings.SCM_GIT, projectName))
    cmd = "git log --since {0} -p".format(since)
    p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
    output = p.stdout.read()
    ### here output comes back as expected in dev environment, but empty in once deployed
    return filterCommits(parseCommits(output), searchTerm)
jpic
  • 32,891
  • 5
  • 112
  • 113
D.C.
  • 15,340
  • 19
  • 71
  • 102
  • is anything showing up in your apache server logs? – mata May 17 '12 at 22:26
  • Nothing conspicuous at all... I even tried explicitly logginthe output variable, and it just says it's empty, not None or anything – D.C. May 17 '12 at 22:29
  • 1
    Maybe related: http://stackoverflow.com/questions/8494335/running-subprocess-popen-under-apachemod-wsgi-is-always-returning-an-error-with What's the return code of git log command (called from subprocess) ? What apache/mod_wsgi/python versions ? – jpic May 17 '12 at 22:39

1 Answers1

3
  1. Chain your chdir as part of your command (ie, cd /foo/bar/zoo)
  2. Pass the full path to git

So your command would end up cd /foo/bar/zoo && /usr/bin/git log --since

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284