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

Side by Side Diff: build/android/pylib/utils/md5sum.py

Issue 1127133004: Remove ICS support from build/android/pylib/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « build/android/pylib/instrumentation/test_runner.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import collections 5 import collections
6 import logging 6 import logging
7 import os 7 import os
8 import re 8 import re
9 import tempfile 9 import tempfile
10 import types 10 import types
11 11
12 from pylib import cmd_helper 12 from pylib import cmd_helper
13 from pylib import constants 13 from pylib import constants
14 from pylib.utils import device_temp_file 14 from pylib.utils import device_temp_file
15 15
16 MD5SUM_DEVICE_LIB_PATH = '/data/local/tmp/md5sum/' 16 MD5SUM_DEVICE_LIB_PATH = '/data/local/tmp/md5sum/'
17 MD5SUM_DEVICE_BIN_PATH = MD5SUM_DEVICE_LIB_PATH + 'md5sum_bin' 17 MD5SUM_DEVICE_BIN_PATH = MD5SUM_DEVICE_LIB_PATH + 'md5sum_bin'
18 18
19 MD5SUM_DEVICE_SCRIPT_FORMAT = ( 19 MD5SUM_DEVICE_SCRIPT_FORMAT = (
20 'test -f {path} -o -d {path} ' 20 'test -f {path} -o -d {path} '
21 '&& LD_LIBRARY_PATH={md5sum_lib} {device_pie_wrapper} {md5sum_bin} {path}') 21 '&& LD_LIBRARY_PATH={md5sum_lib} {md5sum_bin} {path}')
22 22
23 _STARTS_WITH_CHECKSUM_RE = re.compile(r'^\s*[0-9a-fA-f]{32}\s+') 23 _STARTS_WITH_CHECKSUM_RE = re.compile(r'^\s*[0-9a-fA-f]{32}\s+')
24 24
25 25
26 def CalculateHostMd5Sums(paths): 26 def CalculateHostMd5Sums(paths):
27 """Calculates the MD5 sum value for all items in |paths|. 27 """Calculates the MD5 sum value for all items in |paths|.
28 28
29 Args: 29 Args:
30 paths: A list of host paths to md5sum. 30 paths: A list of host paths to md5sum.
31 Returns: 31 Returns:
(...skipping 26 matching lines...) Expand all
58 md5sum_dist_path = os.path.join(constants.GetOutDirectory(), 'md5sum_dist') 58 md5sum_dist_path = os.path.join(constants.GetOutDirectory(), 'md5sum_dist')
59 if not os.path.exists(md5sum_dist_path): 59 if not os.path.exists(md5sum_dist_path):
60 raise IOError('File not built: %s' % md5sum_dist_path) 60 raise IOError('File not built: %s' % md5sum_dist_path)
61 device.adb.Push(md5sum_dist_path, MD5SUM_DEVICE_LIB_PATH) 61 device.adb.Push(md5sum_dist_path, MD5SUM_DEVICE_LIB_PATH)
62 62
63 out = [] 63 out = []
64 64
65 with tempfile.NamedTemporaryFile() as md5sum_script_file: 65 with tempfile.NamedTemporaryFile() as md5sum_script_file:
66 with device_temp_file.DeviceTempFile( 66 with device_temp_file.DeviceTempFile(
67 device.adb) as md5sum_device_script_file: 67 device.adb) as md5sum_device_script_file:
68 device_pie_wrapper = device.GetDevicePieWrapper()
69 md5sum_script = ( 68 md5sum_script = (
70 MD5SUM_DEVICE_SCRIPT_FORMAT.format( 69 MD5SUM_DEVICE_SCRIPT_FORMAT.format(
71 path=p, md5sum_lib=MD5SUM_DEVICE_LIB_PATH, 70 path=p, md5sum_lib=MD5SUM_DEVICE_LIB_PATH,
72 device_pie_wrapper=device_pie_wrapper,
73 md5sum_bin=MD5SUM_DEVICE_BIN_PATH) 71 md5sum_bin=MD5SUM_DEVICE_BIN_PATH)
74 for p in paths) 72 for p in paths)
75 md5sum_script_file.write('; '.join(md5sum_script)) 73 md5sum_script_file.write('; '.join(md5sum_script))
76 md5sum_script_file.flush() 74 md5sum_script_file.flush()
77 device.adb.Push(md5sum_script_file.name, md5sum_device_script_file.name) 75 device.adb.Push(md5sum_script_file.name, md5sum_device_script_file.name)
78 out = device.RunShellCommand(['sh', md5sum_device_script_file.name]) 76 out = device.RunShellCommand(['sh', md5sum_device_script_file.name])
79 77
80 return _ParseMd5SumOutput(out) 78 return _ParseMd5SumOutput(out)
81 79
82 80
83 def _ParseMd5SumOutput(out): 81 def _ParseMd5SumOutput(out):
84 hash_and_path = (l.split(None, 1) for l in out 82 hash_and_path = (l.split(None, 1) for l in out
85 if l and _STARTS_WITH_CHECKSUM_RE.match(l)) 83 if l and _STARTS_WITH_CHECKSUM_RE.match(l))
86 return dict((p, h) for h, p in hash_and_path) 84 return dict((p, h) for h, p in hash_and_path)
87 85
OLDNEW
« no previous file with comments | « build/android/pylib/instrumentation/test_runner.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698