diff options
author | Ramón M. Gómez <ramongomez@us.es> | 2020-04-23 12:53:27 +0200 |
---|---|---|
committer | Ramón M. Gómez <ramongomez@us.es> | 2020-04-23 12:53:27 +0200 |
commit | 88fc95a93b9db4528257c4d9e4a39eed22c68783 (patch) | |
tree | 24fa3a557745a5693ca0cd169cdf03e8f6920107 /admin/Sources | |
parent | 570e249505b5de4535ef19b6a16472e781369014 (diff) |
#962: Only OGAgent for Windows runs each line in independent processes (other agents can run the whole script in a single subprocess).
Diffstat (limited to 'admin/Sources')
-rw-r--r-- | admin/Sources/Clients/ogagent/src/opengnsys/modules/server/OpenGnSys/__init__.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/admin/Sources/Clients/ogagent/src/opengnsys/modules/server/OpenGnSys/__init__.py b/admin/Sources/Clients/ogagent/src/opengnsys/modules/server/OpenGnSys/__init__.py index 4e3c613a..5fab6589 100644 --- a/admin/Sources/Clients/ogagent/src/opengnsys/modules/server/OpenGnSys/__init__.py +++ b/admin/Sources/Clients/ogagent/src/opengnsys/modules/server/OpenGnSys/__init__.py @@ -82,8 +82,8 @@ class OpenGnSysWorker(ServerWorker): REST = None # REST object logged_in = False # User session flag locked = {} - random = None # Random string for secure connections - length = 32 # Random string length + random = None # Random string for secure connections + length = 32 # Random string length def onActivation(self): """ @@ -280,10 +280,13 @@ class OpenGnSysWorker(ServerWorker): :return: JSON object {"op": "launched"} """ logger.debug('Processing script request') - # Decoding script + # Decoding script (Windows scripts need a subprocess call per line) script = urllib.unquote(post_params.get('script').decode('base64')).decode('utf8') - script = 'import subprocess;{0}'.format( - ';'.join(['subprocess.check_output({0},shell=True)'.format(repr(c)) for c in script.split('\n')])) + if operations.os_type == 'Windoes': + script = 'import subprocess; {0}'.format( + ';'.join(['subprocess.check_output({0},shell=True)'.format(repr(c)) for c in script.split('\n')])) + else: + script = 'import subprocess; subprocess.check_output("""{0}""",shell=True)'.format(script) # Executing script. if post_params.get('client', 'false') == 'false': thr = ScriptExecutorThread(script) |