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

Unified Diff: tools/coverity/coverity.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, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/code_coverage/process_coverage.py ('k') | tools/crx_id/PRESUBMIT.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/coverity/coverity.py
diff --git a/tools/coverity/coverity.py b/tools/coverity/coverity.py
old mode 100644
new mode 100755
index 2080e74662874f2deece6281c7479b67aa0cd045..6fed7ca8cfa9628f94f8ee67fd130cc8aa6a5955
--- a/tools/coverity/coverity.py
+++ b/tools/coverity/coverity.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.
@@ -77,6 +77,7 @@ COVERITY_USER = 'admin'
# Relative to CHROMIUM_SOURCE_DIR. Contains the pid of this script.
LOCK_FILE = 'coverity.lock'
+
def _ReadPassword(pwfilename):
"""Reads the coverity password in from a file where it was stashed"""
pwfile = open(pwfilename, 'r')
@@ -84,6 +85,7 @@ def _ReadPassword(pwfilename):
pwfile.close()
return password.rstrip()
+
def _RunCommand(cmd, dry_run, shell=False, echo_cmd=True):
"""Runs the command if dry_run is false, otherwise just prints the command."""
if echo_cmd:
@@ -93,12 +95,14 @@ def _RunCommand(cmd, dry_run, shell=False, echo_cmd=True):
else:
return 0
+
def _ReleaseLock(lock_file, lock_filename):
"""Removes the lockfile. Function-ized so we can bail from anywhere"""
os.close(lock_file)
os.remove(lock_filename)
-def main(options, args):
+
+def run_coverity(options, args):
"""Runs all the selected tests for the given build type and target."""
# Create the lock file to prevent another instance of this script from
# running.
@@ -130,7 +134,7 @@ def main(options, args):
if gclient_exit != 0:
print 'gclient aborted with status %s' % gclient_exit
_ReleaseLock(lock_file, lock_filename)
- sys.exit(1)
+ return 1
print 'Elapsed time: %ds' % (time.time() - start_time)
@@ -145,7 +149,7 @@ def main(options, args):
else:
print 'Platform "%s" unrecognized, aborting' % sys.platform
_ReleaseLock(lock_file, lock_filename)
- sys.exit(1)
+ return 1
if options.dry_run:
print 'shutil.rmtree(%s)' % repr(rm_path)
@@ -229,7 +233,8 @@ def main(options, args):
return 0
-if '__main__' == __name__:
+
+def main():
option_parser = optparse.OptionParser()
option_parser.add_option('', '--dry-run', action='store_true', default=False,
help='print but don\'t run the commands')
@@ -296,6 +301,8 @@ if '__main__' == __name__:
default=False)
options, args = option_parser.parse_args()
+ return run_coverity(options, args)
- result = main(options, args)
- sys.exit(result)
+
+if '__main__' == __name__:
+ sys.exit(main())
« no previous file with comments | « tools/code_coverage/process_coverage.py ('k') | tools/crx_id/PRESUBMIT.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698