From e7c4945ae99e2aadbab9372a16e7ca7b9269fabe Mon Sep 17 00:00:00 2001 From: "DESKTOP-DPA61F8\\Benedek" Date: Thu, 29 Apr 2021 19:17:48 +0200 Subject: [PATCH] OK --- client/client.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/client/client.py b/client/client.py index 01f27fc..578991e 100644 --- a/client/client.py +++ b/client/client.py @@ -123,6 +123,8 @@ while True: print("Error: "+str(e)) LOGGED_IN = False continue + else: + print('You are already logged in!') if separatedCommand[0] == 'EXIT': @@ -135,6 +137,7 @@ while True: if separatedCommand[0] == 'LOUT' and len(separatedCommand) == 1: network.sendMessage(command.encode('UTF-8')) print(network.recieveMessage().decode('UTF-8')) + LOGGED_IN = False continue if separatedCommand[0] == 'MKD' and len(separatedCommand) == 2: @@ -173,7 +176,7 @@ while True: network.sendMessage(cmd.encode('UTF-8')) with open(separatedCommand[1], "rb") as file: - network.sendMessage(file.readlines()) + network.sendMessage(file.read()) network.sendMessage('EOF'.encode('UTF-8')) response = network.recieveMessage().decode('UTF-8') @@ -187,12 +190,15 @@ while True: dnlFilename = separatedCommand[1].split(os.path.sep)[-1] cmd = 'DNL ' + dnlFilename network.sendMessage(cmd.encode('UTF-8')) - file = network.recieveMessage().decode('UTF-8') + filecontent = network.recieveMessage() response = network.recieveMessage().decode('UTF-8') - if response == 'OK': + print(DOWNLOAD_LOCATION + dnlFilename) + + if response == 'EOF': with open(DOWNLOAD_LOCATION + dnlFilename, "wb+") as file: - file.writelines(file) + file.write(filecontent) + print('OK') else: print(response)