1
0
Fork 0
mirror of https://github.com/vbatts/sl-feeds.git synced 2025-07-02 23:18:30 +00:00
sl-feeds/bin/changelog_pyinotify.py
Vincent Batts f522293398 adding this for history sake
It has not been updated since 2011 and should get a rewrite and
simplification...
2017-01-25 12:24:20 -08:00

39 lines
1.1 KiB
Python
Executable file

#!/usr/bin/env python
import os
import sys
import glob
import time
sys.path.insert(0, "/home/vbatts/opt/lib/python2.5/site-packages")
sys.path.insert(0, "/home/vbatts/opt/lib/python2.5")
import pyinotify
dir_path = "/mirrors/ftp.slackware.com/pub/slackware"
def process_changelog_rss(event):
if os.path.basename(event.pathname) == "ChangeLog.txt":
print "%f: proccessing %s" % (time.time(), event)
os.system("/home/vbatts/opt/bin/ruby /home/vbatts/bin/gen_changlog_rss.rb %s" % event.pathname)
def main(args):
wm = pyinotify.WatchManager()
notifier = pyinotify.Notifier(wm)
for dir in glob.glob(dir_path + "/*/"):
if os.path.exists(dir + "ChangeLog.txt"):
print "%f: Adding watch for %s" % (time.time(), dir)
wm.add_watch(dir, pyinotify.IN_MOVED_TO, rec=False, proc_fun=process_changelog_rss)
for dir in glob.glob(dir_path + "/*/patches/"):
print "%f: Adding watch for %s" % (time.time(), dir)
wm.add_watch(dir, pyinotify.IN_MOVED_TO, rec=False, proc_fun=process_changelog_rss)
#wm.add_watch("/home/vbatts/", pyinotify.IN_MOVED_TO, rec=False, proc_fun=process_changelog_rss)
notifier.loop()
if __name__ == "__main__": main(sys.argv[1:])