Index: build/android/tombstones.py |
diff --git a/build/android/tombstones.py b/build/android/tombstones.py |
index 712f90fac81dd3f51d2e6906f684388c1b2bd896..72ddde99a477f62f76696fe2688b38f02b971b89 100755 |
--- a/build/android/tombstones.py |
+++ b/build/android/tombstones.py |
@@ -170,12 +170,14 @@ def _ResolveTombstones(jobs, tombstones): |
logging.info(line) |
-def _GetTombstonesForDevice(device, args): |
+def _GetTombstonesForDevice(device, every_tombstone, stack, wipe_tombstones): |
"""Returns a list of tombstones on a given device. |
Args: |
device: An instance of DeviceUtils. |
- args: command line arguments |
+ every_tombstone: Whether to resolve every tombstone. |
mikecase (-- gone --)
2016/08/01 22:44:30
Maybe rename to resolve_all_tombstones.
Its awkwa
BigBossZhiling
2016/08/01 23:04:35
Done.
|
+ stack: Stack. |
mikecase (-- gone --)
2016/08/01 22:44:30
Probably at least write the datatype for the stack
BigBossZhiling
2016/08/01 23:04:35
I think it is boolean. But I don't know what this
|
+ wipe_tombstones: Whether to wipe tombstones. |
""" |
ret = [] |
all_tombstones = list(_ListTombstones(device)) |
@@ -187,7 +189,7 @@ def _GetTombstonesForDevice(device, args): |
all_tombstones.sort(cmp=lambda a, b: cmp(b[1], a[1])) |
# Only resolve the most recent unless --all-tombstones given. |
- tombstones = all_tombstones if args.all_tombstones else [all_tombstones[0]] |
+ tombstones = all_tombstones if every_tombstone else [all_tombstones[0]] |
device_now = _GetDeviceDateTime(device) |
try: |
@@ -197,7 +199,7 @@ def _GetTombstonesForDevice(device, args): |
'device_now': device_now, |
'time': tombstone_time, |
'file': tombstone_file, |
- 'stack': args.stack, |
+ 'stack': stack, |
'data': _GetTombstoneData(device, tombstone_file)}] |
except device_errors.CommandFailedError: |
for entry in device.StatDirectory( |
@@ -206,12 +208,31 @@ def _GetTombstonesForDevice(device, args): |
raise |
# Erase all the tombstones if desired. |
- if args.wipe_tombstones: |
+ if wipe_tombstones: |
for tombstone_file, _ in all_tombstones: |
_EraseTombstone(device, tombstone_file) |
return ret |
+def ClearAllTombstones(device): |
+ """Clear all tombstones in the device. |
+ |
+ Args: |
+ device: An instance of DeviceUtils. |
+ """ |
+ all_tombstones = list(_ListTombstones(device)) |
+ if not all_tombstones: |
+ logging.warning('No tombstones.') |
mikecase (-- gone --)
2016/08/01 22:44:30
Maybe slightly more descriptive warning. Like "No
BigBossZhiling
2016/08/01 23:04:35
Done.
|
+ |
+ for tombstone_file, _ in all_tombstones: |
+ _EraseTombstone(device, tombstone_file) |
+ |
+def ResolveAllTombstones(device, all_tombstones, stack, wipe_tombstones, |
+ jobs=4): |
+ return _ResolveTombstones(jobs, |
+ _GetTombstonesForDevice(device, |
+ all_tombstones, |
+ stack, wipe_tombstones)) |
def main(): |
custom_handler = logging.StreamHandler(sys.stdout) |
@@ -260,12 +281,9 @@ def main(): |
# This must be done serially because strptime can hit a race condition if |
# used for the first time in a multithreaded environment. |
# http://bugs.python.org/issue7980 |
- tombstones = [] |
for device in devices: |
- tombstones += _GetTombstonesForDevice(device, args) |
- |
- _ResolveTombstones(args.jobs, tombstones) |
- |
+ ResolveAllTombstones(device, args.all_tombstones, |
mikecase (-- gone --)
2016/08/01 22:44:30
This indentation looks off.
BigBossZhiling
2016/08/01 23:04:35
Done.
|
+ args.stack, args.wipe_tombstones, args.jobs) |
if __name__ == '__main__': |
sys.exit(main()) |