[ANSWERED]: MacFSEvents for py 2.5

Posted on
Mon Aug 18, 2014 6:59 pm
kw123 offline
User avatar
Posts: 8360
Joined: May 12, 2013
Location: Dallas, TX

[ANSWERED]: MacFSEvents for py 2.5

does anyone know of an equivalent packed for py 2.5. MacFSEvents requires python 2.7 and Indigo only supports 2.5..

MacFSEvent is a package that allows to set a trigger on a file: If THAT file changes your python function gets called. you doing have to test date/timestamp or file size every second to check if anything has changed.


thanks

Karl

Posted on
Tue Aug 19, 2014 7:15 am
matt (support) offline
Site Admin
User avatar
Posts: 21416
Joined: Jan 27, 2003
Location: Texas

Re: MacFSEvents for py 2.5

watchdog looks promising, but requires py 2.6+.

pyinotify might work, but I didn't look at it in detail.

If you are going for a fast way to get it done and don't want to have to worry about installing a package, then I would just poll the modification date in a loop with a sleep as detailed here:

Code: Select all
import os.path, time
files = ['file1.txt', 'file2.txt', 'file3,txt']
changes =  {"file1.txt":os.path.getmtime("file1.txt"),"file2.txt":os.path.getmtime("file2.txt"),"file3.txt":os.path.getmtime("file3.txt")}
while True:
    for f in files:
        if changes.get(f) < os.path.getmtime(f):
            print "File {} has been modified".format(f)
            changes[f] = os.path.getmtime(f)
        else:
            print "No changes, going to sleep."
    time.sleep(10)

Image

Posted on
Tue Aug 19, 2014 7:29 am
kw123 offline
User avatar
Posts: 8360
Joined: May 12, 2013
Location: Dallas, TX

Re: [ANSWERED]: MacFSEvents for py 2.5

I am currently doing the "sleep loop" and checking the date. was looking for some other way. thanks for the pointer

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests