finish and reorganise

This commit is contained in:
Daniel 2021-03-23 10:05:04 +00:00
parent ba47435068
commit 8338243950
10 changed files with 51 additions and 4 deletions

Binary file not shown.

BIN
Controlled/screen.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

View File

@ -1,5 +1,6 @@
import socket
import os
#from test import update_image
# device's IP address
SERVER_HOST = "0.0.0.0" #(socket.gethostbyname(socket.gethostname()))
@ -26,7 +27,7 @@ print(f"[+] {address} is connected.")
received = client_socket.recv(BUFFER_SIZE).decode()
filename, filesize = received.split(SEPARATOR)
# remove absolute path if there is
filename = os.path.basename(filename)
#filename = os.path.basename(filename)
# convert to integer
filesize = int(filesize)
# start receiving the file from the socket
@ -44,10 +45,12 @@ while True:
# write to the file the bytes we just received
try:
hello = bytes_read.decode()
os.remove(filename)
print("I am deleting the file")
#update_image()
os.remove("screen.jpg")
os.rename(r"screen_download.jpg",r"screen.jpg")
print("I am moving the file")
except:
f = open(filename, 'ab')
f = open("screen_download.jpg", 'ab')
f.write(bytes_read)
print("I am adding to the file")
f.close()

View File

@ -0,0 +1,44 @@
#!/usr/bin/python3
#Displays a loop of all image files found by gather_files.py. Run that script first to populate your image db file. See README for python dependency installation hints.
import tkinter as tk
from PIL import ImageTk, Image
import os, random, time
#Loop through a new image every 4 seconds.
def update_image():
path = "screen.jpg"
try:
img = ImageTk.PhotoImage(Image.open(path).resize((800, 480)))
#Issue with image file, try another.
except Exception as e:
print("Error: " + str(e))
path = get_random_file()
img = ImageTk.PhotoImage(Image.open(path).resize((800, 480)))
panel.configure(image=img)
panel.image = img
window.after(100, update_image)
return
path = "screen.jpg"
window = tk.Tk()
#window.attributes("-fullscreen",True)
window.title("Photo Gallery")
window.geometry("800x480")
window.configure(background='black')
#Load an initial image onto the Label.
try:
img = ImageTk.PhotoImage(Image.open(path).resize((800, 480)))
#Issue with image file, try another.
except Exception as e:
print("Error: " + str(e))
path = "screen.jpg"
img = ImageTk.PhotoImage(Image.open(path).resize((800, 480)))
panel = tk.Label(window, image=img)
panel.pack(side="bottom", fill="both", expand="yes")
update_image()
window.mainloop()

View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB