Skip to content

Commit df84ca5

Browse files
committed
Changed sh.md5sum calls to python implementation
1 parent f2896af commit df84ca5

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

pythonforandroid/recipe.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from shutil import rmtree
66
from six import PY2, with_metaclass
77

8+
import hashlib
9+
810
import sh
911
import shutil
1012
import fnmatch
@@ -360,9 +362,9 @@ def download(self):
360362
if not exists(marker_filename):
361363
shprint(sh.rm, filename)
362364
elif self.md5sum:
363-
current_md5 = shprint(sh.md5sum, filename).split()[0]
365+
current_md5 = md5sum(filename)
364366
if current_md5 == self.md5sum:
365-
debug('Downloaded expected content!')
367+
debug('Checked md5sum: downloaded expected content!')
366368
do_download = False
367369
else:
368370
info('Downloaded unexpected content...')
@@ -386,10 +388,10 @@ def download(self):
386388
shprint(sh.touch, marker_filename)
387389

388390
if exists(filename) and isfile(filename) and self.md5sum:
389-
current_md5 = shprint(sh.md5sum, filename).split()[0]
391+
current_md5 = md5sum(filename)
390392
if self.md5sum is not None:
391393
if current_md5 == self.md5sum:
392-
debug('Downloaded expected content!')
394+
debug('Checked md5sum: downloaded expected content!')
393395
else:
394396
info('Downloaded unexpected content...')
395397
debug('* Generated md5sum: {}'.format(current_md5))
@@ -1102,3 +1104,12 @@ def prebuild_arch(self, arch):
11021104
# def ctx(self, ctx):
11031105
# self._ctx = ctx
11041106
# ctx.python_recipe = self
1107+
1108+
1109+
def md5sum(filen):
1110+
'''Calculate the md5sum of a file.
1111+
'''
1112+
with open(filen, 'rb') as fileh:
1113+
md5 = hashlib.md5(fileh.read())
1114+
1115+
return md5.hexdigest()

0 commit comments

Comments
 (0)