Skip to content

Commit bb0c80b

Browse files
koalocdunn2001
authored andcommitted
Doxybuild: Error message if doxygen not found
This patch introduces a better error message. See discussion at pull open-source-parsers#129.
1 parent ff5abe7 commit bb0c80b

1 file changed

Lines changed: 23 additions & 7 deletions

File tree

doxybuild.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from devtools import tarball
55
from contextlib import contextmanager
66
import subprocess
7+
import traceback
78
import re
89
import os
910
import sys
@@ -52,24 +53,39 @@ def do_subst_in_file(targetfile, sourcefile, dict):
5253
def getstatusoutput(cmd):
5354
"""cmd is a list.
5455
"""
55-
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
56-
output, _ = process.communicate()
57-
status = process.returncode
56+
try:
57+
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
58+
output, _ = process.communicate()
59+
status = process.returncode
60+
except:
61+
status = -1
62+
output = traceback.format_exc()
5863
return status, output
5964

6065
def run_cmd(cmd, silent=False):
61-
print('Running:', repr(' '.join(cmd)), 'in', repr(os.getcwd()))
66+
"""Raise exception on failure.
67+
"""
68+
info = 'Running: %r in %r' %(' '.join(cmd), os.getcwd())
69+
print(info)
6270
sys.stdout.flush()
6371
if silent:
6472
status, output = getstatusoutput(cmd)
6573
else:
6674
status, output = os.system(' '.join(cmd)), ''
6775
if status:
68-
msg = 'error=%d, output="""\n%s\n"""' %(status, output)
69-
print(msg)
70-
#raise Exception(msg)
76+
msg = 'Error while %s ...\n\terror=%d, output="""%s"""' %(info, status, output)
77+
raise Exception(msg)
78+
79+
def assert_is_exe(path):
80+
if not path:
81+
raise Exception('path is empty.')
82+
if not os.path.isfile(path):
83+
raise Exception('%r is not a file.' %path)
84+
if not os.access(path, os.X_OK):
85+
raise Exception('%r is not executable by this user.' %path)
7186

7287
def run_doxygen(doxygen_path, config_file, working_dir, is_silent):
88+
assert_is_exe(doxygen_path)
7389
config_file = os.path.abspath(config_file)
7490
with cd(working_dir):
7591
cmd = [doxygen_path, config_file]

0 commit comments

Comments
 (0)