<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Python Module when using Blocky]]></title><description><![CDATA[<p dir="auto">I am trying to use the FLow/Blocky interface to read a remote ICS file.  It needs a python module.  How do I do this please?  I get a error "no module names icalendar"</p>
<pre><code>import urequests
from icalendar import Calendar
from datetime import datetime

def download_file(url):
    headers = {
        'User-Agent': 'MicroPython'
    }
    response = urequests.get(url, headers=headers)
    if response.status_code == 200:
        file_contents = response.content
        return file_contents
    else:
        return None

def parse_ics(ics_data):
    calendar = Calendar.from_ical(ics_data)
    current_meeting = None
    next_meeting = None
    now = datetime.now()

    for event in calendar.walk('vevent'):
        start_time = event.get('dtstart').dt
        end_time = event.get('dtend').dt
        if start_time &lt;= now &lt;= end_time:
            current_meeting = event.get('summary')
        elif start_time &gt; now:
            if next_meeting is None or start_time &lt; next_meeting['start']:
                next_meeting = {
                    'start': start_time,
                    'summary': event.get('summary')
                }

    return current_meeting, next_meeting

# Example usage
ics_url = "http://example.com/meetings.ics"
ics_data = download_file(ics_url)
if ics_data is not None:
    current_meeting, next_meeting = parse_ics(ics_data)
    if current_meeting:
        print("Current meeting:", current_meeting)
    else:
        print("FREETIME")
    
    if next_meeting:
        time_until_next = (next_meeting['start'] - datetime.now()).total_seconds()
        print("Next meeting:", next_meeting['summary'])
        print("Seconds until next meeting:", time_until_next)
else:
    print("Failed to download the ICS file.")</code></pre>
]]></description><link>https://community.m5stack.com/topic/5345/python-module-when-using-blocky</link><generator>RSS for Node</generator><lastBuildDate>Wed, 06 May 2026 19:32:53 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/5345.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 29 May 2023 21:40:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Python Module when using Blocky on Fri, 11 Aug 2023 09:23:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zane_shus" aria-label="Profile: zane_shus">@<bdi>zane_shus</bdi></a> said in <a href="/post/21031">Python Module when using Blocky</a>:</p>
<blockquote>
<p dir="auto">I am trying to use the FLow/Blocky interface to read a remote ICS file.  It needs a python module.  How do I do this please?  I get a error "no module names icalendar"</p>
</blockquote>
<p dir="auto">It seems like you're encountering an issue with the "icalendar" Python module while trying to use the Flow/Blocky interface to read a remote ICS file. The error message "no module named icalendar" indicates that the required Python module is not installed in your environment.</p>
]]></description><link>https://community.m5stack.com/post/21867</link><guid isPermaLink="true">https://community.m5stack.com/post/21867</guid><dc:creator><![CDATA[zabrodskyitaras]]></dc:creator><pubDate>Fri, 11 Aug 2023 09:23:54 GMT</pubDate></item></channel></rss>