'Parse the ps output.
Note that cmdline consumes every field up to the end of line
and as it is string, we can\'t perfectly see what the arguments
on the command line really were. We just assume a space is the arg
seperator. It\'s imperfect, but it\'s better than nothing.
Obviously, if cmd/cmdline is specified, it must be the last
column of output.
Args:
cmd: A string containing the base command that was run.
args: A list of strings containing the commandline args for the command.
stdout: A string containing the stdout of the command run.
stderr: A string containing the stderr of the command run. (Unused)
return_val: The return code following command execution.
time_taken: The time taken to run the process. (Unused)
knowledge_base: An RDF KnowledgeBase. (Unused)
Yields:
RDF Process objects.'

def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base):

    _ = (stderr, time_taken, knowledge_base)
    self.CheckReturn(cmd, return_val)
    if (not stdout):
        return
    rdf_convert_table = {'pid': ('pid', int), 'tgid': ('pid', int), 'ppid': ('ppid', int), 'comm': ('name', str), 'ucomm': ('name', str), 'ruid': ('real_uid', int), 'uid': ('effective_uid', int), 'euid': ('effective_uid', int), 'suid': ('saved_uid', int), 'svuid': ('saved_uid', int), 'user': ('username', str), 'euser': ('username', str), 'uname': ('username', str), 'rgid': ('real_gid', int), 'gid': ('effective_gid', int), 'egid': ('effective_gid', int), 'sgid': ('saved_gid', int), 'svgid': ('saved_gid', int), 'tty': ('terminal', str), 'tt': ('terminal', str), 'tname': ('terminal', str), 'stat': ('status', str), 'nice': ('nice', int), 'ni': ('nice', int), 'thcount': ('num_threads', int), 'nlwp': ('num_threads', int), 'pcpu': ('cpu_percent', float), '%cpu': ('cpu_percent', float), 'c': ('cpu_percent', float), 'rss': ('RSS_size', long), 'rssize': ('RSS_size', long), 'rsz': ('RSS_size', long), 'vsz': ('VMS_size', long), 'vsize': ('VMS_size', long), 'pmem': ('memory_percent', float), '%mem': ('memory_percent', float), 'args': ('cmdline', self._SplitCmd), 'command': ('cmdline', self._SplitCmd), 'cmd': ('cmdline', self._SplitCmd)}
    expected_fields = self._FindPsOutputFormat(cmd, args)
    lines = stdout.splitlines()
    if self._HasHeaders(args):
        lines = lines[1:]
    for line in lines:
        try:
            entries = line.split(None, (len(expected_fields) - 1))
            process = rdf_client.Process()
            for (name, value) in zip(expected_fields, entries):
                if (name not in rdf_convert_table):
                    continue
                (rdf_name, method) = rdf_convert_table[name]
                setattr(process, rdf_name, method(value))
            if ((not process.name) and process.cmdline):
                process.name = os.path.basename(process.cmdline[0])
            (yield process)
        except ValueError:
            logging.warn('Unparsable    line    found    for    %s    %s:\n        %s', cmd, args, line)
