# HG changeset patch # User Steve Losh # Date 1353783258 18000 # Node ID 0e92c9363422df88fb493d3546fa6309eb60f7af # Parent 154eb9cb113d5eeb8cc26b332059cdef1157a73c Don't choke on deleted files. diff -r 154eb9cb113d -r 0e92c9363422 peat --- a/peat Sat Nov 24 13:48:39 2012 -0500 +++ b/peat Sat Nov 24 13:54:18 2012 -0500 @@ -14,7 +14,7 @@ # Repeat commands! # ################## -import os, subprocess, sys, time +import errno, os, subprocess, sys, time from optparse import OptionParser @@ -36,8 +36,16 @@ def check(paths): cutoff = int(time.time() - interval) for p in paths: - if os.stat(p).st_mtime >= cutoff: - return True + try: + if os.stat(p).st_mtime >= cutoff: + return True + except OSError, e: + # If the file has been deleted since we started watching, don't + # worry about it. + if e.errno == errno.ENOENT: + pass + else: + raise return False def run():