Commits

Steve Losh committed 0e92c93

Don't choke on deleted files.

  • Participants
  • Parent commits 154eb9c
  • Tags v0.2.1

Comments (0)

Files changed (1)

                               # Repeat commands! #
                                ##################
 
-import os, subprocess, sys, time
+import errno, os, subprocess, sys, time
 from optparse import OptionParser
 
 
 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():