diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2014-12-12 14:33:20 -0500 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2014-12-12 14:33:20 -0500 |
commit | 20de60576f464aa87a38b5a270a5a72330452670 (patch) | |
tree | c39f9e51287477ffd4cc1320ab02a527c0fe669d /scripts/packages-formatter.py | |
parent | ea5c8563351233105e1c9536353f0d6e6a4a3bf7 (diff) |
Wrap call to autobuild in some diagnostic code.
Hopefully this will make certain errors clearer, notably failure to launch
autobuild due to "cannot find the file specified".
Diffstat (limited to 'scripts/packages-formatter.py')
-rwxr-xr-x | scripts/packages-formatter.py | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/scripts/packages-formatter.py b/scripts/packages-formatter.py index 1432cdaebe..34fc92e44c 100755 --- a/scripts/packages-formatter.py +++ b/scripts/packages-formatter.py @@ -26,18 +26,41 @@ $/LicenseInfo$ """ import os import sys +import errno import re import subprocess -autobuild=os.getenv('AUTOBUILD', +_autobuild=os.getenv('AUTOBUILD', 'autobuild' if not ( sys.platform == 'win32' or sys.platform == 'cygwin') else 'autobuild.cmd') pkg_line=re.compile('^([\w-]+):\s+(.*)$') +def autobuild(*args): + """ + Launch autobuild with specified command-line arguments. + Return its stdout pipe from which the caller can read. + """ + # subprocess wants a list, not a tuple + command = [_autobuild] + list(args) + try: + child = subprocess.Popen(command, + stdin=None, stdout=subprocess.PIPE, + universal_newlines=True) + except OSError as err: + if err.errno != errno.ENOENT: + # Don't attempt to interpret anything but ENOENT + raise + # Here it's ENOENT: subprocess can't find the autobuild executable. + print >>sys.stderr, "packages-formatter on %s: can't run autobuild:\n%s\n%s" % \ + (sys.platform, ' '.join(command), err) + sys.exit(1) + + # no exceptions yet, let caller read stdout + return child.stdout + version={} -versions=subprocess.Popen([autobuild, 'install', '--versions'], - stdin=None, stdout=subprocess.PIPE, universal_newlines=True).stdout +versions=autobuild('install', '--versions') for line in versions: pkg_info = pkg_line.match(line) if pkg_info: @@ -50,8 +73,7 @@ for line in versions: sys.exit("Unrecognized --versions output: %s" % line) copyright={} -copyrights=subprocess.Popen([autobuild, 'install', '--copyrights'], - stdin=None, stdout=subprocess.PIPE, universal_newlines=True).stdout +copyrights=autobuild('install', '--copyrights') viewer_copyright = copyrights.readline() # first line is the copyright for the viewer itself for line in copyrights: pkg_info = pkg_line.match(line) |