Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: tools/checklicenses/checklicenses.py

Issue 8678023: Fix python scripts in src/tools/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/checkdeps/checkdeps.py ('k') | tools/clang/scripts/update.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Makes sure that all files contain proper licensing information.""" 6 """Makes sure that all files contain proper licensing information."""
7 7
8 8
9 import optparse 9 import optparse
10 import os.path 10 import os.path
11 import subprocess 11 import subprocess
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 ], 404 ],
405 'v8/test/cctest': [ # http://crbug.com/98597 405 'v8/test/cctest': [ # http://crbug.com/98597
406 'UNKNOWN', 406 'UNKNOWN',
407 ], 407 ],
408 'webkit/data/ico_decoder': [ 408 'webkit/data/ico_decoder': [
409 'UNKNOWN', 409 'UNKNOWN',
410 ], 410 ],
411 } 411 }
412 412
413 413
414 def main(options, args): 414 def check_licenses(options, args):
415 # Figure out which directory we have to check. 415 # Figure out which directory we have to check.
416 if len(args) == 0: 416 if len(args) == 0:
417 # No directory to check specified, use the repository root. 417 # No directory to check specified, use the repository root.
418 start_dir = options.base_directory 418 start_dir = options.base_directory
419 elif len(args) == 1: 419 elif len(args) == 1:
420 # Directory specified. Start here. It's supposed to be relative to the 420 # Directory specified. Start here. It's supposed to be relative to the
421 # base directory. 421 # base directory.
422 start_dir = os.path.abspath(os.path.join(options.base_directory, args[0])) 422 start_dir = os.path.abspath(os.path.join(options.base_directory, args[0]))
423 else: 423 else:
424 # More than one argument, we don't handle this. 424 # More than one argument, we don't handle this.
425 PrintUsage() 425 PrintUsage()
426 sys.exit(1) 426 return 1
427 427
428 print "Using base directory:", options.base_directory 428 print "Using base directory:", options.base_directory
429 print "Checking:", start_dir 429 print "Checking:", start_dir
430 print 430 print
431 431
432 licensecheck_path = os.path.abspath(os.path.join(options.base_directory, 432 licensecheck_path = os.path.abspath(os.path.join(options.base_directory,
433 'third_party', 433 'third_party',
434 'devscripts', 434 'devscripts',
435 'licensecheck.pl')) 435 'licensecheck.pl'))
436 436
437 licensecheck = subprocess.Popen([licensecheck_path, '-r', start_dir], 437 licensecheck = subprocess.Popen([licensecheck_path, '-r', start_dir],
438 stdout=subprocess.PIPE, 438 stdout=subprocess.PIPE,
439 stderr=subprocess.PIPE) 439 stderr=subprocess.PIPE)
440 stdout, stderr = licensecheck.communicate() 440 stdout, stderr = licensecheck.communicate()
441 if options.verbose: 441 if options.verbose:
442 print '----------- licensecheck stdout -----------' 442 print '----------- licensecheck stdout -----------'
443 print stdout 443 print stdout
444 print '--------- end licensecheck stdout ---------' 444 print '--------- end licensecheck stdout ---------'
445 if licensecheck.returncode != 0 or stderr: 445 if licensecheck.returncode != 0 or stderr:
446 print '----------- licensecheck stderr -----------' 446 print '----------- licensecheck stderr -----------'
447 print stderr 447 print stderr
448 print '--------- end licensecheck stderr ---------' 448 print '--------- end licensecheck stderr ---------'
449 print "\nFAILED\n" 449 print "\nFAILED\n"
450 sys.exit(1) 450 return 1
451 451
452 success = True 452 success = True
453 for line in stdout.splitlines(): 453 for line in stdout.splitlines():
454 filename, license = line.split(':', 1) 454 filename, license = line.split(':', 1)
455 filename = os.path.relpath(filename.strip(), options.base_directory) 455 filename = os.path.relpath(filename.strip(), options.base_directory)
456 456
457 # All files in the build output directory are generated one way or another. 457 # All files in the build output directory are generated one way or another.
458 # There's no need to check them. 458 # There's no need to check them.
459 if filename.startswith('out/') or filename.startswith('sconsbuild/'): 459 if filename.startswith('out/') or filename.startswith('sconsbuild/'):
460 continue 460 continue
(...skipping 16 matching lines...) Expand all
477 found_path_specific = True 477 found_path_specific = True
478 break 478 break
479 if found_path_specific: 479 if found_path_specific:
480 continue 480 continue
481 481
482 print "'%s' has non-whitelisted license '%s'" % (filename, license) 482 print "'%s' has non-whitelisted license '%s'" % (filename, license)
483 success = False 483 success = False
484 484
485 if success: 485 if success:
486 print "\nSUCCESS\n" 486 print "\nSUCCESS\n"
487 sys.exit(0) 487 return 0
488 else: 488 else:
489 print "\nFAILED\n" 489 print "\nFAILED\n"
490 print "Please read", 490 print "Please read",
491 print "http://www.chromium.org/developers/adding-3rd-party-libraries" 491 print "http://www.chromium.org/developers/adding-3rd-party-libraries"
492 print "for more info how to handle the failure." 492 print "for more info how to handle the failure."
493 print 493 print
494 print "Please respect OWNERS of checklicenses.py. Changes violating" 494 print "Please respect OWNERS of checklicenses.py. Changes violating"
495 print "this requirement may be reverted." 495 print "this requirement may be reverted."
496 496 return 1
497 sys.exit(1)
498 497
499 498
500 if '__main__' == __name__: 499 def main():
501 default_root = os.path.abspath( 500 default_root = os.path.abspath(
502 os.path.join(os.path.dirname(__file__), '..', '..')) 501 os.path.join(os.path.dirname(__file__), '..', '..'))
503 option_parser = optparse.OptionParser() 502 option_parser = optparse.OptionParser()
504 option_parser.add_option('--root', default=default_root, 503 option_parser.add_option('--root', default=default_root,
505 dest='base_directory', 504 dest='base_directory',
506 help='Specifies the repository root. This defaults ' 505 help='Specifies the repository root. This defaults '
507 'to "../.." relative to the script file, which ' 506 'to "../.." relative to the script file, which '
508 'will normally be the repository root.') 507 'will normally be the repository root.')
509 option_parser.add_option('-v', '--verbose', action='store_true', 508 option_parser.add_option('-v', '--verbose', action='store_true',
510 default=False, help='Print debug logging') 509 default=False, help='Print debug logging')
511 option_parser.add_option('--ignore-suppressions', 510 option_parser.add_option('--ignore-suppressions',
512 action='store_true', 511 action='store_true',
513 default=False, 512 default=False,
514 help='Ignore path-specific license whitelist.') 513 help='Ignore path-specific license whitelist.')
515 options, args = option_parser.parse_args() 514 options, args = option_parser.parse_args()
516 main(options, args) 515 return check_licenses(options, args)
516
517
518 if '__main__' == __name__:
519 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/checkdeps/checkdeps.py ('k') | tools/clang/scripts/update.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698