mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 15:37:45 +00:00
fix contextmanager, remove args argument to start()
This commit is contained in:
parent
e7b61995ad
commit
804efe9d38
@ -6,10 +6,12 @@ by the mitmproxy-specific ScriptContext.
|
||||
# Do not import __future__ here, this would apply transitively to the inline scripts.
|
||||
from __future__ import absolute_import, print_function, division
|
||||
|
||||
import inspect
|
||||
import os
|
||||
import shlex
|
||||
import sys
|
||||
import contextlib
|
||||
import warnings
|
||||
|
||||
import six
|
||||
|
||||
@ -20,8 +22,10 @@ from mitmproxy import exceptions
|
||||
def setargs(args):
|
||||
oldargs = sys.argv
|
||||
sys.argv = args
|
||||
yield
|
||||
sys.argv = oldargs
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
sys.argv = oldargs
|
||||
|
||||
|
||||
class Script(object):
|
||||
@ -98,7 +102,15 @@ class Script(object):
|
||||
finally:
|
||||
sys.path.pop()
|
||||
sys.path.pop()
|
||||
return self.run("start", self.args)
|
||||
|
||||
start_fn = self.ns.get("start")
|
||||
if len(inspect.getargspec(start_fn).args) == 2:
|
||||
warnings.warn(
|
||||
"The 'args' argument of the start() script hook is deprecated. "
|
||||
"Please use sys.argv instead."
|
||||
)
|
||||
return self.run("start", self.args)
|
||||
return self.run("start")
|
||||
|
||||
def unload(self):
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user