aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-07-23 11:08:14 +1200
committerAldo Cortesi <aldo@nullcube.com>2016-07-23 11:08:14 +1200
commit05caa0a03d118a8f0fdf42bbe34ed74c8940c4a0 (patch)
tree63986a4b01724be6ecbc1ed84bda6fe6a39ea653
parent51a8ba57f1a6e8fdece5daf893176ccb67d18b1a (diff)
downloadmitmproxy-05caa0a03d118a8f0fdf42bbe34ed74c8940c4a0.tar.gz
mitmproxy-05caa0a03d118a8f0fdf42bbe34ed74c8940c4a0.tar.bz2
mitmproxy-05caa0a03d118a8f0fdf42bbe34ed74c8940c4a0.zip
script: tune auto reload
- Don't respond to directory changes - Ignore hidden files I've "solved" this as well as it can be done in modd, and getting good results here just turns into a large pile of heuristics that don't work in all circumstances. Also watchdog sucks.
-rw-r--r--mitmproxy/builtins/script.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/mitmproxy/builtins/script.py b/mitmproxy/builtins/script.py
index 468aa8e0..220fb9af 100644
--- a/mitmproxy/builtins/script.py
+++ b/mitmproxy/builtins/script.py
@@ -94,11 +94,21 @@ class ReloadHandler(watchdog.events.FileSystemEventHandler):
def __init__(self, callback):
self.callback = callback
+ def filter(self, event):
+ if event.is_directory:
+ return False
+ if os.path.basename(event.src_path).startswith("."):
+ return False
+ print(event.src_path)
+ return True
+
def on_modified(self, event):
- self.callback()
+ if self.filter(event):
+ self.callback()
def on_created(self, event):
- self.callback()
+ if self.filter(event):
+ self.callback()
class Script: