X-Git-Url: https://git.ucc.asn.au/?p=minutes-rss.git;a=blobdiff_plain;f=minutes-rss.py;fp=minutes-rss.py;h=2b31f23c04cb937661492708056ae1c80696678b;hp=12c410c90f8c08f37779bc33f732fb883585e2e2;hb=e6d4f12b0cfee1b4a4b0e5da499c08f7cca702b8;hpb=86ce18f8d594ea2233cefa2d382c5f5e7df5fb44 diff --git a/minutes-rss.py b/minutes-rss.py index 12c410c..2b31f23 100755 --- a/minutes-rss.py +++ b/minutes-rss.py @@ -60,15 +60,26 @@ def itemWriter(minutes): output += '\n' return output -# BEWARE THE GIANT HACK - This should be replaced before it burns someone -args = shlex.split('/usr/bin/find %s'%MINUTESPATH + ' -maxdepth 2 -iname "*txt" -type f -printf "%TY-%Tm-%Td %TT %p\n"') -sub = subprocess.Popen(args, stdout=subprocess.PIPE) -items = sub.communicate()[0].split('\n') -items.sort() -items = [os.path.abspath(x.split(' ')[-1]) for x in items[-15:]] -items.reverse() +if __name__ == '__main__': + xmlpath = os.path.join(MINUTESPATH, 'minutes.xml') + try: + lastupdate = os.stat(xmlpath)[-2] + except OSError: + lastupdate = 0 -minutes = [UCCMinutes(x) for x in items] + # BEWARE THE GIANT HACK - This should be replaced before it burns someone + args = shlex.split('/usr/bin/find %s'%MINUTESPATH + ' -maxdepth 2 -iname "*txt" -type f -printf "%TY-%Tm-%Td %TT %p\n"') + sub = subprocess.Popen(args, stdout=subprocess.PIPE) + items = sub.communicate()[0].split('\n') + items.sort() -print RSS(''.join([itemWriter(x) for x in minutes]), minutes[0].modtime) + items = [os.path.abspath(x.split(' ')[-1]) for x in items[-15:]] + items.reverse() + + latestItem = UCCMinutes(items[0]) + + if latestItem.stattime > lastupdate: + minutes = [latestItem] + [UCCMinutes(x) for x in items[1:]] + output = RSS(''.join([itemWriter(x) for x in minutes]), minutes[0].modtime) + open(xmlpath, 'w').write(output)