clean up removal of tqdm

This commit is contained in:
CactiChameleon9 2020-12-10 08:44:59 +00:00
parent 4eb152b8aa
commit 4904363288
7 changed files with 220 additions and 229 deletions

View File

@ -31,22 +31,21 @@ filename = os.path.basename(filename)
filesize = int(filesize) filesize = int(filesize)
# start receiving the file from the socket # start receiving the file from the socket
# and writing to the file stream # and writing to the file stream
progress = "_"
#with open(filename, "wb") as f: #with open(filename, "wb") as f:
while True: while True:
for _ in progress: # read 1024 bytes from the socket (receive)
# read 1024 bytes from the socket (receive) bytes_read = client_socket.recv(BUFFER_SIZE)
bytes_read = client_socket.recv(BUFFER_SIZE) if not bytes_read:
if not bytes_read: # nothing is received
# nothing is received # file transmitting is done take another time
# file transmitting is done take another time break
break # write to the file the bytes we just received
# write to the file the bytes we just received f = open(filename, 'ab')
f = open(filename, 'ab') f.write(bytes_read)
f.write(bytes_read) print(bytes_read)
print(bytes_read) f.close()
f.close()
# close the client socket # close the client socket
#client_socket.close() #client_socket.close()

View File

@ -35,119 +35,117 @@ filename = os.path.basename(filename)
filesize = int(filesize) filesize = int(filesize)
# start receiving the file from the socket # start receiving the file from the socket
# and writing to the file stream # and writing to the file stream
progress = "_"
#with open(filename, "wb") as f: #with open(filename, "wb") as f:
def pressRrelease_char(char): def pressRrelease_char(char):
keyboard.press(char) keyboard.press(char)
while True: while True:
for _ in progress: # read 1024 bytes from the socket (receive)
# read 1024 bytes from the socket (receive) bytes_read = client_socket.recv(BUFFER_SIZE)
bytes_read = client_socket.recv(BUFFER_SIZE) if not bytes_read:
if not bytes_read: # nothing is received
# nothing is received # file transmitting is done take another time
# file transmitting is done take another time break
break # write to the file the bytes we just received
# write to the file the bytes we just received f = open(filename, 'wb')
f = open(filename, 'wb') f.write(bytes_read)
f.write(bytes_read) # update the progress bar
# update the progress bar f.close()
f.close()
g = open(filename, 'r')
ge = g.read()
print (ge)
try:
if (ge == "Key.enter"):
pressRrelease_char(Key.enter)
elif (ge == "Key.shift"):
pressRrelease_char(Key.shift)
elif (ge == "Key.space"):
pressRrelease_char(Key.space)
elif (ge == "Key.backspace"):
pressRrelease_char(Key.backspace)
elif (ge == "Key.ctrl_r"):
pressRrelease_char(Key.ctrl_r)
elif (ge == "Key.ctrl_l"):
pressRrelease_char(Key.ctrl_l)
elif (ge == "Key.shift_r"):
pressRrelease_char(Key.shift_r)
elif (ge == "Key.alt_l"):
pressRrelease_char(Key.alt_l)
elif (ge == "Key.alt_r"):
pressRrelease_char(Key.alt_r)
elif (ge == "Key.cmd"):
pressRrelease_char(Key.cmd)
elif (ge == "Key.caps_lock"):
pressRrelease_char(Key.caps_lock)
elif (ge == "Key.tab"):
pressRrelease_char(Key.tab)
elif (ge == "Key.f1"):
pressRrelease_char(Key.f1)
elif (ge == "Key.f2"):
pressRrelease_char(Key.f2)
elif (ge == "Key.f3"):
pressRrelease_char(Key.f3)
elif (ge == "Key.f4"):
pressRrelease_char(Key.f4)
elif (ge == "Key.f5"):
pressRrelease_char(Key.f5)
elif (ge == "Key.f6"):
pressRrelease_char(Key.f6)
elif (ge == "Key.f7"):
pressRrelease_char(Key.f7)
elif (ge == "Key.f8"):
pressRrelease_char(Key.f8)
elif (ge == "Key.f9"):
pressRrelease_char(Key.f9)
elif (ge == "Key.f10"):
pressRrelease_char(Key.f10)
elif (ge == "Key.f11"):
pressRrelease_char(Key.f11)
elif (ge == "Key.f12"):
pressRrelease_char(Key.f12)
elif (ge == "Key.esc"):
pressRrelease_char(Key.esc)
elif (ge == "Key.insert"):
pressRrelease_char(Key.insert)
elif (ge == "Key.delete"):
pressRrelease_char(Key.delete)
elif (ge == "Key.end"):
pressRrelease_char(Key.end)
elif (ge == "Key.num_lock"):
pressRrelease_char(Key.num_lock)
elif (ge == "Key.home"):
pressRrelease_char(Key.home)
elif (ge == "Key.page_up"):
pressRrelease_char(Key.page_up)
elif (ge == "Key.page_down"):
pressRrelease_char(Key.page_down)
elif (ge == "Key.pause"):
pressRrelease_char(Key.pause)
elif (ge == "Key.scroll_lock"):
pressRrelease_char(Key.scroll_lock)
elif (ge == "Key.menu"):
pressRrelease_char(Key.menu)
elif (ge == "Key.print_screen"):
pressRrelease_char(Key.print_screen)
elif (ge == "Key.left"):
pressRrelease_char(Key.left)
elif (ge == "Key.up"):
pressRrelease_char(Key.up)
elif (ge == "Key.right"):
pressRrelease_char(Key.right)
elif (ge == "Key.down"):
pressRrelease_char(Key.down)
else:
pressRrelease_char((ge))
except:
print("an error occured with ", ge)
g.close()
g = open(filename, 'r')
ge = g.read()
print (ge)
try:
if (ge == "Key.enter"):
pressRrelease_char(Key.enter)
elif (ge == "Key.shift"):
pressRrelease_char(Key.shift)
elif (ge == "Key.space"):
pressRrelease_char(Key.space)
elif (ge == "Key.backspace"):
pressRrelease_char(Key.backspace)
elif (ge == "Key.ctrl_r"):
pressRrelease_char(Key.ctrl_r)
elif (ge == "Key.ctrl_l"):
pressRrelease_char(Key.ctrl_l)
elif (ge == "Key.shift_r"):
pressRrelease_char(Key.shift_r)
elif (ge == "Key.alt_l"):
pressRrelease_char(Key.alt_l)
elif (ge == "Key.alt_r"):
pressRrelease_char(Key.alt_r)
elif (ge == "Key.cmd"):
pressRrelease_char(Key.cmd)
elif (ge == "Key.caps_lock"):
pressRrelease_char(Key.caps_lock)
elif (ge == "Key.tab"):
pressRrelease_char(Key.tab)
elif (ge == "Key.f1"):
pressRrelease_char(Key.f1)
elif (ge == "Key.f2"):
pressRrelease_char(Key.f2)
elif (ge == "Key.f3"):
pressRrelease_char(Key.f3)
elif (ge == "Key.f4"):
pressRrelease_char(Key.f4)
elif (ge == "Key.f5"):
pressRrelease_char(Key.f5)
elif (ge == "Key.f6"):
pressRrelease_char(Key.f6)
elif (ge == "Key.f7"):
pressRrelease_char(Key.f7)
elif (ge == "Key.f8"):
pressRrelease_char(Key.f8)
elif (ge == "Key.f9"):
pressRrelease_char(Key.f9)
elif (ge == "Key.f10"):
pressRrelease_char(Key.f10)
elif (ge == "Key.f11"):
pressRrelease_char(Key.f11)
elif (ge == "Key.f12"):
pressRrelease_char(Key.f12)
elif (ge == "Key.esc"):
pressRrelease_char(Key.esc)
elif (ge == "Key.insert"):
pressRrelease_char(Key.insert)
elif (ge == "Key.delete"):
pressRrelease_char(Key.delete)
elif (ge == "Key.end"):
pressRrelease_char(Key.end)
elif (ge == "Key.num_lock"):
pressRrelease_char(Key.num_lock)
elif (ge == "Key.home"):
pressRrelease_char(Key.home)
elif (ge == "Key.page_up"):
pressRrelease_char(Key.page_up)
elif (ge == "Key.page_down"):
pressRrelease_char(Key.page_down)
elif (ge == "Key.pause"):
pressRrelease_char(Key.pause)
elif (ge == "Key.scroll_lock"):
pressRrelease_char(Key.scroll_lock)
elif (ge == "Key.menu"):
pressRrelease_char(Key.menu)
elif (ge == "Key.print_screen"):
pressRrelease_char(Key.print_screen)
elif (ge == "Key.left"):
pressRrelease_char(Key.left)
elif (ge == "Key.up"):
pressRrelease_char(Key.up)
elif (ge == "Key.right"):
pressRrelease_char(Key.right)
elif (ge == "Key.down"):
pressRrelease_char(Key.down)
else:
pressRrelease_char((ge))
except:
print("an error occured with ", ge)
g.close()
# close the client socket # close the client socket
#client_socket.close() #client_socket.close()

View File

@ -35,7 +35,6 @@ filename = os.path.basename(filename)
filesize = int(filesize) filesize = int(filesize)
# start receiving the file from the socket # start receiving the file from the socket
# and writing to the file stream # and writing to the file stream
progress = "_"
#with open(filename, "wb") as f: #with open(filename, "wb") as f:
@ -43,109 +42,108 @@ def pressRrelease_char(char):
keyboard.release(char) keyboard.release(char)
while True: while True:
for _ in progress: # read 1024 bytes from the socket (receive)
# read 1024 bytes from the socket (receive) bytes_read = client_socket.recv(BUFFER_SIZE)
bytes_read = client_socket.recv(BUFFER_SIZE) if not bytes_read:
if not bytes_read: # nothing is received
# nothing is received # file transmitting is done take another time
# file transmitting is done take another time break
break # write to the file the bytes we just received
# write to the file the bytes we just received f = open(filename, 'wb')
f = open(filename, 'wb') f.write(bytes_read)
f.write(bytes_read)
f.close()
g = open(filename, 'r')
ge = g.read()
print (ge) f.close()
try:
if (ge == "Key.enter"): g = open(filename, 'r')
pressRrelease_char(Key.enter) ge = g.read()
elif (ge == "Key.shift"):
pressRrelease_char(Key.shift) print (ge)
elif (ge == "Key.space"): try:
pressRrelease_char(Key.space) if (ge == "Key.enter"):
elif (ge == "Key.backspace"): pressRrelease_char(Key.enter)
pressRrelease_char(Key.backspace) elif (ge == "Key.shift"):
elif (ge == "Key.ctrl_r"): pressRrelease_char(Key.shift)
pressRrelease_char(Key.ctrl_r) elif (ge == "Key.space"):
elif (ge == "Key.ctrl_l"): pressRrelease_char(Key.space)
pressRrelease_char(Key.ctrl_l) elif (ge == "Key.backspace"):
elif (ge == "Key.shift_r"): pressRrelease_char(Key.backspace)
pressRrelease_char(Key.shift_r) elif (ge == "Key.ctrl_r"):
elif (ge == "Key.alt_l"): pressRrelease_char(Key.ctrl_r)
pressRrelease_char(Key.alt_l) elif (ge == "Key.ctrl_l"):
elif (ge == "Key.alt_r"): pressRrelease_char(Key.ctrl_l)
pressRrelease_char(Key.alt_r) elif (ge == "Key.shift_r"):
elif (ge == "Key.cmd"): pressRrelease_char(Key.shift_r)
pressRrelease_char(Key.cmd) elif (ge == "Key.alt_l"):
elif (ge == "Key.caps_lock"): pressRrelease_char(Key.alt_l)
pressRrelease_char(Key.caps_lock) elif (ge == "Key.alt_r"):
elif (ge == "Key.tab"): pressRrelease_char(Key.alt_r)
pressRrelease_char(Key.tab) elif (ge == "Key.cmd"):
elif (ge == "Key.f1"): pressRrelease_char(Key.cmd)
pressRrelease_char(Key.f1) elif (ge == "Key.caps_lock"):
elif (ge == "Key.f2"): pressRrelease_char(Key.caps_lock)
pressRrelease_char(Key.f2) elif (ge == "Key.tab"):
elif (ge == "Key.f3"): pressRrelease_char(Key.tab)
pressRrelease_char(Key.f3) elif (ge == "Key.f1"):
elif (ge == "Key.f4"): pressRrelease_char(Key.f1)
pressRrelease_char(Key.f4) elif (ge == "Key.f2"):
elif (ge == "Key.f5"): pressRrelease_char(Key.f2)
pressRrelease_char(Key.f5) elif (ge == "Key.f3"):
elif (ge == "Key.f6"): pressRrelease_char(Key.f3)
pressRrelease_char(Key.f6) elif (ge == "Key.f4"):
elif (ge == "Key.f7"): pressRrelease_char(Key.f4)
pressRrelease_char(Key.f7) elif (ge == "Key.f5"):
elif (ge == "Key.f8"): pressRrelease_char(Key.f5)
pressRrelease_char(Key.f8) elif (ge == "Key.f6"):
elif (ge == "Key.f9"): pressRrelease_char(Key.f6)
pressRrelease_char(Key.f9) elif (ge == "Key.f7"):
elif (ge == "Key.f10"): pressRrelease_char(Key.f7)
pressRrelease_char(Key.f10) elif (ge == "Key.f8"):
elif (ge == "Key.f11"): pressRrelease_char(Key.f8)
pressRrelease_char(Key.f11) elif (ge == "Key.f9"):
elif (ge == "Key.f12"): pressRrelease_char(Key.f9)
pressRrelease_char(Key.f12) elif (ge == "Key.f10"):
elif (ge == "Key.esc"): pressRrelease_char(Key.f10)
pressRrelease_char(Key.esc) elif (ge == "Key.f11"):
elif (ge == "Key.insert"): pressRrelease_char(Key.f11)
pressRrelease_char(Key.insert) elif (ge == "Key.f12"):
elif (ge == "Key.delete"): pressRrelease_char(Key.f12)
pressRrelease_char(Key.delete) elif (ge == "Key.esc"):
elif (ge == "Key.end"): pressRrelease_char(Key.esc)
pressRrelease_char(Key.end) elif (ge == "Key.insert"):
elif (ge == "Key.num_lock"): pressRrelease_char(Key.insert)
pressRrelease_char(Key.num_lock) elif (ge == "Key.delete"):
elif (ge == "Key.home"): pressRrelease_char(Key.delete)
pressRrelease_char(Key.home) elif (ge == "Key.end"):
elif (ge == "Key.page_up"): pressRrelease_char(Key.end)
pressRrelease_char(Key.page_up) elif (ge == "Key.num_lock"):
elif (ge == "Key.page_down"): pressRrelease_char(Key.num_lock)
pressRrelease_char(Key.page_down) elif (ge == "Key.home"):
elif (ge == "Key.pause"): pressRrelease_char(Key.home)
pressRrelease_char(Key.pause) elif (ge == "Key.page_up"):
elif (ge == "Key.scroll_lock"): pressRrelease_char(Key.page_up)
pressRrelease_char(Key.scroll_lock) elif (ge == "Key.page_down"):
elif (ge == "Key.menu"): pressRrelease_char(Key.page_down)
pressRrelease_char(Key.menu) elif (ge == "Key.pause"):
elif (ge == "Key.print_screen"): pressRrelease_char(Key.pause)
pressRrelease_char(Key.print_screen) elif (ge == "Key.scroll_lock"):
elif (ge == "Key.left"): pressRrelease_char(Key.scroll_lock)
pressRrelease_char(Key.left) elif (ge == "Key.menu"):
elif (ge == "Key.up"): pressRrelease_char(Key.menu)
pressRrelease_char(Key.up) elif (ge == "Key.print_screen"):
elif (ge == "Key.right"): pressRrelease_char(Key.print_screen)
pressRrelease_char(Key.right) elif (ge == "Key.left"):
elif (ge == "Key.down"): pressRrelease_char(Key.left)
pressRrelease_char(Key.down) elif (ge == "Key.up"):
else: pressRrelease_char(Key.up)
pressRrelease_char((ge)) elif (ge == "Key.right"):
except: pressRrelease_char(Key.right)
print("an error occured with ", ge) elif (ge == "Key.down"):
g.close() pressRrelease_char(Key.down)
else:
pressRrelease_char((ge))
except:
print("an error occured with ", ge)
g.close()

View File

@ -45,9 +45,8 @@ s.send(f"{filename}{SEPARATOR}{filesize}".encode())
def sendfile(): def sendfile():
# start sending the file # start sending the file
progress = "_"
with open(filename, "rb") as f: with open(filename, "rb") as f:
for _ in progress: while True:
# read the bytes from the file # read the bytes from the file
bytes_read = f.read(BUFFER_SIZE) bytes_read = f.read(BUFFER_SIZE)
if not bytes_read: if not bytes_read:

View File

@ -44,9 +44,8 @@ s.send(f"{filename}{SEPARATOR}{filesize}".encode())
def sendfile(): def sendfile():
# start sending the file # start sending the file
progress = "_"
with open(filename, "rb") as f: with open(filename, "rb") as f:
for _ in progress: while True:
# read the bytes from the file # read the bytes from the file
bytes_read = f.read(BUFFER_SIZE) bytes_read = f.read(BUFFER_SIZE)
if not bytes_read: if not bytes_read:

View File

@ -32,9 +32,8 @@ s.send(f"{filename}{SEPARATOR}{filesize}".encode())
def sendfile(): def sendfile():
# start sending the file # start sending the file
progress = "_"
with open(filename, "rb") as f: with open(filename, "rb") as f:
for _ in progress: while True:
# read the bytes from the file # read the bytes from the file
bytes_read = f.read(BUFFER_SIZE) bytes_read = f.read(BUFFER_SIZE)
if not bytes_read: if not bytes_read:

View File

@ -29,9 +29,8 @@ s.send(f"{filename}{SEPARATOR}{filesize}".encode())
def sendfile(): def sendfile():
# start sending the file # start sending the file
progress = "_"
with open(filename, "rb") as f: with open(filename, "rb") as f:
for _ in progress: while True:
# read the bytes from the file # read the bytes from the file
bytes_read = f.read(BUFFER_SIZE) bytes_read = f.read(BUFFER_SIZE)
if not bytes_read: if not bytes_read: