Wired (in theory)
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
DESKTOP-DPA61F8\Benedek 2021-04-25 17:39:54 +02:00
parent 2412412ff6
commit 0765ae191d

View File

@ -45,6 +45,7 @@ def loadAddress() -> str:
data = json.load(json_file) data = json.load(json_file)
return data['address'] return data['address']
def printCommand(): def printCommand():
print('\nInvalid command! Available commands:\n' + print('\nInvalid command! Available commands:\n' +
' Create directory -> MKD <directory name> \n' + ' Create directory -> MKD <directory name> \n' +
@ -120,40 +121,63 @@ while True:
if separatedCommand[0] == 'LOUT' and len(separatedCommand) == 1: if separatedCommand[0] == 'LOUT' and len(separatedCommand) == 1:
network.sendMessage(command.encode('UTF-8')) network.sendMessage(command.encode('UTF-8'))
print(network.recieveMessage())
continue continue
if separatedCommand[0] == 'MKD' and len(separatedCommand) == 2: if separatedCommand[0] == 'MKD' and len(separatedCommand) == 2:
network.sendMessage(command.encode('UTF-8')) network.sendMessage(command.encode('UTF-8'))
print(network.recieveMessage())
continue continue
if separatedCommand[0] == 'RMD' and len(separatedCommand) == 2: if separatedCommand[0] == 'RMD' and len(separatedCommand) == 2:
network.sendMessage(command.encode('UTF-8')) network.sendMessage(command.encode('UTF-8'))
print(network.recieveMessage())
continue continue
if separatedCommand[0] == 'GWD' and len(separatedCommand) == 1: if separatedCommand[0] == 'GWD' and len(separatedCommand) == 1:
network.sendMessage(command.encode('UTF-8')) network.sendMessage(command.encode('UTF-8'))
print(network.recieveMessage())
continue continue
if separatedCommand[0] == 'CWD' and len(separatedCommand) == 2: if separatedCommand[0] == 'CWD' and len(separatedCommand) == 2:
network.sendMessage(command.encode('UTF-8')) network.sendMessage(command.encode('UTF-8'))
print(network.recieveMessage())
continue continue
if separatedCommand[0] == 'LST' and len(separatedCommand) == 1: if separatedCommand[0] == 'LST' and len(separatedCommand) == 1:
network.sendMessage(command.encode('UTF-8')) network.sendMessage(command.encode('UTF-8'))
print(network.recieveMessage())
continue continue
if separatedCommand[0] == 'UPL' and len(separatedCommand) == 2: if separatedCommand[0] == 'UPL' and len(separatedCommand) == 2:
if os.path.isfile(separatedCommand[1]): if os.path.isfile(separatedCommand[1]):
cmd = 'UPL ' + separatedCommand[1].split(os.path.sep)[-1]
network.sendMessage(cmd.encode('UTF-8'))
with open(separatedCommand[1], "rb") as file: with open(separatedCommand[1], "rb") as file:
print('TODO: Implement!') network.sendMessage(file.readlines())
network.sendMessage('EOF'.encode('UTF-8'))
response = network.recieveMessage()
print(response.decode())
else: else:
print('Invalid argument for file upload: ' + separatedCommand[1]) print('Invalid argument for file upload: ' + separatedCommand[1])
continue continue
if separatedCommand[0] == 'DNL' and len(separatedCommand) == 2: if separatedCommand[0] == 'DNL' and len(separatedCommand) == 2:
dnlFilename = separatedCommand[1].rsplit(os.apth.sep, 1)[-1] dnlFilename = separatedCommand[1].split(os.path.sep)[-1]
with open(DOWNLOAD_LOCATION + dnlFilename, "wb") as file: cmd = 'DNL ' + dnlFilename
print('TODO: Implement!') network.sendMessage(cmd.encode('UTF-8'))
file = network.recieveMessage()
response = network.recieveMessage()
if response == 'OK':
with open(DOWNLOAD_LOCATION + dnlFilename, "wb+") as file:
file.writelines(file)
else:
print(response.decode())
continue continue
printCommand() printCommand()