mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-02 14:13:42 -04:00
0ad3b0421f
It's not useful to raise an excpetion because it will only report the command called exit with an error. Just return an error code instead of rasing an exception. This way we get nicer error messages: ./waf unknowncommand No function unknowncommand defined in /home/lucas/p/dronecode/ardupilot/wscript vs ./waf unknowncommand No function unknowncommand defined in /home/lucas/p/dronecode/ardupilot/wscript Traceback (most recent call last): File "./waf", line 15, in <module> raise e subprocess.CalledProcessError: Command '['python', '/home/lucas/p/dronecode/ardupilot/modules/waf/waf-light', 'unknowncommand']' returned non-zero exit status 1
27 lines
730 B
Python
Executable File
27 lines
730 B
Python
Executable File
#!/usr/bin/python
|
|
|
|
from __future__ import print_function
|
|
import subprocess
|
|
import os.path as p
|
|
import sys
|
|
|
|
d = p.dirname(p.realpath(__file__))
|
|
waf_light = p.join(d, 'modules', 'waf', 'waf-light')
|
|
|
|
try:
|
|
subprocess.check_call(['python', waf_light] + sys.argv[1:])
|
|
except subprocess.CalledProcessError as e:
|
|
if e.returncode != 2 or p.isfile(waf_light):
|
|
sys.exit(1)
|
|
|
|
print('Missing waf submodule. Trying to get it')
|
|
|
|
try:
|
|
subprocess.check_call(['git', 'submodule', 'update', '--init',
|
|
'modules/waf'])
|
|
except subprocess.CalledProcessError:
|
|
print('Could not update submodule', file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
print('Submodules OK, try running again')
|