<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sendPREMISEvent(webRoot, eventType, agentIdentifier, eventDetail, eventOutcome, eventOutcomeDetail=None, linkObjectList=[], eventDate=None, debug=False, eventIdentifier=None):
 """ A function to format an event to be uploaded and send it to a particular CODA server in order to register it """


    atomID = uuid.uuid1().hex
    eventXML = createPREMISEventXML(
        eventType=eventType,
        agentIdentifier=agentIdentifier,
        eventDetail=eventDetail,
        eventOutcome=eventOutcome,
        outcomeDetail=eventOutcomeDetail,
        eventIdentifier=eventIdentifier,
        eventDate=eventDate,
        linkObjectList=linkObjectList
    )
    atomXML = bagatom.wrapAtom(eventXML, id=atomID, title=atomID)
    atomXMLText = '<?xml version="1.0"?>\n%s' % etree.tostring(
        atomXML, pretty_print=True
    )
    if debug:
        print "Uploading XML to %s\n---\n%s\n---\n" % (webRoot, atomXMLText)
    response = None
    try:
        response, content = doWebRequest(webRoot, "POST", data=atomXMLText)
    except urllib2.URLError:
        pass
    if not response:
        waitForURL(webRoot, 60)
        response, content = doWebRequest(webRoot, "POST", data=atomXMLText)
    if response.code != 201:
        if debug:
            tempdir = tempfile.gettempdir()
            tfPath = os.path.join(
                tempdir, "premis_upload_%s.html" % uuid.uuid1().hex
            )
            tf = open(tfPath, "w")
            tf.write(content)
            tf.close()
            sys.stderr.write(
                "Output from webserver available at %s. Response code %s" % (
                    tf.name, response.code
                )
            )
        raise Exception(
            "Error uploading PREMIS Event to %s. Response code is %s" % (
                webRoot, response.code
            )
        )
    return (response, content)