mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-02-01 07:49:10 +00:00
scripts: allow package imports
This commit is contained in:
parent
714ba16111
commit
ff53e7a6eb
@ -74,6 +74,7 @@ class Script(object):
|
|||||||
script_dir = os.path.dirname(os.path.abspath(self.args[0]))
|
script_dir = os.path.dirname(os.path.abspath(self.args[0]))
|
||||||
self.ns = {'__file__': os.path.abspath(self.args[0])}
|
self.ns = {'__file__': os.path.abspath(self.args[0])}
|
||||||
sys.path.append(script_dir)
|
sys.path.append(script_dir)
|
||||||
|
sys.path.append(os.path.join(script_dir, ".."))
|
||||||
try:
|
try:
|
||||||
with open(self.filename) as f:
|
with open(self.filename) as f:
|
||||||
code = compile(f.read(), self.filename, 'exec')
|
code = compile(f.read(), self.filename, 'exec')
|
||||||
@ -86,6 +87,7 @@ class Script(object):
|
|||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
sys.path.pop()
|
sys.path.pop()
|
||||||
|
sys.path.pop()
|
||||||
return self.run("start", self.args)
|
return self.run("start", self.args)
|
||||||
|
|
||||||
def unload(self):
|
def unload(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user