[tor-commits] [stem/master] Propagating cwd for republish calls

atagar at torproject.org atagar at torproject.org
Fri Dec 14 07:35:58 UTC 2012


commit 2fcdc4bbd6ebcb27725d45cffa3461b4d833913e
Author: Damian Johnson <atagar at torproject.org>
Date:   Thu Dec 13 23:34:43 2012 -0800

    Propagating cwd for republish calls
    
    The script's a little nicer (and closer to working) when we pass through a cwd
    rather than trying to set it separately.
---
 docs/republish.py |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/docs/republish.py b/docs/republish.py
index 180863c..70cd50e 100644
--- a/docs/republish.py
+++ b/docs/republish.py
@@ -24,28 +24,25 @@ If stem's repository is unchanged then this is a no-op.
   -r, --repeat RATE     tries to republish the site at a set rate, in minutes
 """
 
-def run(command):
+def run(command, cwd = None):
   # Runs the given command. This returns the stdout if successful, and raises
   # an OSError if it fails.
   
-  cmd = subprocess.Popen(command.split(' '), stdout = subprocess.PIPE, stderr = subprocess.PIPE)
+  cmd = subprocess.Popen(command.split(' '), stdout = subprocess.PIPE, stderr = subprocess.PIPE, cwd = cwd)
   
   if cmd.wait() == 0:
     return cmd.communicate()[0]
   else:
     stdout, stderr = cmd.communicate()
-    raise OSError("'%s' failed\n  stdout: %s\n  stderr: %s" % (command, stdout, stderr))
+    raise OSError("'%s' failed\n  stdout: %s\n  stderr: %s" % (command, stdout.strip(), stderr.strip()))
 
 def republish_site():
   # Checks if stem's repository has changed, rebuilding the site if so. Ideally
   # we'd use plumbing commands to check this but... meh. Patches welcome.
   
-  clone_cmd = 'git --git-dir=/home/stem/stem/.git pull'
-  
-  if 'Already up-to-date.' not in run(clone_cmd):
+  if 'Already up-to-date.' not in run('git pull', cwd = '/home/stem/stem'):
     LOGGER.log(logging.INFO, "Stem's repository has changed. Republishing...")
-    run('cd /home/stem/stem/docs')
-    run('make html')
+    run('make html', cwd = '/home/stem/stem/docs')
     run('sudo -u mirroradm static-master-update-component stem.torproject.org')
     LOGGER.log(logging.INFO, "  site republished")
 



More information about the tor-commits mailing list