Index: tools/checklicenses/checklicenses.py
|
diff --git a/tools/checklicenses/checklicenses.py b/tools/checklicenses/checklicenses.py
|
index 4fd2c059a72e48fff170311613360e81f6ff07cd..9b40d1957e647e9c3865c6d48e5d510f957d88d4 100755
|
--- a/tools/checklicenses/checklicenses.py
|
+++ b/tools/checklicenses/checklicenses.py
|
@@ -1,4 +1,4 @@
|
-#!/usr/bin/python
|
+#!/usr/bin/env python
|
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
# Use of this source code is governed by a BSD-style license that can be
|
# found in the LICENSE file.
|
@@ -411,7 +411,7 @@ PATH_SPECIFIC_WHITELISTED_LICENSES = {
|
}
|
|
|
-def main(options, args):
|
+def check_licenses(options, args):
|
# Figure out which directory we have to check.
|
if len(args) == 0:
|
# No directory to check specified, use the repository root.
|
@@ -423,7 +423,7 @@ def main(options, args):
|
else:
|
# More than one argument, we don't handle this.
|
PrintUsage()
|
- sys.exit(1)
|
+ return 1
|
|
print "Using base directory:", options.base_directory
|
print "Checking:", start_dir
|
@@ -447,7 +447,7 @@ def main(options, args):
|
print stderr
|
print '--------- end licensecheck stderr ---------'
|
print "\nFAILED\n"
|
- sys.exit(1)
|
+ return 1
|
|
success = True
|
for line in stdout.splitlines():
|
@@ -484,7 +484,7 @@ def main(options, args):
|
|
if success:
|
print "\nSUCCESS\n"
|
- sys.exit(0)
|
+ return 0
|
else:
|
print "\nFAILED\n"
|
print "Please read",
|
@@ -493,11 +493,10 @@ def main(options, args):
|
print
|
print "Please respect OWNERS of checklicenses.py. Changes violating"
|
print "this requirement may be reverted."
|
+ return 1
|
|
- sys.exit(1)
|
|
-
|
-if '__main__' == __name__:
|
+def main():
|
default_root = os.path.abspath(
|
os.path.join(os.path.dirname(__file__), '..', '..'))
|
option_parser = optparse.OptionParser()
|
@@ -513,4 +512,8 @@ if '__main__' == __name__:
|
default=False,
|
help='Ignore path-specific license whitelist.')
|
options, args = option_parser.parse_args()
|
- main(options, args)
|
+ return check_licenses(options, args)
|
+
|
+
|
+if '__main__' == __name__:
|
+ sys.exit(main())
|
|