mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 09:31:41 -05:00
Catch errors with native run
This commit is contained in:
parent
5d936a7d44
commit
e3cd80a91a
1 changed files with 9 additions and 12 deletions
|
@ -70,18 +70,15 @@ def handleMessage(message):
|
|||
reply = {'version': VERSION}
|
||||
|
||||
elif cmd == 'run':
|
||||
if "|" in message["command"]:
|
||||
commands = message["command"].split("|")
|
||||
p1 = subprocess.Popen(commands[0].split(" "),stdout=subprocess.PIPE)
|
||||
p2 = p1
|
||||
for command in commands[1:]:
|
||||
command = list(filter(None,command.split(" ")))
|
||||
p2 = subprocess.Popen(command,stdin=p1.stdout,stdout=subprocess.PIPE)
|
||||
p1.stdout.close()
|
||||
p1 = p2
|
||||
output = p2.communicate()[0].decode("utf-8")
|
||||
else:
|
||||
output = subprocess.check_output(message["command"].split(" ")).decode("utf-8")
|
||||
commands = message["command"].split("|")
|
||||
p1 = subprocess.Popen(commands[0].split(" "),stderr=subprocess.STDOUT,stdout=subprocess.PIPE)
|
||||
p2 = p1
|
||||
for command in commands[1:]:
|
||||
command = list(filter(None,command.split(" ")))
|
||||
p2 = subprocess.Popen(command,stdin=p1.stdout,stderr=subprocess.STDOUT,stdout=subprocess.PIPE)
|
||||
p1.stdout.close()
|
||||
p1 = p2
|
||||
output = p2.communicate()[0].decode("utf-8")
|
||||
reply['content'] = output if output else ""
|
||||
|
||||
elif cmd == 'eval':
|
||||
|
|
Loading…
Add table
Reference in a new issue