<commit_before># coding=utf-8

"""
Get ceph status from one node
"""

import subprocess
import re
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)),
                                'ceph'))
from ceph import CephCollector


# This is external to the CephCollector so it can be tested
# separately.
def process_ceph_status(output):
    pattern = re.compile(r'\bclient io .*')
    res = pattern.search(output)
    if not res:
        return {}
    try:
        ceph_stats = res.group()
        number = re.compile(r'\d+')
        rd = number.search(ceph_stats)
        if rd:
            wr = number.search(ceph_stats, rd.end())
            if wr:
                iops = number.search(ceph_stats, wr.end())
        ret = {}
        if rd:
            ret['rd'] = rd.group()
        if wr:
            ret['wr'] = wr.group()
        if iops:
            ret['iops'] = iops.group()
        return ret
    except:
        return {}
<commit_msg>fixes in response to review comments<commit_after># coding=utf-8

"""
Get ceph status from one node
"""

import subprocess
import re
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)),
                                'ceph'))
from ceph import CephCollector

patternchk = re.compile(r'\bclient io .*')
numberchk = re.compile(r'\d+')


# This is external to the CephCollector so it can be tested
# separately.
def process_ceph_status(output):
    if 'client io' not in output:
        return {}
    res = patternchk.search(output)
    if not res:
        return {}
    ceph_stats = res.group()
    if not ceph_stats:
        return {}
    rd = wr = iops = None
    rd = numberchk.search(ceph_stats)
    if rd:
        wr = numberchk.search(ceph_stats, rd.end())
        if wr:
            iops = numberchk.search(ceph_stats, wr.end())
    ret = {}
    if rd:
        ret['rd'] = rd.group()
    if wr:
        ret['wr'] = wr.group()
    if iops:
        ret['iops'] = iops.group()
    return ret

{'fraction_non_alphanumeric': 0.12413452027695351, 'fraction_numerical': 0.0019782393669634025, 'mean_word_length': 2.0885496183206107, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2349531', 'n_tokens_mistral': 674, 'n_tokens_neox': 663, 'n_words': 177}