<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_report(self, report):
 """ Updates the report identified by the ``report.id`` field; if this field does not exist, then ``report.external_id`` will be used if it exists. Any other fields on ``report`` that are not ``None`` will overwrite values on the report in TruSTAR's system. Any fields that are ``None`` will simply be ignored; their values will be unchanged. :param report: A |Report| object with the updated values. :return: The |Report| object. Example: Old Title Changed Title """


        # default to interal ID type if ID field is present
        if report.id is not None:
            id_type = IdType.INTERNAL
            report_id = report.id
        # if no ID field is present, but external ID field is, default to external ID type
        elif report.external_id is not None:
            id_type = IdType.EXTERNAL
            report_id = report.external_id
        # if no ID fields exist, raise exception
        else:
            raise Exception("Cannot update report without either an ID or an external ID.")

        # not allowed to update value of 'reportId', so remove it
        report_dict = {k: v for k, v in report.to_dict().items() if k != 'reportId'}

        params = {'idType': id_type}

        data = json.dumps(report.to_dict())
        self._client.put("reports/%s" % report_id, data=data, params=params)

        return report