summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-10-01 17:45:47 +0200
committerJelmer Vernooij <jelmer@samba.org>2010-10-01 18:49:42 +0200
commit9cdebd0ebcbf9b890679fa77ce6d8e0127fce28e (patch)
tree90373cdc1486409d1a842a0354f99f1e91cb4e81
parentc4ab2b38af122c7e9173bd5af10f1f9584aa1310 (diff)
downloadsamba-9cdebd0ebcbf9b890679fa77ce6d8e0127fce28e.tar.gz
samba-9cdebd0ebcbf9b890679fa77ce6d8e0127fce28e.tar.bz2
samba-9cdebd0ebcbf9b890679fa77ce6d8e0127fce28e.zip
autobuild: Avoid unnecessary chdir() calls.
-rwxr-xr-xscript/autobuild.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/script/autobuild.py b/script/autobuild.py
index 48ac15028a..be8006c324 100755
--- a/script/autobuild.py
+++ b/script/autobuild.py
@@ -3,7 +3,7 @@
# Copyright Andrew Tridgell 2010
# released under GNU GPL v3 or later
-from subprocess import Popen, PIPE
+from subprocess import call, check_call,Popen, PIPE
import os, tarfile, sys, time
from optparse import OptionParser
import smtplib
@@ -71,21 +71,17 @@ retry_task = [ '''set -e
''' % samba_master]
def run_cmd(cmd, dir=".", show=None, output=False, checkfail=True):
- cwd = os.getcwd()
- os.chdir(dir)
if show is None:
show = options.verbose
if show:
print("Running: '%s' in '%s'" % (cmd, dir))
if output:
- ret = Popen([cmd], shell=True, stdout=PIPE).communicate()[0]
- os.chdir(cwd)
- return ret
- ret = os.system(cmd)
- os.chdir(cwd)
- if checkfail and ret != 0:
- raise Exception("FAILED %s: %d" % (cmd, ret))
- return ret
+ return Popen([cmd], shell=True, stdout=PIPE, cwd=dir).communicate()[0]
+ elif checkfail:
+ return check_call(cmd, shell=True)
+ else:
+ return call(cmd, shell=True)
+
class builder(object):
'''handle build of one directory'''