Merge pull request 'Remove tqdm from the scripts' (#3) from no_tqdm into master
Reviewed-on: https://gitea.doserver.duckdns.org/CactiChameleon9/Remote_Control_Python_Script/pulls/3
This commit is contained in:
commit
b475adef12
@ -1,11 +1,11 @@
|
|||||||
import socket
|
import socket
|
||||||
import os
|
import os
|
||||||
import tqdm
|
|
||||||
# device's IP address
|
# device's IP address
|
||||||
SERVER_HOST = "127.0.0.1" #(socket.gethostbyname(socket.gethostname()))
|
SERVER_HOST = "127.0.0.1" #(socket.gethostbyname(socket.gethostname()))
|
||||||
SERVER_PORT = 5001
|
SERVER_PORT = 5001
|
||||||
# receive 4096 bytes each time
|
# receive 4096 bytes each time
|
||||||
BUFFER_SIZE = 4096
|
BUFFER_SIZE = 128
|
||||||
SEPARATOR = "<SEPARATOR>"
|
SEPARATOR = "<SEPARATOR>"
|
||||||
# create the server socket
|
# create the server socket
|
||||||
# TCP socket
|
# TCP socket
|
||||||
@ -31,11 +31,10 @@ 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 = tqdm.tqdm(range(filesize), f"Receiving {filename}", unit="B", unit_scale=True, unit_divisor=1024)
|
|
||||||
#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:
|
||||||
@ -44,10 +43,9 @@ while True:
|
|||||||
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')
|
||||||
|
if (bytes_read.find("Key") == -1): #don't write shifts and controls
|
||||||
f.write(bytes_read)
|
f.write(bytes_read)
|
||||||
print(bytes_read)
|
print(bytes_read)
|
||||||
# update the progress bar
|
|
||||||
progress.update(len(bytes_read))
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
# close the client socket
|
# close the client socket
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import socket
|
import socket
|
||||||
import os
|
import os
|
||||||
import tqdm
|
|
||||||
import pynput
|
import pynput
|
||||||
from pynput.keyboard import Key, Controller
|
from pynput.keyboard import Key, Controller
|
||||||
#press
|
#press
|
||||||
@ -36,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 = tqdm.tqdm(range(filesize), f"Receiving {filename}", unit="B", unit_scale=True, unit_divisor=1024)
|
|
||||||
#with open(filename, "wb") as f:
|
#with open(filename, "wb") as f:
|
||||||
|
|
||||||
|
|
||||||
@ -44,7 +42,6 @@ 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:
|
||||||
@ -55,7 +52,6 @@ while True:
|
|||||||
f = open(filename, 'wb')
|
f = open(filename, 'wb')
|
||||||
f.write(bytes_read)
|
f.write(bytes_read)
|
||||||
# update the progress bar
|
# update the progress bar
|
||||||
progress.update(len(bytes_read))
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
g = open(filename, 'r')
|
g = open(filename, 'r')
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import socket
|
import socket
|
||||||
import os
|
import os
|
||||||
import tqdm
|
|
||||||
import pynput
|
import pynput
|
||||||
from pynput.keyboard import Key, Controller
|
from pynput.keyboard import Key, Controller
|
||||||
#release
|
#release
|
||||||
@ -36,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 = tqdm.tqdm(range(filesize), f"Receiving {filename}", unit="B", unit_scale=True, unit_divisor=1024)
|
|
||||||
#with open(filename, "wb") as f:
|
#with open(filename, "wb") as f:
|
||||||
|
|
||||||
|
|
||||||
@ -44,7 +42,6 @@ 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:
|
||||||
@ -54,8 +51,7 @@ while True:
|
|||||||
# 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
|
|
||||||
progress.update(len(bytes_read))
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
g = open(filename, 'r')
|
g = open(filename, 'r')
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import socket
|
import socket
|
||||||
import os
|
import os
|
||||||
import tqdm
|
|
||||||
import pynput
|
import pynput
|
||||||
from pynput.mouse import Button, Controller
|
from pynput.mouse import Button, Controller
|
||||||
import time
|
import time
|
||||||
@ -38,14 +37,12 @@ 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 = tqdm.tqdm(range(filesize), f"Receiving {filename}", unit="B", unit_scale=True, unit_divisor=1024)
|
|
||||||
#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:
|
||||||
@ -57,8 +54,6 @@ while True:
|
|||||||
# update the progress bar
|
# update the progress bar
|
||||||
f = open(filename, 'wb')
|
f = open(filename, 'wb')
|
||||||
f.write(bytes_read)
|
f.write(bytes_read)
|
||||||
# update the progress bar
|
|
||||||
progress.update(len(bytes_read))
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
g = open(filename, 'r')
|
g = open(filename, 'r')
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import socket
|
import socket
|
||||||
import os
|
import os
|
||||||
import tqdm
|
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
from pynput import keyboard
|
from pynput import keyboard
|
||||||
|
|
||||||
@ -46,9 +45,8 @@ s.send(f"{filename}{SEPARATOR}{filesize}".encode())
|
|||||||
|
|
||||||
def sendfile():
|
def sendfile():
|
||||||
# start sending the file
|
# start sending the file
|
||||||
progress = tqdm.tqdm(range(filesize), f"Sending {filename}", unit="B", unit_scale=True, unit_divisor=1024)
|
|
||||||
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:
|
||||||
@ -57,8 +55,6 @@ def sendfile():
|
|||||||
# we use sendall to assure transimission in
|
# we use sendall to assure transimission in
|
||||||
# busy networks
|
# busy networks
|
||||||
s.sendall(bytes_read)
|
s.sendall(bytes_read)
|
||||||
# update the progress bar
|
|
||||||
progress.update(len(bytes_read))
|
|
||||||
# close the socket
|
# close the socket
|
||||||
#s.close()
|
#s.close()
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import socket
|
import socket
|
||||||
import os
|
import os
|
||||||
import tqdm
|
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
from pynput import keyboard
|
from pynput import keyboard
|
||||||
|
|
||||||
@ -45,9 +44,8 @@ s.send(f"{filename}{SEPARATOR}{filesize}".encode())
|
|||||||
|
|
||||||
def sendfile():
|
def sendfile():
|
||||||
# start sending the file
|
# start sending the file
|
||||||
progress = tqdm.tqdm(range(filesize), f"Sending {filename}", unit="B", unit_scale=True, unit_divisor=1024)
|
|
||||||
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:
|
||||||
@ -56,8 +54,6 @@ def sendfile():
|
|||||||
# we use sendall to assure transimission in
|
# we use sendall to assure transimission in
|
||||||
# busy networks
|
# busy networks
|
||||||
s.sendall(bytes_read)
|
s.sendall(bytes_read)
|
||||||
# update the progress bar
|
|
||||||
progress.update(len(bytes_read))
|
|
||||||
# close the socket
|
# close the socket
|
||||||
#s.close()
|
#s.close()
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import socket
|
import socket
|
||||||
import os
|
import os
|
||||||
import tqdm
|
|
||||||
from pynput import keyboard
|
from pynput import keyboard
|
||||||
from pynput.mouse import Button, Controller
|
from pynput.mouse import Button, Controller
|
||||||
from pynput import mouse
|
from pynput import mouse
|
||||||
@ -33,9 +32,8 @@ s.send(f"{filename}{SEPARATOR}{filesize}".encode())
|
|||||||
|
|
||||||
def sendfile():
|
def sendfile():
|
||||||
# start sending the file
|
# start sending the file
|
||||||
progress = tqdm.tqdm(range(filesize), f"Sending {filename}", unit="B", unit_scale=True, unit_divisor=1024)
|
|
||||||
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:
|
||||||
@ -44,8 +42,6 @@ def sendfile():
|
|||||||
# we use sendall to assure transimission in
|
# we use sendall to assure transimission in
|
||||||
# busy networks
|
# busy networks
|
||||||
s.sendall(bytes_read)
|
s.sendall(bytes_read)
|
||||||
# update the progress bar
|
|
||||||
progress.update(len(bytes_read))
|
|
||||||
# close the socket
|
# close the socket
|
||||||
#s.close()
|
#s.close()
|
||||||
|
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
import socket
|
import socket
|
||||||
import os
|
import os
|
||||||
import tqdm
|
|
||||||
from pynput import keyboard
|
from pynput import keyboard
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SEPARATOR = "<SEPARATOR>"
|
SEPARATOR = "<SEPARATOR>"
|
||||||
BUFFER_SIZE = 4096 # send 4096 bytes each time step
|
BUFFER_SIZE = 128 # send 4096 bytes each time step
|
||||||
|
|
||||||
|
|
||||||
# the ip address or hostname of the server, the receiver
|
# the ip address or hostname of the server, the receiver
|
||||||
host = "10.4.27.243"
|
host = "127.0.0.1"
|
||||||
# the port, let's use 5001
|
# the port, let's use 5001
|
||||||
port = 5001
|
port = 5001
|
||||||
# the name of file we want to send, make sure it exists
|
# the name of file we want to send, make sure it exists
|
||||||
@ -30,9 +29,8 @@ s.send(f"{filename}{SEPARATOR}{filesize}".encode())
|
|||||||
|
|
||||||
def sendfile():
|
def sendfile():
|
||||||
# start sending the file
|
# start sending the file
|
||||||
progress = tqdm.tqdm(range(filesize), f"Sending {filename}", unit="B", unit_scale=True, unit_divisor=1024)
|
|
||||||
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:
|
||||||
@ -41,8 +39,6 @@ def sendfile():
|
|||||||
# we use sendall to assure transimission in
|
# we use sendall to assure transimission in
|
||||||
# busy networks
|
# busy networks
|
||||||
s.sendall(bytes_read)
|
s.sendall(bytes_read)
|
||||||
# update the progress bar
|
|
||||||
progress.update(len(bytes_read))
|
|
||||||
# close the socket
|
# close the socket
|
||||||
#s.close()
|
#s.close()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user