mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
fix #349
This commit is contained in:
parent
b6986b8999
commit
58ea198698
@ -179,7 +179,9 @@ class StatusBar(common.WWrap):
|
|||||||
scheme += "2https" if dst[1] else "http"
|
scheme += "2https" if dst[1] else "http"
|
||||||
r.append("[dest:%s]"%utils.unparse_url(scheme, *self.master.server.config.get_upstream_server.dst[2:]))
|
r.append("[dest:%s]"%utils.unparse_url(scheme, *self.master.server.config.get_upstream_server.dst[2:]))
|
||||||
if self.master.scripts:
|
if self.master.scripts:
|
||||||
r.append("[scripts:%s]"%len(self.master.scripts))
|
r.append("[")
|
||||||
|
r.append(("heading_key", "s"))
|
||||||
|
r.append("cripts:%s]"%len(self.master.scripts))
|
||||||
# r.append("[lt:%0.3f]"%self.master.looptime)
|
# r.append("[lt:%0.3f]"%self.master.looptime)
|
||||||
|
|
||||||
if self.master.stream:
|
if self.master.stream:
|
||||||
@ -784,8 +786,14 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
else:
|
else:
|
||||||
self.view_flowlist()
|
self.view_flowlist()
|
||||||
|
|
||||||
def edit_scripts(self, *args, **kwargs):
|
def edit_scripts(self, scripts):
|
||||||
pass
|
commands = [x[0] for x in scripts] # remove outer array
|
||||||
|
if commands == [s.command for s in self.scripts]:
|
||||||
|
return
|
||||||
|
|
||||||
|
self.unload_scripts()
|
||||||
|
for command in commands:
|
||||||
|
self.load_script(command)
|
||||||
|
|
||||||
def loop(self):
|
def loop(self):
|
||||||
changed = True
|
changed = True
|
||||||
@ -878,7 +886,7 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
self.view_grideditor(
|
self.view_grideditor(
|
||||||
grideditor.ScriptEditor(
|
grideditor.ScriptEditor(
|
||||||
self,
|
self,
|
||||||
[[i.argv[0]] for i in self.scripts],
|
[[i.command] for i in self.scripts],
|
||||||
self.edit_scripts
|
self.edit_scripts
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -494,8 +494,11 @@ class FlowMaster(controller.Master):
|
|||||||
|
|
||||||
def unload_scripts(self):
|
def unload_scripts(self):
|
||||||
for s in self.scripts[:]:
|
for s in self.scripts[:]:
|
||||||
s.unload()
|
self.unload_script(s)
|
||||||
self.scripts.remove(s)
|
|
||||||
|
def unload_script(self, script):
|
||||||
|
script.unload()
|
||||||
|
self.scripts.remove(script)
|
||||||
|
|
||||||
def load_script(self, command):
|
def load_script(self, command):
|
||||||
"""
|
"""
|
||||||
|
@ -55,6 +55,8 @@ class Script:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse_command(klass, command):
|
def parse_command(klass, command):
|
||||||
|
if not command or not command.strip():
|
||||||
|
raise ScriptError("Empty script command.")
|
||||||
if os.name == "nt": # Windows: escape all backslashes in the path.
|
if os.name == "nt": # Windows: escape all backslashes in the path.
|
||||||
backslashes = shlex.split(command, posix=False)[0].count("\\")
|
backslashes = shlex.split(command, posix=False)[0].count("\\")
|
||||||
command = command.replace("\\", "\\\\", backslashes)
|
command = command.replace("\\", "\\\\", backslashes)
|
||||||
|
Loading…
Reference in New Issue
Block a user