<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def prepare(self, error=None, frame=None):
 """ Prepare the report to be sent to IOpipe. :param error: An optional error to add to report. :param frame: A stack frame to add to report in the event of a timeout. """

        if error:
            self.retain_error(error, frame)

        self.report["environment"]["host"]["boot_id"] = system.read_bootid()

        # convert labels to list for sending
        self.report["labels"] = list(self.labels)

        meminfo = system.read_meminfo()

        self.report.update(
            {
                "aws": self.extract_context_data(),
                "timestampEnd": int(time.time() * 1000),
            }
        )

        self.report["environment"]["os"].update(
            {
                "cpus": system.read_stat(),
                "freemem": meminfo["MemFree"],
                "hostname": system.read_hostname(),
                "totalmem": meminfo["MemTotal"],
                "usedmem": meminfo["MemTotal"] - meminfo["MemFree"],
            }
        )

        self.report["environment"]["os"]["linux"]["pid"] = {
            "self": {
                "stat": system.read_pid_stat("self"),
                "stat_start": self.stat_start,
                "status": system.read_pid_status("self"),
            }
        }

        self.report["disk"] = system.read_disk()

        self.report["duration"] = int((monotonic() - self.start_time) * 1e9)