Exemplo n.º 1
0
def put_css_in_file(html_message, journal_name):
    """
    Retrieve the CSS of the journal and insert/inline it in the <head>
    section of the given html_message. (Used for HTML alert emails)

    Parameters:
          journal_name  -  the journal name
          html_message  -  the html message (string) in which the CSS
                           should be inserted
    Returns:
          the HTML message with its CSS inlined
    """
    css_path = get_journal_css_url(journal_name)
    if not css_path:
        return
    css_file = WEBJOURNAL_OPENER.open(css_path)
    css = css_file.read()
    css = make_full_paths_in_css(css, journal_name)
    html_parted = html_message.split("</head>")
    if len(html_parted) > 1:
        html = '%s<style type="text/css">%s</style></head>%s' % (html_parted[0],
                                                        css,
                                                        html_parted[1])
    else:
        html_parted = html_message.split("<html>")
        if len(html_parted) > 1:
            html = '%s<html><head><style type="text/css">%s</style></head>%s' % (html_parted[0],
                                                                                 css,
                                                                                 html_parted[1])
        else:
            return
    return html
def _update_feed(yahoo_weather_rss, cached_filename, expire_time_filename):
    """
    Retrieve the latest weather information from Yahoo and write it to
    'cached_filename'. Also write the supposed expiration date
    provided by Yahoo to 'expire_time_filename'.
    """
    default_timeout = socket.getdefaulttimeout()
    socket.setdefaulttimeout(2.0)
    try:
        try:
            feed = WEBJOURNAL_OPENER.open(yahoo_weather_rss)
        except:
            return
    finally:
        socket.setdefaulttimeout(default_timeout)

    cached_file = open('%s/%s' % (CFG_CACHEDIR, cached_filename), 'w')
    cached_file.write(feed.read())
    cached_file.close()

    feed_data = feedparser.parse(yahoo_weather_rss)
    expire_time = feed_data.headers['expires']
    expire_file = open('%s/%s' % (CFG_CACHEDIR, expire_time_filename), 'w')
    expire_file.write(expire_time)
    expire_file.close()
Exemplo n.º 3
0
def put_css_in_file(html_message, journal_name):
    """
    Retrieve the CSS of the journal and insert/inline it in the <head>
    section of the given html_message. (Used for HTML alert emails)

    Parameters:
          journal_name  -  the journal name
          html_message  -  the html message (string) in which the CSS
                           should be inserted
    Returns:
          the HTML message with its CSS inlined
    """
    css_path = get_journal_css_url(journal_name)
    if not css_path:
        return
    css_file = WEBJOURNAL_OPENER.open(css_path)
    css = css_file.read()
    css = make_full_paths_in_css(css, journal_name)
    html_parted = html_message.split("</head>")
    if len(html_parted) > 1:
        html = '%s<style type="text/css">%s</style></head>%s' % (
            html_parted[0], css, html_parted[1])
    else:
        html_parted = html_message.split("<html>")
        if len(html_parted) > 1:
            html = '%s<html><head><style type="text/css">%s</style></head>%s' % (
                html_parted[0], css, html_parted[1])
        else:
            return
    return html
def _update_feed(yahoo_weather_rss, cached_filename, expire_time_filename):
    """
    Retrieve the latest weather information from Yahoo and write it to
    'cached_filename'. Also write the supposed expiration date
    provided by Yahoo to 'expire_time_filename'.
    """
    default_timeout = socket.getdefaulttimeout()
    socket.setdefaulttimeout(2.0)
    try:
        try:
            feed = WEBJOURNAL_OPENER.open(yahoo_weather_rss)
        except:
            return
    finally:
        socket.setdefaulttimeout(default_timeout)

    cached_file = open('%s/%s' % (CFG_CACHEDIR, cached_filename), 'w')
    cached_file.write(feed.read())
    cached_file.close()

    feed_data = feedparser.parse(yahoo_weather_rss)
    expire_time = feed_data.headers['expires']
    expire_file = open('%s/%s' % (CFG_CACHEDIR, expire_time_filename), 'w')
    expire_file.write(expire_time)
    expire_file.close()
def _update_seminars(indico_baseurl, indico_what, indico_loc, indico_id,
                     indico_onlypublic, indico_from, indico_to,
                     indico_key, indico_sig, indico_credential_path,
                     cached_filename):
    """
    helper function that gets the xml data source from CERN Indico and creates
    a dedicated xml file in the cache for easy use in the widget.
    """
    if indico_credential_path:
        indico_key, indico_sig = get_indico_credentials(indico_credential_path)
    url = create_Indico_request_url(indico_baseurl,
                                    indico_what,
                                    indico_loc,
                                    indico_id,
                                    'xml',
                                    {'onlypublic': indico_onlypublic,
                                     'from': indico_from,
                                     'to': indico_to},
                                    indico_key, indico_sig)
    default_timeout = socket.getdefaulttimeout()
    socket.setdefaulttimeout(2.0)
    try:
        try:
            indico_xml = WEBJOURNAL_OPENER.open(url)
        except:
            return
    finally:
        socket.setdefaulttimeout(default_timeout)
    xml_file_handler = minidom.parseString(indico_xml.read())
    seminar_xml = ['<Indico_Seminars time="%s">' % time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime()), ]
    agenda_items = xml_file_handler.getElementsByTagName("conference")
    for item in agenda_items:
        seminar_xml.extend(["<seminar>", ])
        try:
            start_date = item.getElementsByTagName("startDate")[0].firstChild.toxml(encoding="utf-8")
            start_time = start_date[11:16]
        except:
            start_time = ""
        seminar_xml.extend(["<start_time>%s</start_time>" % start_time, ])
        try:
            category = item.getElementsByTagName("category")[0].firstChild.toxml(encoding="utf-8")
            category = category.split("/")[-1]
            category = category.replace("&amp;", "")
            category = category.replace("nbsp;", "")
            category = category.replace("&nbsp;", "")
        except:
            category = ""
        seminar_xml.extend(["<category>%s</category>" % category, ])
        try:
            title = item.getElementsByTagName("title")[0].firstChild.toxml(encoding="utf-8")
        except:
            title = ""
        seminar_xml.extend(["<title>%s</title>" % title, ])
        try:
            url = item.getElementsByTagName("url")[0].firstChild.toxml(encoding="utf-8")
        except:
            url = "#"
        seminar_xml.extend(["<url>%s</url>" % url, ])
        try:
            speaker = item.getElementsByTagName("fullName")[0].firstChild.toxml(encoding="utf-8")
        except:
            speaker = ""
        seminar_xml.extend(["<speaker>%s</speaker>" % speaker, ])
        try:
            room = item.getElementsByTagName("room")[0].firstChild.toxml(encoding="utf-8")
        except:
            room = ""
        seminar_xml.extend(["<room>%s</room>" % room, ])
        try:
            location = item.getElementsByTagName("location")[0].firstChild.toxml(encoding="utf-8")
        except:
            location = ""
        seminar_xml.extend(["<location>%s</location>" % location, ])
        seminar_xml.extend(["</seminar>", ])
    seminar_xml.extend(["</Indico_Seminars>", ])
    # write the created file to cache
    fptr = open("%s/%s" % (CFG_CACHEDIR, cached_filename), "w")
    fptr.write("\n".join(seminar_xml))
    fptr.close()
def _update_seminars(indico_baseurl, indico_what, indico_loc, indico_id,
                     indico_onlypublic, indico_from, indico_to,
                     indico_key, indico_sig, indico_credential_path,
                     cached_filename):
    """
    helper function that gets the xml data source from CERN Indico and creates
    a dedicated xml file in the cache for easy use in the widget.
    """
    if indico_credential_path:
        indico_key, indico_sig = get_indico_credentials(indico_credential_path)
    url = create_Indico_request_url(indico_baseurl,
                                    indico_what,
                                    indico_loc,
                                    indico_id,
                                    'xml',
                                    {'onlypublic': indico_onlypublic,
                                     'from': indico_from,
                                     'to': indico_to},
                                    indico_key, indico_sig)
    default_timeout = socket.getdefaulttimeout()
    socket.setdefaulttimeout(2.0)
    try:
        try:
            indico_xml = WEBJOURNAL_OPENER.open(url)
        except:
            return
    finally:
        socket.setdefaulttimeout(default_timeout)
    xml_file_handler = minidom.parseString(indico_xml.read())
    seminar_xml = ['<Indico_Seminars time="%s">' % time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime()), ]
    agenda_items = xml_file_handler.getElementsByTagName("conference")
    for item in agenda_items:
        seminar_xml.extend(["<seminar>", ])

        for childNode in item.childNodes:

            if childNode.tagName == "startDate":
                key = "start_time"
                value = childNode.firstChild.toxml(encoding="utf-8")
                value = value and value[11:16] or ""
                seminar_xml.extend(["<%s>%s</%s>" % (key, value, key), ])
                continue

            #if childNode.tagName == "endDate":
            #    continue

            if childNode.tagName == "creator":
                for extraChildNode in childNode.getElementsByTagName("fullName"):
                    key = "creator"
                    value = extraChildNode.firstChild.toxml(encoding="utf-8")
                    seminar_xml.extend(["<%s>%s</%s>" % (key, value, key), ])
                    # Only get the first childNode
                    break
                continue

            #if childNode.tagName == "hasAnyProtection":
            #    continue

            #if childNode.tagName == "roomFullname":
            #    continue

            #if childNode.tagName == "modificationDate":
            #    continue

            #if childNode.tagName == "timezone":
            #    continue

            if childNode.tagName == "category":
                key = "category"
                value = childNode.firstChild.toxml(encoding="utf-8")
                value = value.split("/")[-1].replace("&amp;", "").replace("nbsp;", "").replace("&nbsp;", "")
                seminar_xml.extend(["<%s>%s</%s>" % (key, value, key), ])
                continue

            if childNode.tagName == "title":
                key = "title"
                value = childNode.firstChild.toxml(encoding="utf-8")
                seminar_xml.extend(["<%s>%s</%s>" % (key, value, key), ])
                continue

            if childNode.tagName == "location":
                key = "location"
                value = childNode.firstChild.toxml(encoding="utf-8")
                seminar_xml.extend(["<%s>%s</%s>" % (key, value, key), ])
                continue

            #if childNode.tagName == "type":
            #    continue

            #if childNode.tagName == "categoryId":
            #    continue

            #if childNode.tagName == "description":
            #    continue

            #if childNode.tagName == "roomMapURL":
            #    continue

            #if childNode.tagName == "material":
            #    continue

            #if childNode.tagName == "visibility":
            #    continue

            #if childNode.tagName == "address":
            #    continue

            #if childNode.tagName == "creationDate":
            #    continue

            if childNode.tagName == "room":
                key = "room"
                value = childNode.firstChild.toxml(encoding="utf-8")
                seminar_xml.extend(["<%s>%s</%s>" % (key, value, key), ])
                continue

            if childNode.tagName == "chairs":
                for extraChildNode in childNode.getElementsByTagName("fullName"):
                    key = "chair"
                    value = extraChildNode.firstChild.toxml(encoding="utf-8")
                    seminar_xml.extend(["<%s>%s</%s>" % (key, value, key), ])
                    # Only get the first childNode
                    break
                continue

            if childNode.tagName == "url":
                key = "url"
                value = childNode.firstChild.toxml(encoding="utf-8")
                seminar_xml.extend(["<%s>%s</%s>" % (key, value, key), ])
                continue

        seminar_xml.extend(["</seminar>", ])
    seminar_xml.extend(["</Indico_Seminars>", ])
    # write the created file to cache
    fptr = open("%s/%s" % (CFG_CACHEDIR, cached_filename), "w")
    fptr.write("\n".join(seminar_xml))
    fptr.close()
Exemplo n.º 7
0
def perform_request_alert(journal_name, issue,
                          sent, plain_text, subject, recipients,
                          html_mail, force, ln=CFG_SITE_LANG):
    """
    All the logic for alert emails.

    Display a form to edit email/recipients and options to send the
    email.  Sent in HTML/PlainText or only PlainText if wished so.
    Also prevent mistake of sending the alert more than one for a
    particular issue.

    Parameters:
        journal_name  -  the journal for which the alert is sent
               issue  -  the issue for which the alert is sent
                sent  -  Display interface to edit email if "False"
                         (string). Else send the email.
          plain_text  -  the text of the mail
             subject  -  the subject of the mail
          recipients  -  the recipients of the mail (string with
                         comma-separated emails)
           html_mail  -  if 'html', also send email as HTML (copying
                         from the current issue on the web)
               force  -  if different than "False", the email is sent
                         even if it has already been sent.
                  ln  -  language
    """
    # FIXME: more flexible options to choose the language of the alert
    languages = get_journal_languages(journal_name)
    if languages:
        alert_ln = languages[0]
    else:
        alert_ln = CFG_SITE_LANG

    if not get_release_datetime(issue, journal_name, ln):
        # Trying to send an alert for an unreleased issue
        return wjt.tmpl_admin_alert_unreleased_issue(ln,
                                                     journal_name)
    if sent == "False":
        # Retrieve default message, subject and recipients, and
        # display email editor
        subject = wjt.tmpl_admin_alert_subject(journal_name,
                                               alert_ln,
                                               issue)
        plain_text = wjt.tmpl_admin_alert_plain_text(journal_name,
                                                     alert_ln,
                                                     issue)
        plain_text = plain_text.encode('utf-8')
        recipients = get_journal_alert_recipient_email(journal_name)
        return wjt.tmpl_admin_alert_interface(ln,
                                              journal_name,
                                              subject,
                                              plain_text,
                                              recipients,
                                              alert_ln)
    else:
        # User asked to send the mail
        if was_alert_sent_for_issue(issue,
                                    journal_name,
                                    ln) != False and force == "False":
            # Mmh, email already sent before for this issue. Ask
            # confirmation
            return wjt.tmpl_admin_alert_was_already_sent(ln,
                                                         journal_name,
                                                         subject,
                                                         plain_text,
                                                         recipients,
                                                         html_mail,
                                                         issue)
        html_string = None
        if html_mail == "html":
            # Also send as HTML: retrieve from current issue
            html_file = WEBJOURNAL_OPENER.open('%s/journal/%s?ln=%s'
                                % (CFG_SITE_URL, journal_name, alert_ln))
            html_string = html_file.read()
            html_file.close()
            html_string = put_css_in_file(html_string, journal_name)
            html_string = insert_journal_link(html_string, journal_name, issue, ln)
            html_string = wash_alert(html_string)

        sender_email = get_journal_alert_sender_email(journal_name)
        send_email(sender_email, recipients, subject, plain_text,
                   html_string, header='', footer='', html_header='',
                   html_footer='', charset='utf-8')

        update_DB_for_alert(issue, journal_name, ln)
        return wjt.tmpl_admin_alert_success_msg(ln,
                                                journal_name)
def _update_seminars(indico_baseurl, indico_what, indico_loc, indico_id,
                     indico_onlypublic, indico_from, indico_to, indico_key,
                     indico_sig, indico_credential_path, cached_filename):
    """
    helper function that gets the xml data source from CERN Indico and creates
    a dedicated xml file in the cache for easy use in the widget.
    """
    if indico_credential_path:
        indico_key, indico_sig = get_indico_credentials(indico_credential_path)
    url = create_Indico_request_url(indico_baseurl, indico_what, indico_loc,
                                    indico_id, 'xml', {
                                        'onlypublic': indico_onlypublic,
                                        'from': indico_from,
                                        'to': indico_to
                                    }, indico_key, indico_sig)
    default_timeout = socket.getdefaulttimeout()
    socket.setdefaulttimeout(2.0)
    try:
        try:
            indico_xml = WEBJOURNAL_OPENER.open(url)
        except:
            return
    finally:
        socket.setdefaulttimeout(default_timeout)
    xml_file_handler = minidom.parseString(indico_xml.read())
    seminar_xml = [
        '<Indico_Seminars time="%s">' %
        time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime()),
    ]
    agenda_items = xml_file_handler.getElementsByTagName("conference")
    for item in agenda_items:
        seminar_xml.extend([
            "<seminar>",
        ])

        for childNode in item.childNodes:

            if childNode.tagName == "startDate":
                key = "start_time"
                value = childNode.firstChild.toxml(encoding="utf-8")
                value = value and value[11:16] or ""
                seminar_xml.extend([
                    "<%s>%s</%s>" % (key, value, key),
                ])
                continue

            #if childNode.tagName == "endDate":
            #    continue

            if childNode.tagName == "creator":
                for extraChildNode in childNode.getElementsByTagName(
                        "fullName"):
                    key = "creator"
                    value = extraChildNode.firstChild.toxml(encoding="utf-8")
                    seminar_xml.extend([
                        "<%s>%s</%s>" % (key, value, key),
                    ])
                    # Only get the first childNode
                    break
                continue

            #if childNode.tagName == "hasAnyProtection":
            #    continue

            #if childNode.tagName == "roomFullname":
            #    continue

            #if childNode.tagName == "modificationDate":
            #    continue

            #if childNode.tagName == "timezone":
            #    continue

            if childNode.tagName == "category":
                key = "category"
                value = childNode.firstChild.toxml(encoding="utf-8")
                value = value.split("/")[-1].replace("&amp;", "").replace(
                    "nbsp;", "").replace("&nbsp;", "")
                seminar_xml.extend([
                    "<%s>%s</%s>" % (key, value, key),
                ])
                continue

            if childNode.tagName == "title":
                key = "title"
                value = childNode.firstChild.toxml(encoding="utf-8")
                seminar_xml.extend([
                    "<%s>%s</%s>" % (key, value, key),
                ])
                continue

            if childNode.tagName == "location":
                key = "location"
                value = childNode.firstChild.toxml(encoding="utf-8")
                seminar_xml.extend([
                    "<%s>%s</%s>" % (key, value, key),
                ])
                continue

            #if childNode.tagName == "type":
            #    continue

            #if childNode.tagName == "categoryId":
            #    continue

            #if childNode.tagName == "description":
            #    continue

            #if childNode.tagName == "roomMapURL":
            #    continue

            #if childNode.tagName == "material":
            #    continue

            #if childNode.tagName == "visibility":
            #    continue

            #if childNode.tagName == "address":
            #    continue

            #if childNode.tagName == "creationDate":
            #    continue

            if childNode.tagName == "room":
                key = "room"
                value = childNode.firstChild.toxml(encoding="utf-8")
                seminar_xml.extend([
                    "<%s>%s</%s>" % (key, value, key),
                ])
                continue

            if childNode.tagName == "chairs":
                for extraChildNode in childNode.getElementsByTagName(
                        "fullName"):
                    key = "chair"
                    value = extraChildNode.firstChild.toxml(encoding="utf-8")
                    seminar_xml.extend([
                        "<%s>%s</%s>" % (key, value, key),
                    ])
                    # Only get the first childNode
                    break
                continue

            if childNode.tagName == "url":
                key = "url"
                value = childNode.firstChild.toxml(encoding="utf-8")
                seminar_xml.extend([
                    "<%s>%s</%s>" % (key, value, key),
                ])
                continue

        seminar_xml.extend([
            "</seminar>",
        ])
    seminar_xml.extend([
        "</Indico_Seminars>",
    ])
    # write the created file to cache
    fptr = open("%s/%s" % (CFG_CACHEDIR, cached_filename), "w")
    fptr.write("\n".join(seminar_xml))
    fptr.close()
Exemplo n.º 9
0
def perform_request_alert(journal_name,
                          issue,
                          sent,
                          plain_text,
                          subject,
                          recipients,
                          html_mail,
                          force,
                          ln=CFG_SITE_LANG):
    """
    All the logic for alert emails.

    Display a form to edit email/recipients and options to send the
    email.  Sent in HTML/PlainText or only PlainText if wished so.
    Also prevent mistake of sending the alert more than one for a
    particular issue.

    Parameters:
        journal_name  -  the journal for which the alert is sent
               issue  -  the issue for which the alert is sent
                sent  -  Display interface to edit email if "False"
                         (string). Else send the email.
          plain_text  -  the text of the mail
             subject  -  the subject of the mail
          recipients  -  the recipients of the mail (string with
                         comma-separated emails)
           html_mail  -  if 'html', also send email as HTML (copying
                         from the current issue on the web)
               force  -  if different than "False", the email is sent
                         even if it has already been sent.
                  ln  -  language
    """
    # FIXME: more flexible options to choose the language of the alert
    languages = get_journal_languages(journal_name)
    if languages:
        alert_ln = languages[0]
    else:
        alert_ln = CFG_SITE_LANG

    if not get_release_datetime(issue, journal_name, ln):
        # Trying to send an alert for an unreleased issue
        return wjt.tmpl_admin_alert_unreleased_issue(ln, journal_name)
    if sent == "False":
        # Retrieve default message, subject and recipients, and
        # display email editor
        subject = wjt.tmpl_admin_alert_subject(journal_name, alert_ln, issue)
        plain_text = wjt.tmpl_admin_alert_plain_text(journal_name, alert_ln,
                                                     issue)
        plain_text = plain_text.encode('utf-8')
        recipients = get_journal_alert_recipient_email(journal_name)
        return wjt.tmpl_admin_alert_interface(ln, journal_name, subject,
                                              plain_text, recipients, alert_ln)
    else:
        # User asked to send the mail
        if was_alert_sent_for_issue(issue, journal_name,
                                    ln) != False and force == "False":
            # Mmh, email already sent before for this issue. Ask
            # confirmation
            return wjt.tmpl_admin_alert_was_already_sent(
                ln, journal_name, subject, plain_text, recipients, html_mail,
                issue)
        html_string = None
        if html_mail == "html":
            # Also send as HTML: retrieve from current issue
            html_file = WEBJOURNAL_OPENER.open(
                '%s/journal/%s?ln=%s' % (CFG_SITE_URL, journal_name, alert_ln))
            html_string = html_file.read()
            html_file.close()
            html_string = put_css_in_file(html_string, journal_name)
            html_string = insert_journal_link(html_string, journal_name, issue,
                                              ln)
            html_string = wash_alert(html_string)

        sender_email = get_journal_alert_sender_email(journal_name)
        send_email(sender_email,
                   recipients,
                   subject,
                   plain_text,
                   html_string,
                   header='',
                   footer='',
                   html_header='',
                   html_footer='',
                   charset='utf-8')

        update_DB_for_alert(issue, journal_name, ln)
        return wjt.tmpl_admin_alert_success_msg(ln, journal_name)
Exemplo n.º 10
0
def _update_seminars(indico_baseurl, indico_what, indico_loc, indico_id,
                     indico_onlypublic, indico_from, indico_to, indico_key,
                     indico_sig, indico_credential_path, cached_filename):
    """
    helper function that gets the xml data source from CERN Indico and creates
    a dedicated xml file in the cache for easy use in the widget.
    """
    if indico_credential_path:
        indico_key, indico_sig = get_indico_credentials(indico_credential_path)
    url = create_Indico_request_url(indico_baseurl, indico_what, indico_loc,
                                    indico_id, 'xml', {
                                        'onlypublic': indico_onlypublic,
                                        'from': indico_from,
                                        'to': indico_to
                                    }, indico_key, indico_sig)
    default_timeout = socket.getdefaulttimeout()
    socket.setdefaulttimeout(2.0)
    try:
        try:
            indico_xml = WEBJOURNAL_OPENER.open(url)
        except:
            return
    finally:
        socket.setdefaulttimeout(default_timeout)
    xml_file_handler = minidom.parseString(indico_xml.read())
    seminar_xml = [
        '<Indico_Seminars time="%s">' %
        time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime()),
    ]
    agenda_items = xml_file_handler.getElementsByTagName("conference")
    for item in agenda_items:
        seminar_xml.extend([
            "<seminar>",
        ])
        try:
            start_date = item.getElementsByTagName(
                "startDate")[0].firstChild.toxml(encoding="utf-8")
            start_time = start_date[11:16]
        except:
            start_time = ""
        seminar_xml.extend([
            "<start_time>%s</start_time>" % start_time,
        ])
        try:
            category = item.getElementsByTagName(
                "category")[0].firstChild.toxml(encoding="utf-8")
            category = category.split("/")[-1]
            category = category.replace("&amp;", "")
            category = category.replace("nbsp;", "")
            category = category.replace("&nbsp;", "")
        except:
            category = ""
        seminar_xml.extend([
            "<category>%s</category>" % category,
        ])
        try:
            title = item.getElementsByTagName("title")[0].firstChild.toxml(
                encoding="utf-8")
        except:
            title = ""
        seminar_xml.extend([
            "<title>%s</title>" % title,
        ])
        try:
            url = item.getElementsByTagName("url")[0].firstChild.toxml(
                encoding="utf-8")
        except:
            url = "#"
        seminar_xml.extend([
            "<url>%s</url>" % url,
        ])
        try:
            speaker = item.getElementsByTagName(
                "fullName")[0].firstChild.toxml(encoding="utf-8")
        except:
            speaker = ""
        seminar_xml.extend([
            "<speaker>%s</speaker>" % speaker,
        ])
        try:
            room = item.getElementsByTagName("room")[0].firstChild.toxml(
                encoding="utf-8")
        except:
            room = ""
        seminar_xml.extend([
            "<room>%s</room>" % room,
        ])
        try:
            location = item.getElementsByTagName(
                "location")[0].firstChild.toxml(encoding="utf-8")
        except:
            location = ""
        seminar_xml.extend([
            "<location>%s</location>" % location,
        ])
        seminar_xml.extend([
            "</seminar>",
        ])
    seminar_xml.extend([
        "</Indico_Seminars>",
    ])
    # write the created file to cache
    fptr = open("%s/%s" % (CFG_CACHEDIR, cached_filename), "w")
    fptr.write("\n".join(seminar_xml))
    fptr.close()