Skip to content

Instantly share code, notes, and snippets.

@mcclure
Created September 2, 2015 23:05
Show Gist options
  • Save mcclure/617b038464f300ca802d to your computer and use it in GitHub Desktop.
Save mcclure/617b038464f300ca802d to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# NOTE: BEFORE EXECUTING, REPLACE THE PATH IN cwd= IN THE FINAL LINE.
import subprocess
import copy
import os
globalEnv = copy.deepcopy( os.environ )
globalEnv["HGPLAIN"]="1" # Disable pager, etc in any following calls
def fullExec(cmd, cwd=None, env=None):
proc = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,env=env if env else globalEnv)
result = proc.wait()
outstr, errstr = proc.communicate()
return bool(result),outstr,errstr
print "Going in"
fullExec(['hg', 'log'], cwd="/Users/mcc/work/h/test-emily-game")
# Expected behavior: Script completes
# Observed behavior: Script does not complete?!
# Invoking `HGPLAIN=1 hg log` in the cwd directory terminates just fine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment