From 9bc3f14cd9e45e5213ba9c81b4232251ce3f3229 Mon Sep 17 00:00:00 2001 From: "DESKTOP-DPA61F8\\Benedek" Date: Sun, 25 Apr 2021 18:29:28 +0200 Subject: [PATCH] Decoding response! --- client/client.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/client/client.py b/client/client.py index 88ecefb..4f2b1b6 100644 --- a/client/client.py +++ b/client/client.py @@ -40,6 +40,7 @@ def loadPrivateKey(passphrase: str) -> RsaKey: return rsaKey + def loadAddress() -> str: with open(CONFIG_LOCATION) as json_file: data = json.load(json_file) @@ -121,32 +122,32 @@ while True: if separatedCommand[0] == 'LOUT' and len(separatedCommand) == 1: network.sendMessage(command.encode('UTF-8')) - print(network.recieveMessage()) + print(network.recieveMessage().decode('UTF-8')) continue if separatedCommand[0] == 'MKD' and len(separatedCommand) == 2: network.sendMessage(command.encode('UTF-8')) - print(network.recieveMessage()) + print(network.recieveMessage().decode('UTF-8')) continue if separatedCommand[0] == 'RMD' and len(separatedCommand) == 2: network.sendMessage(command.encode('UTF-8')) - print(network.recieveMessage()) + print(network.recieveMessage().decode('UTF-8')) continue if separatedCommand[0] == 'GWD' and len(separatedCommand) == 1: network.sendMessage(command.encode('UTF-8')) - print(network.recieveMessage()) + print(network.recieveMessage().decode('UTF-8')) continue if separatedCommand[0] == 'CWD' and len(separatedCommand) == 2: network.sendMessage(command.encode('UTF-8')) - print(network.recieveMessage()) + print(network.recieveMessage().decode('UTF-8')) continue if separatedCommand[0] == 'LST' and len(separatedCommand) == 1: network.sendMessage(command.encode('UTF-8')) - print(network.recieveMessage()) + print(network.recieveMessage().decode('UTF-8')) continue if separatedCommand[0] == 'UPL' and len(separatedCommand) == 2: @@ -158,8 +159,8 @@ while True: network.sendMessage(file.readlines()) network.sendMessage('EOF'.encode('UTF-8')) - response = network.recieveMessage() - print(response.decode()) + response = network.recieveMessage().decode('UTF-8') + print(response) else: print('Invalid argument for file upload: ' + separatedCommand[1]) @@ -169,18 +170,18 @@ while True: dnlFilename = separatedCommand[1].split(os.path.sep)[-1] cmd = 'DNL ' + dnlFilename network.sendMessage(cmd.encode('UTF-8')) - file = network.recieveMessage() - response = network.recieveMessage() + file = network.recieveMessage().decode('UTF-8') + response = network.recieveMessage().decode('UTF-8') if response == 'OK': with open(DOWNLOAD_LOCATION + dnlFilename, "wb+") as file: file.writelines(file) else: - print(response.decode()) + print(response) continue printCommand() except Exception as e: - print('Error: '+str(e)) \ No newline at end of file + print('Error: ' + str(e))