Skip to content

Instantly share code, notes, and snippets.

@TheRealJunior
Last active May 13, 2019 13:50
Show Gist options
  • Select an option

  • Save TheRealJunior/e3a47caf27adeb0c02b8024ff8d4404f to your computer and use it in GitHub Desktop.

Select an option

Save TheRealJunior/e3a47caf27adeb0c02b8024ff8d4404f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys, subprocess
from logzero import logger
def get_tombstone_list():
output = str(subprocess.check_output(['adb', 'shell', 'su -c "ls /tombstones/"']), 'utf-8')
tombstone_lines = [tombstone.strip() for tombstone in output.split('\n') if 'tombstone' in tombstone]
return tombstone_lines
def pull_tombstones(tombstone_list):
for tombstone in tombstone_list:
logger.info('pulling %s -> ../tombstones/%s' % (tombstone, tombstone))
subprocess.check_call(['adb', 'pull', '/tombstones/%s' % tombstone, '../tombstones/'])
def remove_tombstones():
subprocess.check_call(['adb', 'shell', 'su -c "rm /tombstones/tombstone_*"'])
def main():
try:
option = sys.argv[1]
except Exception as e:
option = 'pull'
tombstone_list = get_tombstone_list()
if option == 'pull':
pull_tombstones(tombstone_list)
elif option == 'clear':
remove_tombstones()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment