Decoding response!
This commit is contained in:
parent
0765ae191d
commit
9bc3f14cd9
@ -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))
|
||||
print('Error: ' + str(e))
|
||||
|
Loading…
Reference in New Issue
Block a user