MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / script_run

Method script_run

mitmproxy/addons/script.py:169–188  ·  view source on GitHub ↗

Run a script on the specified flows. The script is configured with the current options and all lifecycle events for each flow are simulated. Note that the load event is not invoked.

(self, flows: Sequence[flow.Flow], path: mtypes.Path)

Source from the content-addressed store, hash-verified

167
168 @command.command("script.run")
169 def script_run(self, flows: Sequence[flow.Flow], path: mtypes.Path) -> None:
170 """
171 Run a script on the specified flows. The script is configured with
172 the current options and all lifecycle events for each flow are
173 simulated. Note that the load event is not invoked.
174 """
175 if not os.path.isfile(path):
176 logger.error("No such script: %s" % path)
177 return
178 mod = load_script(path)
179 if mod:
180 with addonmanager.safecall():
181 ctx.master.addons.invoke_addon_sync(
182 mod,
183 hooks.ConfigureHook(ctx.options.keys()),
184 )
185 ctx.master.addons.invoke_addon_sync(mod, hooks.RunningHook())
186 for f in flows:
187 for evt in eventsequence.iterate(f):
188 ctx.master.addons.invoke_addon_sync(mod, evt)
189
190 def configure(self, updated):
191 if "scripts" in updated:

Callers 2

test_script_runMethod · 0.95

Calls 5

load_scriptFunction · 0.85
invoke_addon_syncMethod · 0.80
errorMethod · 0.45
keysMethod · 0.45
iterateMethod · 0.45

Tested by 2

test_script_runMethod · 0.76