<commit_before># -*- coding: utf-8 -*-

import re
import subprocess
import sys

from SLConfigReader import get_aapt_config, get_adb_config
from SLHelper import keep_window_open

adb_exec = get_adb_config()
adb_shell = (adb_exec, 'shell')
aapt_exec = get_aapt_config()


def check_config():
    if not adb_exec:
        print('Error: adb executable path not configured.')
        keep_window_open()
        sys.exit(0)

    if not aapt_exec:
        print('Error: aapt executable path not configured.')
        keep_window_open()
        sys.exit(0)


def check_android_device():
    if subprocess.call(adb_shell + ('id',), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL):
        print('Error: no Android device connected.')
        keep_window_open()
        sys.exit(0)


def get_all_android_apps():
    all_packages_info = subprocess.check_output(adb_shell + ('cmd', 'package', 'list', 'packages', '-f', '-3'))
    for line in all_packages_info.decode().split('\r\n'):
        line = line.strip()

        if line:
            package_path, package_name = re.findall(r'package:(.*)=(.*)', line)[0]
            package_info = subprocess.check_output(adb_shell + (aapt_exec, 'd', 'badging', package_path))<commit_msg>Ignore error return code from aapt<commit_after># -*- coding: utf-8 -*-

import re
import subprocess
import sys

from SLConfigReader import get_aapt_config, get_adb_config
from SLHelper import keep_window_open

adb_exec = get_adb_config()
adb_shell = (adb_exec, 'shell')
aapt_exec = get_aapt_config()


def check_config():
    if not adb_exec:
        print('Error: adb executable path not configured.')
        keep_window_open()
        sys.exit(0)

    if not aapt_exec:
        print('Error: aapt executable path not configured.')
        keep_window_open()
        sys.exit(0)


def check_android_device():
    if subprocess.call(adb_shell + ('id',), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL):
        print('Error: no Android device connected.')
        keep_window_open()
        sys.exit(0)


def get_all_android_apps():
    all_packages_info = subprocess.check_output(adb_shell + ('cmd', 'package', 'list', 'packages', '-f', '-3'))
    for line in all_packages_info.decode().split('\r\n'):
        line = line.strip()

        if line:
            package_path, package_name = re.findall(r'package:(.*)=(.*)', line)[0]

            package_info = subprocess.run(adb_shell + (aapt_exec, 'd', 'badging', package_path),
                                          check=False, stdout=subprocess.PIPE).stdout
{'fraction_non_alphanumeric': 0.12877895563407932, 'fraction_numerical': 0.004711425206124852, 'mean_word_length': 3.2823529411764705, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4974971', 'n_tokens_mistral': 834, 'n_tokens_neox': 821, 'n_words': 188}