Fix import error in mac_platform_backend.py
[chromium-blink-merge.git] / tools / symsrc / img_fingerprint.py
blobc4b6395b87f5dc43b06543481738d6c1a0708b7a
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
6 """Retrieves an image's "fingerprint".
8 This is used when retrieving the image from the symbol server. The .dll (or cab
9 compressed .dl_) or .exe is expected at a path like:
10 foo.dll/FINGERPRINT/foo.dll
11 """
13 import sys
14 import pefile
17 def GetImgFingerprint(filename):
18 """Returns the fingerprint for an image file"""
19 pe = pefile.PE(filename)
20 return "%08X%06x" % (
21 pe.FILE_HEADER.TimeDateStamp, pe.OPTIONAL_HEADER.SizeOfImage)
24 def main():
25 if len(sys.argv) != 2:
26 print "usage: file.dll"
27 return 1
29 print GetImgFingerprint(sys.argv[1])
30 return 0
33 if __name__ == '__main__':
34 sys.exit(main())