From a942f55854626c62e6978c11a3e93189c08e920a Mon Sep 17 00:00:00 2001 From: Real-Gecko Date: Wed, 7 Oct 2020 18:04:43 +0600 Subject: [PATCH] Fixed error handling from gstfsd in instances --- instances/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/instances/views.py b/instances/views.py index fcaacfb..6f6c4d7 100644 --- a/instances/views.py +++ b/instances/views.py @@ -398,10 +398,13 @@ def add_public_key(request, pk): if instance.proxy.get_status() == 5: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((instance.compute.hostname, 16510)) - s.send(json.dumps(data)) + s.send(json.dumps(data).encode()) result = json.loads(s.recv(1024)) s.close() - msg = _("Installed new SSH public key %(keyname)s") % {'keyname': publickey.keyname} + if result['return'] == 'error': + msg = result['message'] + else: + msg = _("Installed new SSH public key %(keyname)s") % {'keyname': publickey.keyname} addlogmsg(request.user.username, instance.name, msg) if result['return'] == 'success':