remove file necesity

This commit is contained in:
CactiChameleon9
2020-12-10 18:00:59 +00:00
parent b475adef12
commit 7c7b478250
3 changed files with 11 additions and 68 deletions

View File

@ -6,7 +6,7 @@ from pynput.keyboard import Key, Controller
keyboard=Controller()
# device's IP address
SERVER_HOST = "127.0.0.1" #(socket.gethostbyname(socket.gethostname()))
SERVER_HOST = "0.0.0.0" #(socket.gethostbyname(socket.gethostname()))
SERVER_PORT = 10001
# receive 4096 bytes each time
BUFFER_SIZE = 128
@ -25,17 +25,6 @@ print(f"[*] Listening as {SERVER_HOST}:{SERVER_PORT}")
client_socket, address = s.accept()
# if below code is executed, that means the sender is connected
print(f"[+] {address} is connected.")
# receive the file infos
# receive using client socket, not server socket
received = client_socket.recv(BUFFER_SIZE).decode()
filename, filesize = received.split(SEPARATOR)
# remove absolute path if there is
filename = os.path.basename(filename)
# convert to integer
filesize = int(filesize)
# start receiving the file from the socket
# and writing to the file stream
#with open(filename, "wb") as f:
def pressRrelease_char(char):
@ -48,15 +37,9 @@ while True:
# nothing is received
# file transmitting is done take another time
break
# write to the file the bytes we just received
f = open(filename, 'wb')
f.write(bytes_read)
# update the progress bar
f.close()
g = open(filename, 'r')
ge = g.read()
ge = bytes_read.decode()
print (ge)
try:
if (ge == "Key.enter"):
@ -143,7 +126,6 @@ while True:
pressRrelease_char((ge))
except:
print("an error occured with ", ge)
g.close()