sha module is deprecated
This patch removes the deprecated warnings from the python
scripts.
Change-Id: I052a0aab3fb28dd1d78de1307edafda6b6c35e5f
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 52e7aed..fd098ea 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -20,7 +20,6 @@
import os
import platform
import re
-import sha
import shutil
import subprocess
import sys
@@ -29,6 +28,11 @@
import time
import zipfile
+try:
+ from hashlib import sha1 as sha1
+except ImportError:
+ from sha import sha as sha1
+
# missing in Python 2.4 and before
if not hasattr(os, "SEEK_SET"):
os.SEEK_SET = 0
@@ -659,7 +663,7 @@
self.name = name
self.data = data
self.size = len(data)
- self.sha1 = sha.sha(data).hexdigest()
+ self.sha1 = sha1(data).hexdigest()
def WriteToTemp(self):
t = tempfile.NamedTemporaryFile()