Author: hwright
Date: Mon Jun 13 11:12:58 2011
New Revision: 1135086

URL: http://svn.apache.org/viewvc?rev=1135086&view=rev
Log:
Add logging, and hide output from building autoconf, libtool, and swig in
release.py.  Add a --verbose switch to enable this output if requested.

* tools/dist/release.py
  (get_nullfile): New.
  (run_script): Only optionally display output from running subcommands.
  (build_env): Add some logging, and update calls to run_script().
  (main): Add --verbose switch, and set up logging.

Modified:
    subversion/trunk/tools/dist/release.py

Modified: subversion/trunk/tools/dist/release.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/tools/dist/release.py?rev=1135086&r1=1135085&r2=1135086&view=diff
==============================================================================
--- subversion/trunk/tools/dist/release.py (original)
+++ subversion/trunk/tools/dist/release.py Mon Jun 13 11:12:58 2011
@@ -38,6 +38,7 @@ import sys
 import shutil
 import urllib2
 import tarfile
+import logging
 import subprocess
 import argparse       # standard in Python 2.7
 
@@ -51,9 +52,20 @@ def get_prefix(base_dir):
 def get_tempdir(base_dir):
     return os.path.join(base_dir, 'tempdir')
 
-def run_script(script):
+def get_nullfile():
+    # This is certainly not cross platform
+    return open('/dev/null', 'w')
+
+def run_script(args, script):
+    if args.verbose:
+        stdout = None
+        stderr = None
+    else:
+        stdout = get_nullfile()
+        stderr = subprocess.STDOUT
+
     for l in script.split('\n'):
-        subprocess.check_call(l.split())
+        subprocess.check_call(l.split(), stdout=stdout, stderr=stderr)
 
 
 def cleanup(base_dir, args):
@@ -68,6 +80,7 @@ def cleanup(base_dir, args):
 
 def build_env(base_dir, args):
     'Download prerequisites for a release and prepare the environment.'
+    logging.info('Creating release environment')
 
     # Versions of our environment
     params = { 'autoconf'           : 'autoconf-2.68',
@@ -106,20 +119,26 @@ def build_env(base_dir, args):
     cwd = os.getcwd()
 
     # build autoconf
+    logging.info('Building autoconf')
     os.chdir(os.path.join(get_tempdir(base_dir), params['autoconf']))
-    run_script('''./configure --prefix=%s
+    run_script(args,
+               '''./configure --prefix=%s
                   make
                   make install''' % get_prefix(base_dir))
 
     # build libtool
+    logging.info('Building libtool')
     os.chdir(os.path.join(get_tempdir(base_dir), params['libtool']))
-    run_script('''./configure --prefix=%s
+    run_script(args,
+               '''./configure --prefix=%s
                   make
                   make install''' % get_prefix(base_dir))
 
     # build swig
+    logging.info('Building swig')
     os.chdir(os.path.join(get_tempdir(base_dir), params['swig']))
-    run_script('''./configure --prefix=%s --without-pcre
+    run_script(args,
+               '''./configure --prefix=%s --without-pcre
                   make
                   make install''' % get_prefix(base_dir))
 
@@ -145,6 +164,8 @@ def main():
                             description='Create an Apache Subversion release.')
     parser.add_argument('--clean', action='store_true', default=False,
                    help='Remove any directories previously created by 
%(prog)s')
+    parser.add_argument('--verbose', action='store_true', default=False,
+                   help='Increase output verbosity')
     parser.add_argument('--base-dir', default=os.getcwd(),
                    help='''The directory in which to create needed files and
                            folders.  The default is the current working
@@ -174,6 +195,13 @@ def main():
     if args.clean:
         cleanup(args.base_dir, args)
 
+    # Set up logging
+    logger = logging.getLogger()
+    if args.verbose:
+        logger.setLevel(logging.DEBUG)
+    else:
+        logger.setLevel(logging.INFO)
+
     sys.path.append(os.path.join(get_prefix(args.base_dir), 'bin'))
 
     # finally, run the subcommand, and give it the parsed arguments


Reply via email to