Beginner - help walk-through simple LED program

Hello All - I am a novice python user trying to fix a short, older program to display rss feeds on LED panels. The program was created here ( using LED library here ( ).

The modification now displays, but it is stuck on the initial feed. So my main issue is how to get it to loop through each new feed item. I was hoping someone could walk me through the program and why it might not work. Particularly the def populateItems(), def createLinks(), def writeImage() functions.

I am still learning and this exercise would help me advance forward. I wasn’t sure if python3 would work, so left it alone. I am using python 2.7.16 on a raspberry pi for this. Thanks in advance.

import os, time, threading, random
import feedparser
import PIL import Image, ImageFont, ImageDraw
from random import shuffle

        #enter all news feeds you want here

    def colorRed():
        return (255, 0, 0)

    def colorGreen():
        return (0, 255, 0)

    def colorBlue():
        return (0, 0, 255)

    def colorRandom():
        return (random.randint(0,255), random.randint(0,255), random.randint(0,255))

    def populateItems():
        #first clear out everything
        del items[:]
        del displayItems[:]

        #delete all the image files
        os.system("find . -name \*.ppm -delete")
        for url in feeds:
            for post in posts:

    def createLinks():
            for idx, item in enumerate(items):
                writeImage(unicode(item["title"]), idx)
        except ValueError:
            print("Bummer :( I couldn't make you 'dem links :(")
            print("\nWill get more news next half hour!\n\n")

    def writeImage(url, count):
        link, headLine="", url[:]
        def randCol(index = -1):
            if index % 3 == 0:
                return colorRed()
            elif index % 3 == 1:
                return colorGreen()
            elif index % 3 == 2:
                return colorBlue()
                return colorRandom()
        text = ((headLine, randCol(count)), (link, colorRandom()))
        font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf", 10)
        all_text = ""
        for text_color_pair in text:
            t = text_color_pair[0]
            all_text = all_text + t
        width, ignore = font.getsize(all_text)
        im ="RGB", (width + 30, 16), "black")
        draw = ImageDraw.Draw(im)
        x = 0;
        for text_color_pair in text:
            t = text_color_pair[0]
            c = text_color_pair[1]
            draw.text((x, 0), t, c, font=font)
            x = x + font.getsize(t)[0]

    def run():
        print("News Fetched at {}\n".format(time.ctime()))
        threading.Timer(len(items) * 60, run).start()

    def showOnLEDDisplay():
        for disp in displayItems[:60]:
            os.system("sudo ./demo -D 1 --led-cols=96 --led-rows=16 --led-brightness=75 --led-chain=3"+disp)

    if __name__ == '__main__':

Hi @jax200, first of all, merry xmas haha. Second, after a quick look at your code I could spot the first problem: You are not escaping that backslash within the find command. Remember, a single backslash within a string tells Python to treat the next character in a special way, other than text. And by not escaping that backslash, your find command might not be working as you’d expect