#718: Soportar comando Ejecutar Script en agente de sistema operativo.

git-svn-id: https://opengnsys.es/svn/branches/version1.1@5134 a21b9725-9963-47de-94b9-378ad31fedc9
oglive
ramon 2017-01-05 11:31:49 +00:00
parent 4c0ad234ee
commit 157e9e72a0
1 changed files with 6 additions and 3 deletions

View File

@ -45,6 +45,7 @@ import platform
import time
import random
import string
import urllib
# Error handler decorator.
def catchBackgroundError(fnc):
@ -106,10 +107,12 @@ class OpenGnSysWorker(ServerWorker):
if secret != self.random:
logger.error('Unauthorized operation.')
raise Exception('Unauthorized operation')
# Executing script
script = postParams.get('script')
# Decoding script.
script = urllib.unquote(postParams.get('script').decode('base64')).decode('utf8')
script = 'import subprocess; subprocess.check_output("""{}""",shell=True)'.format(script)
# Executing script.
if postParams.get('client', 'false') == 'false':
thr = ScriptExecutorThread(script=script.decode('base64'))
thr = ScriptExecutorThread(script)
thr.start()
else:
self.sendScriptMessage(script)