<commit_before>#!/usr/bin/python

import json
import platform
import subprocess

PLUGIN_VERSION = "1"
HEARTBEAT="true"

data={}
data['plugin_version'] = PLUGIN_VERSION
data['heartbeat_required']=HEARTBEAT

commands = {'packages_to_be_updated':'yum updateinfo list available | wc -l','security_updates':'yum updateinfo list security all | wc -l'}

os_info = platform.linux_distribution()[0].lower()

def get_command_output(command):
    p = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
    (output, err) = p.communicate()
    p_status = p.wait()
    return output

if 'centos' in os_info or 'red hat' in os_info:
    for each_cmd,each_val in commands.items():
        out = get_command_output(each_val)
        if out:
            out = out.rstrip()
            out = int(out) - 7
            data[each_cmd] = out
else:
    FILE_PATH='/var/lib/update-notifier/updates-available'
    lines = [line.strip('\n') for line in open(FILE_PATH)]
    for line in lines:
        if 'packages can be updated' in line:
            data['packages_to_be_updated'] = line.split()[0]
        if 'updates are security updates' in line:
            data['security_updates'] = line.split()[0]
print(json.dumps(data))<commit_msg>Security update count issue fixed.<commit_after>#!/usr/bin/python

import json
import platform
import subprocess

PLUGIN_VERSION = "1"
HEARTBEAT="true"

data={}
data['plugin_version'] = PLUGIN_VERSION
data['heartbeat_required']=HEARTBEAT

command="yum check-update --security | grep -i 'needed for security'"

os_info = platform.linux_distribution()[0].lower()

def get_command_output(command):
    p = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
    (output, err) = p.communicate()
    p_status = p.wait()
    return output

if 'centos' in os_info or 'red hat' in os_info:
        out = get_command_output(command)
        if out:
            out = out.rstrip()
            count = out.split("needed for security")
            security_count = count[0].split()[0]
            if security_count == 'No':
            	data['security_updates'] = 0
            else:
               data['security_updates'] = security_count
            packages_count = count[1].split()
            for each in packages_count:
                 if each.isdigit():
                     data['packages_to_be_updated']=each
                
else:	
    FILE_PATH='/var/lib/update-notifier/updates-available'
    lines = [line.strip('\n') for line in open(FILE_PATH)]
    for line in lines:
        if 'packages can be updated' in line:
            data['packages_to_be_updated'] = line.split()[0]
        if 'updates are security updates' in line:
            data['security_updates'] = line.split()[0]
print(json.dumps(data))
{'fraction_non_alphanumeric': 0.1228134110787172, 'fraction_numerical': 0.0047376093294460644, 'mean_word_length': 3.001457725947522, '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': '2737202', 'n_tokens_mistral': 875, 'n_tokens_neox': 864, 'n_words': 206}