diff options
author | Maximilian Hils <git@maximilianhils.com> | 2013-12-08 14:14:31 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2013-12-08 14:14:31 +0100 |
commit | e3c69fd105f925009fdf31efe8598f70e2950ab4 (patch) | |
tree | b61bb99ae8e34f73583263619730fbbe5d526161 /libmproxy/script.py | |
parent | 948d4c0445f006640d08d96dc3d6e604df78bc99 (diff) | |
parent | 3a1d85ab18dbff82505feac3619af733a0a2b4f7 (diff) | |
download | mitmproxy-e3c69fd105f925009fdf31efe8598f70e2950ab4.tar.gz mitmproxy-e3c69fd105f925009fdf31efe8598f70e2950ab4.tar.bz2 mitmproxy-e3c69fd105f925009fdf31efe8598f70e2950ab4.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'libmproxy/script.py')
-rw-r--r-- | libmproxy/script.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/libmproxy/script.py b/libmproxy/script.py index 95fd5be2..c32628b0 100644 --- a/libmproxy/script.py +++ b/libmproxy/script.py @@ -8,12 +8,12 @@ class Script: """ The instantiator should do something along this vein: - s = Script(path, master) + s = Script(argv, master) s.load() - s.run("start") """ - def __init__(self, path, ctx): - self.path, self.ctx = path, ctx + def __init__(self, argv, ctx): + self.argv = argv + self.ctx = ctx self.ns = None def load(self): @@ -23,17 +23,21 @@ class Script: Raises ScriptError on failure, with argument equal to an error message that may be a formatted traceback. """ - path = os.path.expanduser(self.path) + path = os.path.expanduser(self.argv[0]) if not os.path.exists(path): - raise ScriptError("No such file: %s"%self.path) + raise ScriptError("No such file: %s" % path) if not os.path.isfile(path): - raise ScriptError("Not a file: %s"%self.path) + raise ScriptError("Not a file: %s" % path) ns = {} try: execfile(path, ns, ns) + self.ns = ns + self.run("start", self.argv) except Exception, v: raise ScriptError(traceback.format_exc(v)) - self.ns = ns + + def unload(self): + return self.run("done") def run(self, name, *args, **kwargs): """ |