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

Unified Diff: tools/bots/bot_utils.py

Issue 440233005: Added sha256 sums for build outputs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Take ricow's suggestions Created 6 years, 4 months 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 | « editor/build/build.py ('k') | tools/dartium/upload_steps.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/bots/bot_utils.py
diff --git a/tools/bots/bot_utils.py b/tools/bots/bot_utils.py
index b2bf9a71b38ccc9688a732923274340a4463e008..565ee5ae3043a4cf40586881b3af4ba5de9cd71a 100644
--- a/tools/bots/bot_utils.py
+++ b/tools/bots/bot_utils.py
@@ -313,7 +313,7 @@ class GSUtil(object):
args += [remote_path]
self.execute(args)
-def CalculateChecksum(filename):
+def CalculateMD5Checksum(filename):
"""Calculate the MD5 checksum for filename."""
md5 = hashlib.md5()
@@ -326,12 +326,25 @@ def CalculateChecksum(filename):
return md5.hexdigest()
-def CreateChecksumFile(filename, mangled_filename=None):
+def CalculateSha256Checksum(filename):
+ """Calculate the sha256 checksum for filename."""
+
+ sha = hashlib.sha256()
+
+ with open(filename, 'rb') as f:
+ data = f.read(65536)
+ while len(data) > 0:
+ sha.update(data)
+ data = f.read(65536)
+
+ return sha.hexdigest()
+
+def CreateMD5ChecksumFile(filename, mangled_filename=None):
"""Create and upload an MD5 checksum file for filename."""
if not mangled_filename:
mangled_filename = os.path.basename(filename)
- checksum = CalculateChecksum(filename)
+ checksum = CalculateMD5Checksum(filename)
checksum_filename = '%s.md5sum' % filename
with open(checksum_filename, 'w') as f:
@@ -339,6 +352,19 @@ def CreateChecksumFile(filename, mangled_filename=None):
return checksum_filename
+def CreateSha256ChecksumFile(filename, mangled_filename=None):
+ """Create and upload an sha256 checksum file for filename."""
+ if not mangled_filename:
+ mangled_filename = os.path.basename(filename)
+
+ checksum = CalculateSha256Checksum(filename)
+ checksum_filename = '%s.sha256sum' % filename
+
+ with open(checksum_filename, 'w') as f:
+ f.write('%s *%s' % (checksum, mangled_filename))
+
+ return checksum_filename
+
def GetChannelFromName(name):
"""Get the channel from the name. Bleeding edge builders don't
have a suffix."""
« no previous file with comments | « editor/build/build.py ('k') | tools/dartium/upload_steps.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698