From 12d2b1f926bedfb334ce625aad2e85c53e65f481 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Wed, 3 Aug 2011 13:20:36 +1200 Subject: Rip out old script interface, start replacing with new stubs. Scripts are broken for now. --- libmproxy/plugins.py | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 libmproxy/plugins.py (limited to 'libmproxy/plugins.py') 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) -- cgit v1.2.3