diff options
author | Ramón M. Gómez <ramongomez@us.es> | 2019-05-23 14:29:08 +0200 |
---|---|---|
committer | Ramón M. Gómez <ramongomez@us.es> | 2019-05-23 14:29:08 +0200 |
commit | 41c655ecc659d90f3c01244cd5d596c5a3a4368a (patch) | |
tree | 062014fad8cfff6169050f03a31d260a35ac95b7 | |
parent | f573d46cf13a0723082b2ec9e8af29ca70bc9b46 (diff) |
#908: Trying to fix a bug when obteining execution outputs.
-rw-r--r-- | admin/Sources/Clients/ogagent/src/opengnsys/modules/server/OpenGnSys/__init__.py | 3 | ||||
-rw-r--r-- | admin/Sources/Clients/ogagent/src/opengnsys/oglive/operations.py | 4 |
2 files changed, 4 insertions, 3 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 7b14e365..70c3fd4e 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 @@ -160,8 +160,7 @@ class OpenGnSysWorker(ServerWorker): route = route[len(self.REST.endpoint):] # Send back exit status and outputs (base64-encoded) self.REST.sendMessage(route, {'mac': self.interface.mac, 'ip': self.interface.ip, 'trace': op_id, - 'status': stat, 'output': out.encode('utf8').encode('base64'), - 'error': err.encode('utf8').encode('base64')}) + 'status': stat, 'output': out.encode('base64'), 'error': err.encode('base64')}) # Show latest menu, if OGAgent runs on ogLive if os_type == 'oglive': # Send configuration data, if needed diff --git a/admin/Sources/Clients/ogagent/src/opengnsys/oglive/operations.py b/admin/Sources/Clients/ogagent/src/opengnsys/oglive/operations.py index 3cdeef09..9ec907c1 100644 --- a/admin/Sources/Clients/ogagent/src/opengnsys/oglive/operations.py +++ b/admin/Sources/Clients/ogagent/src/opengnsys/oglive/operations.py @@ -39,6 +39,7 @@ import subprocess import struct import array import six +import chardet from opengnsys import utils @@ -209,7 +210,8 @@ def exec_command(cmd): proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = proc.communicate() stat = proc.returncode - return stat, out, err + return stat, out.decode(chardet.detect(out)['encoding']).encode('utf8'),\ + err.decode(chardet.detect(err)['encoding']).encode('utf8') def get_hardware(): |