diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2011-08-03 13:20:36 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2011-08-03 13:20:36 +1200 |
commit | 12d2b1f926bedfb334ce625aad2e85c53e65f481 (patch) | |
tree | dfa4783dd0ee8b85dd4003eab4a8b5b453333138 /libmproxy/plugins.py | |
parent | 62088a666156f70b65d331bc002a946e58c76013 (diff) | |
download | mitmproxy-12d2b1f926bedfb334ce625aad2e85c53e65f481.tar.gz mitmproxy-12d2b1f926bedfb334ce625aad2e85c53e65f481.tar.bz2 mitmproxy-12d2b1f926bedfb334ce625aad2e85c53e65f481.zip |
Rip out old script interface, start replacing with new stubs.
Scripts are broken for now.
Diffstat (limited to 'libmproxy/plugins.py')
-rw-r--r-- | libmproxy/plugins.py | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/libmproxy/plugins.py b/libmproxy/plugins.py deleted file mode 100644 index 09c2edf8..00000000 --- a/libmproxy/plugins.py +++ /dev/null @@ -1,46 +0,0 @@ -import imp, os, traceback - - -class Context: - def __init__(self, master, state): - self.master, self.state = master, state - - def log(self, *args, **kwargs): - self.master.log(*args, **kwargs) - - -class Plugin: - def __init__(self, path, master): - self.path = path - self.ctx = Context(master, master.state) - self.mod = None - self.ns = None - self.load() - - def load(self): - """ - Loads a module and runs the start method. - """ - ns = {} - self.mod = execfile(os.path.expanduser(self.path), {}, ns) - self.ns = ns - self.run("start") - - def run(self, name, *args, **kwargs): - """ - Runs a plugin method. - - Returns: - - (True, retval) on success. - (False, None) on nonexistent method. - (Fals, (exc, traceback string)) if there was an exception. - """ - f = self.ns.get(name) - if f: - try: - return (True, f(self.ctx, *args, **kwargs)) - except Exception, v: - return (False, (v, traceback.format_exc(v))) - else: - return (False, None) |