flowcraft/generator/inspect.py
def _update_trace_info(self, fields, hm):
        """Parses a trace line and updates the :attr:`status_info` attribute.

        Parameters
        ----------
        fields : list
            List of the tab-seperated elements of the trace line
        hm : dict
            Maps the column IDs to their position in the fields argument.
            This dictionary object is retrieve from :func:`_header_mapping`.
        """

        process = fields[hm["process"]]

        if process not in self.processes:
            return

        # Get information from a single line of trace file
        info = dict((column, fields[pos]) for column, pos in hm.items())

        # The headers that will be used to populate the process
        process_tag_headers = ["realtime", "rss", "rchar", "wchar"]
        for h in process_tag_headers:

            # In the rare occasion the tag is parsed first in the trace
            # file than the log file, add the new tag.
            if info["tag"] not in self.process_tags[process]:
                # If the 'start' tag is present in the trace, use that
                # information. If not, it will be parsed in the log file.
                try:
                    timestart = info["start"].split()[1]
                except KeyError:
                    timestart = None
                self.process_tags[process][info["tag"]] = {
                    "workdir": self._expand_path(info["hash"]),
                    "start": timestart
                }

            if h in info and info["tag"] != "-":
                if h != "realtime" and info[h] != "-":
                    self.process_tags[process][info["tag"]][h] = \
                        round(self._size_coverter(info[h]), 2)
                else:
                    self.process_tags[process][info["tag"]][h] = info[h]

        # Set allocated cpu and memory information to process
        if "cpus" in info and not self.processes[process]["cpus"]:
            self.processes[process]["cpus"] = info["cpus"]
        if "memory" in info and not self.processes[process]["memory"]:
            try:
                self.processes[process]["memory"] = self._size_coverter(
                    info["memory"])
            except ValueError:
                self.processes[process]["memory"] = None

        if info["hash"] in self.stored_ids:
            return

        # If the task hash code is provided, expand it to the work directory
        # and add a new entry
        if "hash" in info:
            hs = info["hash"]
            info["work_dir"] = self._expand_path(hs)

        if "tag" in info:
            tag = info["tag"]
            if tag != "-" and tag not in self.samples and \
                    tag.split()[0] not in self.samples:
                self.samples.append(tag)

        self.trace_info[process].append(info)
        self.stored_ids.append(info["hash"])
def _update_trace_info(self, fields, hm):
        """Parses a trace line and updates the :attr:`status_info` attribute.

        Parameters
        ----------
        fields : list
            List of the tab-seperated elements of the trace line
        hm : dict
            Maps the column IDs to their position in the fields argument.
            This dictionary object is retrieve from :func:`_header_mapping`.
        """

        process = fields[hm["process"]]

        if process not in self.processes:
            return

        # Get information from a single line of trace file
        info = dict((column, fields[pos]) for column, pos in hm.items())

        # The headers that will be used to populate the process
        process_tag_headers = ["realtime", "rss", "rchar", "wchar"]
        for h in process_tag_headers:

            # In the rare occasion the tag is parsed first in the trace
            # file than the log file, add the new tag.
            if info["tag"] not in self.process_tags[process]:
                # If the 'start' tag is present in the trace, use that
                # information. If not, it will be parsed in the log file.
                try:
                    timestart = info["start"].split()[1]
                except KeyError:
                    timestart = None
                self.process_tags[process][info["tag"]] = {
                    "workdir": self._expand_path(info["hash"]),
                    "start": timestart
                }

            if h in info and info["tag"] != "-":
                if h != "realtime" and info[h] != "-":
                    self.process_tags[process][info["tag"]][h] = \
                        round(self._size_coverter(info[h]), 2)
                else:
                    self.process_tags[process][info["tag"]][h] = info[h]

        # Set allocated cpu and memory information to process
        if "cpus" in info and not self.processes[process]["cpus"]:
            self.processes[process]["cpus"] = info["cpus"]
        if "memory" in info and not self.processes[process]["memory"]:
            try:
                self.processes[process]["memory"] = self._size_coverter(
                    info["memory"])
            except ValueError:
                self.processes[process]["memory"] = None

        if info["hash"] in self.stored_ids:
            return

        # If the task hash code is provided, expand it to the work directory
        # and add a new entry
        if "hash" in info:
            hs = info["hash"]
            info["work_dir"] = self._expand_path(hs)

        if "tag" in info:
            tag = info["tag"]
            if tag != "-" and tag not in self.samples and \
                    tag.split()[0] not in self.samples:
                self.samples.append(tag)

        self.trace_info[process].append(info)
        self.stored_ids.append(info["hash"])
def _update_trace_info ( self , fields , hm ) : process = fields [ hm [ "process" ] ] if process not in self . processes : return # Get information from a single line of trace file info = dict ( ( column , fields [ pos ] ) for column , pos in hm . items ( ) ) # The headers that will be used to populate the process process_tag_headers = [ "realtime" , "rss" , "rchar" , "wchar" ] for h in process_tag_headers : # In the rare occasion the tag is parsed first in the trace # file than the log file, add the new tag. if info [ "tag" ] not in self . process_tags [ process ] : # If the 'start' tag is present in the trace, use that # information. If not, it will be parsed in the log file. try : timestart = info [ "start" ] . split ( ) [ 1 ] except KeyError : timestart = None self . process_tags [ process ] [ info [ "tag" ] ] = { "workdir" : self . _expand_path ( info [ "hash" ] ) , "start" : timestart } if h in info and info [ "tag" ] != "-" : if h != "realtime" and info [ h ] != "-" : self . process_tags [ process ] [ info [ "tag" ] ] [ h ] = round ( self . _size_coverter ( info [ h ] ) , 2 ) else : self . process_tags [ process ] [ info [ "tag" ] ] [ h ] = info [ h ] # Set allocated cpu and memory information to process if "cpus" in info and not self . processes [ process ] [ "cpus" ] : self . processes [ process ] [ "cpus" ] = info [ "cpus" ] if "memory" in info and not self . processes [ process ] [ "memory" ] : try : self . processes [ process ] [ "memory" ] = self . _size_coverter ( info [ "memory" ] ) except ValueError : self . processes [ process ] [ "memory" ] = None if info [ "hash" ] in self . stored_ids : return # If the task hash code is provided, expand it to the work directory # and add a new entry if "hash" in info : hs = info [ "hash" ] info [ "work_dir" ] = self . _expand_path ( hs ) if "tag" in info : tag = info [ "tag" ] if tag != "-" and tag not in self . samples and tag . split ( ) [ 0 ] not in self . samples : self . samples . append ( tag ) self . trace_info [ process ] . append ( info ) self . stored_ids . append ( info [ "hash" ] )
Parses a trace line and updates the :attr:`status_info` attribute.

        Parameters
        ----------
        fields : list
            List of the tab-seperated elements of the trace line
        hm : dict
            Maps the column IDs to their position in the fields argument.
            This dictionary object is retrieve from :func:`_header_mapping`.
Parses a trace line and updates the : attr : status_info attribute .