summaryrefslogtreecommitdiffstats
path: root/tools/symsrc
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-29 17:25:34 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-29 17:25:34 +0000
commitcb155a802bdc49cfafea1c41e0f0a92168f1da09 (patch)
treebf0fae4855c7f4458d8e959455b9d12d6cd54d9d /tools/symsrc
parent9bec23957253b83955c4096903ad6293d1c6e1bb (diff)
downloadchromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.zip
chromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.tar.gz
chromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.tar.bz2
Fix python scripts in src/tools/
Make sure that: - shebang is only present for executable files - shebang is #!/usr/bin/env python - __main__ is only present for executable files - file's executable bit is coherent Also fix EOF LF to be only one. TBR=timurrrr@chromium.org BUG=105108 TEST= Review URL: http://codereview.chromium.org/8678023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111960 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/symsrc')
-rwxr-xr-x[-rw-r--r--]tools/symsrc/img_fingerprint.py24
-rwxr-xr-x[-rw-r--r--]tools/symsrc/pdb_fingerprint_from_img.py19
-rwxr-xr-x[-rw-r--r--]tools/symsrc/source_index.py18
3 files changed, 42 insertions, 19 deletions
diff --git a/tools/symsrc/img_fingerprint.py b/tools/symsrc/img_fingerprint.py
index 5b3c414..c4b6395 100644..100755
--- a/tools/symsrc/img_fingerprint.py
+++ b/tools/symsrc/img_fingerprint.py
@@ -1,28 +1,34 @@
#!/usr/bin/env python
-
-# Copyright (c) 2008 The Chromium Authors. All rights reserved.
+# 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.
-"""This will retrieve an image's "fingerprint". This is used when retrieving
-the image from the symbol server. The .dll (or cab compressed .dl_) or .exe
-is expected at a path like:
- foo.dll/FINGERPRINT/foo.dll"""
+"""Retrieves an image's "fingerprint".
+
+This is used when retrieving the image from the symbol server. The .dll (or cab
+compressed .dl_) or .exe is expected at a path like:
+ foo.dll/FINGERPRINT/foo.dll
+"""
import sys
import pefile
+
def GetImgFingerprint(filename):
"""Returns the fingerprint for an image file"""
-
pe = pefile.PE(filename)
return "%08X%06x" % (
pe.FILE_HEADER.TimeDateStamp, pe.OPTIONAL_HEADER.SizeOfImage)
-if __name__ == '__main__':
+def main():
if len(sys.argv) != 2:
print "usage: file.dll"
- sys.exit(1)
+ return 1
print GetImgFingerprint(sys.argv[1])
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/tools/symsrc/pdb_fingerprint_from_img.py b/tools/symsrc/pdb_fingerprint_from_img.py
index c7dae50..e994475 100644..100755
--- a/tools/symsrc/pdb_fingerprint_from_img.py
+++ b/tools/symsrc/pdb_fingerprint_from_img.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python
-
-# Copyright (c) 2008 The Chromium Authors. All rights reserved.
+# 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.
@@ -16,12 +15,14 @@ DLL's reference to the PDB, and use that to retrieve the information."""
import sys
import pefile
+
__CV_INFO_PDB70_format__ = ('CV_INFO_PDB70',
('4s,CvSignature', '16s,Signature', 'L,Age'))
__GUID_format__ = ('GUID',
('L,Data1', 'H,Data2', 'H,Data3', '8s,Data4'))
+
def GetPDBInfoFromImg(filename):
"""Returns the PDB fingerprint and the pdb filename given an image file"""
@@ -48,10 +49,16 @@ def GetPDBInfoFromImg(filename):
break
-if __name__ == '__main__':
+
+def main():
if len(sys.argv) != 2:
print "usage: file.dll"
- sys.exit(1)
+ return 1
+
+ (fingerprint, filename) = GetPDBInfoFromImg(sys.argv[1])
+ print "%s %s" % (fingerprint, filename)
+ return 0
- (fingerprint, file) = GetPDBInfoFromImg(sys.argv[1])
- print "%s %s" % (fingerprint, file)
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/tools/symsrc/source_index.py b/tools/symsrc/source_index.py
index 8160872..e2a58e0 100644..100755
--- a/tools/symsrc/source_index.py
+++ b/tools/symsrc/source_index.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python
-
-# Copyright (c) 2008 The Chromium Authors. All rights reserved.
+# 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.
@@ -45,6 +44,7 @@ REPO_MAP = {
"http://google-url.googlecode.com/svn": None,
}
+
def FindFile(filename):
"""Return the full windows path to a file in the same dir as this code."""
thisdir = os.path.dirname(os.path.join(os.path.curdir, __file__))
@@ -61,6 +61,7 @@ def ExtractSourceFiles(pdb_filename):
raise "srctool failed: " + filelist
return [x for x in filelist.split('\r\n') if len(x) != 0]
+
def ReadSourceStream(pdb_filename):
"""Read the contents of the source information stream from a PDB."""
srctool = subprocess.Popen([FindFile('pdbstr.exe'),
@@ -74,6 +75,7 @@ def ReadSourceStream(pdb_filename):
raise "pdbstr failed: " + data
return data
+
def WriteSourceStream(pdb_filename, data):
"""Write the contents of the source information stream to a PDB."""
# Write out the data to a temporary filename that we can pass to pdbstr.
@@ -95,6 +97,7 @@ def WriteSourceStream(pdb_filename, data):
os.unlink(fname)
+
# TODO for performance, we should probably work in directories instead of
# files. I'm scared of DEPS and generated files, so for now we query each
# individual file, and don't make assumptions that all files in the same
@@ -119,6 +122,7 @@ def ExtractSvnInfo(local_filename):
return [root, path, rev]
+
def UpdatePDB(pdb_filename, verbose=False):
"""Update a pdb file with source information."""
dir_blacklist = { }
@@ -190,13 +194,19 @@ def UpdatePDB(pdb_filename, verbose=False):
WriteSourceStream(pdb_filename, '\r\n'.join(lines))
-if __name__ == '__main__':
+
+def main():
if len(sys.argv) < 2 or len(sys.argv) > 3:
print "usage: file.pdb [-v]"
- sys.exit(1)
+ return 1
verbose = False
if len(sys.argv) == 3:
verbose = (sys.argv[2] == '-v')
UpdatePDB(sys.argv[1], verbose=verbose)
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())