<commit_before># Copyright (C) 2015 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import flask
import json
import psutil
import time

from webgui.p_haul_web_gui import APP


@APP.route('/procs')
def procs():
    """
        This function is responsible for listing the processes on this machine as
        a JSON object, where children processes are stored hierarchically
        beneath their parent processes.
    """

    def generate():
        """
            Respond to an HTTP GET request with a stream of events containing
            JSON strings.
        """

        oldroot = {}

        while True:
            flatprocs = []
            root = {}

            for p in psutil.process_iter():
                if callable(p.cmdline):
                    name = os.path.basename(p.cmdline()[0])
                    if name is '':
                        name = p.name()
                else:<commit_msg>p.haul: fixing imports and checking 0 length<commit_after># Copyright (C) 2015 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import flask
import json
import psutil
import time
import os

from webgui.p_haul_web_gui import APP


@APP.route('/procs')
def procs():
    """
        This function is responsible for listing the processes on this machine as
        a JSON object, where children processes are stored hierarchically
        beneath their parent processes.
    """

    def generate():
        """
            Respond to an HTTP GET request with a stream of events containing
            JSON strings.
        """

        oldroot = {}

        while True:
            flatprocs = []
            root = {}

            for p in psutil.process_iter():
                if callable(p.cmdline):
                    if len(p.cmdline()) > 0:
                        name = os.path.basename(p.cmdline()[0])
                    if name is '':
                        name = p.name()
                else:
{'fraction_non_alphanumeric': 0.06827924066135946, 'fraction_numerical': 0.011022657685241886, 'mean_word_length': 2.316751269035533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '1725805', 'n_tokens_mistral': 848, 'n_tokens_neox': 787, 'n_words': 400}