Skip to content
Snippets Groups Projects
Commit 20de6057 authored by Nat Goodspeed's avatar Nat Goodspeed
Browse files

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".
parent ea5c8563
No related branches found
No related tags found
No related merge requests found
......@@ -26,18 +26,41 @@
"""
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 @@
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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment