mirror of https://git.48k.eu/ogclient
Fix /shell/run commands splitting
This patch splits shell commands either with ';' or '\n'.more_events
parent
96c2ddea2d
commit
9890d60300
|
@ -49,7 +49,7 @@ def reboot():
|
|||
|
||||
def execCMD(request, ogRest):
|
||||
cmd = request.getrun()
|
||||
cmds = cmd.split(" ")
|
||||
cmds = cmd.split(";|\n")
|
||||
try:
|
||||
ogRest.proc = subprocess.Popen(cmds, stdout=subprocess.PIPE, shell=True)
|
||||
(output, error) = ogRest.proc.communicate()
|
||||
|
|
|
@ -62,7 +62,7 @@ class restResponse():
|
|||
|
||||
class ogThread():
|
||||
def execcmd(client, request, ogRest):
|
||||
if request.getrun() == None:
|
||||
if not request.getrun():
|
||||
response = restResponse(ogResponses.BAD_REQUEST)
|
||||
client.send(response.get())
|
||||
return
|
||||
|
|
|
@ -14,7 +14,7 @@ class TestShellRunMethods(unittest.TestCase):
|
|||
|
||||
def test_post_with_echo(self):
|
||||
req_json = '{"run":"echo \\"croqueta\\"", "echo":true}'
|
||||
response_json = '{"out": "\\"croqueta\\"\\n"}'
|
||||
response_json = '{"out": \"croqueta\\n\"}'
|
||||
req = 'POST /shell/run HTTP/1.0\r\nContent-Length:'+ \
|
||||
str(len(req_json)) + \
|
||||
'\r\nContent-Type:application/json\r\n\r\n' + req_json
|
||||
|
|
Loading…
Reference in New Issue