<commit_before>import re
from subprocess import Popen, PIPE
from itertools import chain

def is_local_unix_process_active(reobj, ps_cmd=('ps', 'aux')):
    with Popen(ps_cmd, stdout=PIPE, stderr=PIPE,
            universal_newlines=True) as proc:
        matched_processes = [l for l in proc.stdout.read().splitlines()
                if reobj.match(l)]
    return len(matched_processes) > 0

def is_remote_unix_process_active(reobj, remote_id, ps_cmd=('ps', 'aux'),
        client_cmd=('ssh',)):
    popen_args = tuple(chain(client_cmd, (remote_id,), ps_cmd))
    with Popen(popen_args, stdout=PIPE, stderr=PIPE,
            universal_newlines=True) as proc:
        matched_processes = [l for l in proc.stdout.read().splitlines()
                if reobj.match(l)]
    return len(matched_processes) > 0

def is_local_anki_desktop_active(pattern=r'.*python.*anki',
        ps_cmd=('ps', 'aux')):
    reobj = re.compile(pattern, re.IGNORECASE)
    return is_local_unix_process_active(reobj, ps_cmd)

def is_remote_ankidroid_active(hostname, user=None,
        pattern=r'.*com.ichi2.anki.*', ps_cmd=('ps',)):
    reobj = re.compile(pattern, re.IGNORECASE)
    remote_id = '@'.join(user, hostname) if user else hostname
    return is_remote_unix_process_active(reobj, remote_id, ps_cmd)<commit_msg>Updated pattern of anki desktop process<commit_after>import re
from subprocess import Popen, PIPE
from itertools import chain

def is_local_unix_process_active(reobj, ps_cmd=('ps', 'aux')):
    with Popen(ps_cmd, stdout=PIPE, stderr=PIPE,
            universal_newlines=True) as proc:
        matched_processes = [l for l in proc.stdout.read().splitlines()
                if reobj.match(l)]
    return len(matched_processes) > 0

def is_remote_unix_process_active(reobj, remote_id, ps_cmd=('ps', 'aux'),
        client_cmd=('ssh',)):
    popen_args = tuple(chain(client_cmd, (remote_id,), ps_cmd))
    with Popen(popen_args, stdout=PIPE, stderr=PIPE,
            universal_newlines=True) as proc:
        matched_processes = [l for l in proc.stdout.read().splitlines()
                if reobj.match(l)]
    return len(matched_processes) > 0

def is_local_anki_desktop_active(pattern=r'.*python.*bin/anki',
        ps_cmd=('ps', 'aux')):
    reobj = re.compile(pattern, re.IGNORECASE)
    return is_local_unix_process_active(reobj, ps_cmd)

def is_remote_ankidroid_active(hostname, user=None,
        pattern=r'.*com.ichi2.anki.*', ps_cmd=('ps',)):
    reobj = re.compile(pattern, re.IGNORECASE)
    remote_id = '@'.join(user, hostname) if user else hostname
    return is_remote_unix_process_active(reobj, remote_id, ps_cmd)
{'fraction_non_alphanumeric': 0.12547673531655226, 'fraction_numerical': 0.002288329519450801, 'mean_word_length': 4.053949903660886, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1313817', 'n_tokens_mistral': 935, 'n_tokens_neox': 925, 'n_words': 184}