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

import salt.utils
import salt.modules.cmdmod

__salt__ = {'cmd.run': salt.modules.cmdmod._run_quiet}


def osquerygrain():
    '''
    Return osquery version in grain
    '''
    # Provides:
    #   osqueryversion
    #   osquerybinpath
    grains = {}
    option = '--version'

    # Prefer our /opt/osquery/osqueryi if present
    osqueryipaths = ('/opt/osquery/osqueryi', 'osqueryi', '/usr/bin/osqueryi')
    for path in osqueryipaths:
        if salt.utils.which(path):
            for item in __salt__['cmd.run']('{0} {1}'.format(path, option)).split():
                if item[:1].isdigit():
                    grains['osqueryversion'] = item
                    grains['osquerybinpath'] = salt.utils.which(path)
                    break
            break
    return grains
<commit_msg>DeprecationWarning: Use of salt.utils.which detected. This function has been moved to salt.utils.path.which as of Salt 2018.3.0<commit_after># -*- coding: utf-8 -*-

import salt.utils
import salt.modules.cmdmod

__salt__ = {'cmd.run': salt.modules.cmdmod._run_quiet}


def osquerygrain():
    '''
    Return osquery version in grain
    '''
    # Provides:
    #   osqueryversion
    #   osquerybinpath
    grains = {}
    option = '--version'

    # Prefer our /opt/osquery/osqueryi if present
    osqueryipaths = ('/opt/osquery/osqueryi', 'osqueryi', '/usr/bin/osqueryi')
    for path in osqueryipaths:
        if salt.utils.path.which(path):
            for item in __salt__['cmd.run']('{0} {1}'.format(path, option)).split():
                if item[:1].isdigit():
                    grains['osqueryversion'] = item
                    grains['osquerybinpath'] = salt.utils.path.which(path)
                    break
            break
    return grains

{'fraction_non_alphanumeric': 0.13448660714285715, 'fraction_numerical': 0.0078125, 'mean_word_length': 2.2248201438848922, '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': '5135661', 'n_tokens_mistral': 587, 'n_tokens_neox': 560, 'n_words': 123}