Uncovered some errors made with my python script all related to not closing files. Here is the revised code

import os
path = "/home/chris/Dropbox/K6_primo/ssml/"
def fcount(path):
    """ Counts the number of files in a directory """
    count = 0
    for f in os.listdir(path):
        if os.path.isfile(os.path.join(path, f)):
            count += 1
    return (count-2)+101 

count_files = (fcount(path))

print count_files

ninetynine = open("/home/chris/Dropbox/K6_primo/ssml/99.xml", "w")

ninetynine.write("There are %d in the ssml folder" %count_files)

ninetynine.close()

poemnumber = open("/home/chris/Dropbox/K6_primo/poemnumber.txt", "w")

poemnumber.write('heloo world %d' %count_files)

poemnumber.close()

number_as_string = str(count_files)

print("ssml files %d" %count_files)

developed a simple way of random playing of trigger files from the PIR – not yet complete.

Leave a Reply

Your email address will not be published.