<commit_before>import logging

from crispy.lib.module import *
from crispy.lib.fprint import *

logger = logging.getLogger(__name__)

__class_name__ = "PSModule"
class PSModule(CrispyModule):
    """ Get process list on a remote machine. """

    # can be: 'Darwin', 'Linux', 'Windows', 'Android'
    compatible_systems = ['all']

    def run(self, args):
        logger.debug("run(args) was called")
        info("Getting process list now...")

        if (self.is_compatible()):
            print "\nCurrent Process List\n==================="

            try:
#                if self.client.is_darwin():
                    for proc in self.client.conn.modules['psutil'].process_iter():
                        try:
                            pids = proc.as_dict(attrs=['pid', 'name'])
                        except psutil.NoSuchProcess:
                            pass
                        else:
                            print(pids)
            except Exception as e:
                logger.error(e)
                error(e)

            success("Done.")
        else:
            error("Current OS's supported: {}".format(', '.join(self.compatible_systems)))
<commit_msg>added highlighting and format<commit_after>import logging

from crispy.lib.module import *
from crispy.lib.fprint import *

logger = logging.getLogger(__name__)

__class_name__ = "PSModule"
class PSModule(CrispyModule):
    """ Get process list on a remote machine. """

    # can be: 'Darwin', 'Linux', 'Windows', 'Android'
    compatible_systems = ['all']

    def run(self, args):
        logger.debug("run(args) was called")

        if (self.is_compatible()):
            spacing = "{:<5}{:<15}"
            print spacing.format("PID", "Name")

            cpid = self.client.conn.modules['os'].getpid()
            try:
#                if self.client.is_darwin():
                    for proc in self.client.conn.modules['psutil'].process_iter():
                        try:
                            pid = proc.as_dict(attrs=['pid', 'name'])
                        except psutil.NoSuchProcess:
                            pass
                        if pid['pid'] == cpid:
                            highlight(spacing.format(pid['pid'], pid['name']), "yellow")
                        else:
                            print spacing.format(pid['pid'], pid['name'])
            except Exception as e:
                logger.error(e)
                error(e)

            success("Done.")
        else:
            error("Current OS's supported: {}".format(', '.join(self.compatible_systems)))

{'fraction_non_alphanumeric': 0.13425925925925927, 'fraction_numerical': 0.0011574074074074073, 'mean_word_length': 1.640529531568228, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4969928', 'n_tokens_mistral': 713, 'n_tokens_neox': 667, 'n_words': 158}