mirror of
https://github.com/FAUSheppy/homelab_gamevault
synced 2025-12-10 00:28:32 +01:00
Compare commits
16 Commits
linux-supp
...
0d35e9c095
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d35e9c095 | |||
| 1f3b489094 | |||
| 6f4f658393 | |||
| 1cd0516e64 | |||
| ff26fe9bb1 | |||
| 6c6cafe1db | |||
| b515d32d06 | |||
| f3342ac5aa | |||
| 0f573cba74 | |||
| e4c4f17d09 | |||
| 05d2833344 | |||
| 8c2057d8ac | |||
| e1ec605183 | |||
| 2eddfb2d45 | |||
| cc5d9685fa | |||
|
|
a36c737668 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -6,7 +6,11 @@ cache/
|
||||
install/
|
||||
*.json
|
||||
install-dir/
|
||||
|
||||
*.spec
|
||||
*.exe
|
||||
dist/
|
||||
%APPDATA%/
|
||||
example_software_root/
|
||||
|
||||
# windows dir on linux ä
|
||||
**\\install-dir/
|
||||
|
||||
20
README.md
20
README.md
@@ -1,8 +1,18 @@
|
||||
# Example Game
|
||||
You can download the GNU GPL Licensed game "FreeDink" from [here](https://nextcloud.atlantishq.de/s/9T62K9WjpEt3AQ7) and put it into `example_software_root/FreeDink/main_dir" to test it out.
|
||||
|
||||
# TODO
|
||||
- check local cache before loading from remote
|
||||
- better image resizing, prevent stretching etc.
|
||||
- async load from remote, currently the who GUI blocks during the loading process
|
||||
- unpacking progress
|
||||
# Linux
|
||||
|
||||
sudo mkdir -pm755 /etc/apt/keyrings
|
||||
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
|
||||
chmod a+r /etc/apt/keyrings/*
|
||||
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/debian/dists/bullseye/winehq-bullseye.sources\n
|
||||
sudo apt update
|
||||
sudo dpkg --add-architecture i386 \n
|
||||
sudo apt install --install-recommends winehq-staging
|
||||
sudo apt install libgl1:i386 nvidia-driver-libs:i386
|
||||
sudo apt install python3 python3-pip python3-tk
|
||||
|
||||
# non sudo in project #
|
||||
python -m pip install -r requirements.txt
|
||||
python client.py
|
||||
|
||||
37
client.py
37
client.py
@@ -8,6 +8,7 @@ import json
|
||||
import os
|
||||
import cache_utils
|
||||
import imagetools
|
||||
import webbrowser
|
||||
|
||||
customtkinter.set_appearance_mode("dark")
|
||||
customtkinter.set_default_color_theme("blue")
|
||||
@@ -17,6 +18,8 @@ app = customtkinter.CTk()
|
||||
app.geometry("1490x700")
|
||||
last_geometry = app.winfo_geometry()
|
||||
|
||||
scrollable_frame = customtkinter.CTkScrollableFrame(app, width=app.winfo_width(), height=app.winfo_height())
|
||||
|
||||
buttons = []
|
||||
details_elements = []
|
||||
|
||||
@@ -73,7 +76,7 @@ def dropdown_changed(dropdown_var, user_entry, password_entry, server_path_entry
|
||||
password_entry.configure(fg_color=non_disabled_entry_color)
|
||||
user_entry.configure(fg_color=non_disabled_entry_color)
|
||||
server_path_entry.delete(0, customtkinter.END)
|
||||
server_path_entry.insert(0, "ftp://server/path::port or ftps://server/path:port")
|
||||
server_path_entry.insert(0, "ftp://server:port/path or ftps://server:port/path")
|
||||
|
||||
install_dir_entry.delete(0, customtkinter.END)
|
||||
install_dir_entry.insert(0, "./install-dir")
|
||||
@@ -124,13 +127,14 @@ def get_config_inputs():
|
||||
dropdown_changed(dropdown_var, user_entry, password_entry, server_path_entry, install_dir_entry)
|
||||
dropdown.grid(row=0, column=1, padx=10, pady=5)
|
||||
|
||||
# Button to abort & close #
|
||||
abort_button = customtkinter.CTkButton(input_window, text="Abort", command=lambda: input_window.quit(), fg_color="red")
|
||||
abort_button.grid(row=5, column=0, padx=10, pady=20)
|
||||
|
||||
# Button to save & close #
|
||||
save_button = customtkinter.CTkButton(input_window, text="Save & Close", command=lambda: close_input_window(input_window))
|
||||
save_button.grid(row=5, column=0, padx=10, pady=20)
|
||||
save_button.grid(row=5, column=2, padx=10, pady=20)
|
||||
|
||||
# Button to abort & close #
|
||||
abort_button = customtkinter.CTkButton(input_window, text="Abort", command=lambda: input_window.quit())
|
||||
abort_button.grid(row=5, column=2, padx=10, pady=20)
|
||||
|
||||
input_window.update()
|
||||
input_window.mainloop()
|
||||
@@ -167,16 +171,29 @@ def load_main():
|
||||
|
||||
app.title("Lan Vault: Overview")
|
||||
|
||||
# navbar should not expand when window is resized
|
||||
app.grid_rowconfigure(0, weight=0)
|
||||
# buttongrid (scrollable frame) should expand when window is resized
|
||||
app.grid_rowconfigure(1, weight=1)
|
||||
app.grid_columnconfigure(0, weight=1)
|
||||
# place scrollable frame
|
||||
scrollable_frame.grid(row=1, column=0, sticky="nsew", columnspan=2)
|
||||
|
||||
|
||||
# create tiles from meta files #
|
||||
cache_dir_size = 0
|
||||
for software in db.find_all_metadata():
|
||||
create_main_window_tile(software)
|
||||
create_main_window_tile(software, scrollable_frame)
|
||||
|
||||
# retrieve cache dir from any software #
|
||||
if not cache_dir_size:
|
||||
cache_dir_size = cache_utils.get_cache_size()
|
||||
label = customtkinter.CTkLabel(app, text="Cache Size: {:.2f} GB".format(cache_dir_size))
|
||||
GITHUB_URL = "https://github.com/FAUSheppy/homelab_gamevault"
|
||||
github = customtkinter.CTkButton(app, text="Star on Github",
|
||||
command=lambda: webbrowser.open_new(GITHUB_URL))
|
||||
label.grid(row=0, column=0)
|
||||
github.grid(row=0, column=1)
|
||||
|
||||
# set update listener & update positions #
|
||||
update_button_positions()
|
||||
@@ -186,7 +203,7 @@ def destroy_main():
|
||||
'''Destroy all elements in the main view'''
|
||||
|
||||
global buttons
|
||||
|
||||
scrollable_frame.grid_remove()
|
||||
app.unbind("<Configure>")
|
||||
for b in buttons:
|
||||
b.destroy()
|
||||
@@ -202,7 +219,7 @@ def load_details(app, software):
|
||||
app.title("Lan Vault: {}".format(software.title))
|
||||
details_elements = client_details.create_details_page(app, software, switch_to_main)
|
||||
|
||||
def create_main_window_tile(software):
|
||||
def create_main_window_tile(software, parent):
|
||||
'''Create the main window tile'''
|
||||
|
||||
if software.get_thumbnail():
|
||||
@@ -217,7 +234,7 @@ def create_main_window_tile(software):
|
||||
img = PIL.Image.new('RGB', (200, 300))
|
||||
|
||||
img = PIL.ImageTk.PhotoImage(img)
|
||||
button = customtkinter.CTkButton(app, image=img,
|
||||
button = customtkinter.CTkButton(parent, image=img,
|
||||
width=200, height=300,
|
||||
command=lambda: switch_to_game_details(software),
|
||||
border_width=0, corner_radius=0, border_spacing=0,
|
||||
@@ -230,13 +247,13 @@ def update_button_positions(event=None):
|
||||
'''Sets the tile positions initially and on resize'''
|
||||
|
||||
global last_geometry
|
||||
|
||||
# check vs old location #
|
||||
new_geometry = app.winfo_geometry()
|
||||
if last_geometry[0] == new_geometry[0] and last_geometry[1] == new_geometry[1]:
|
||||
return
|
||||
else:
|
||||
last_geometry = new_geometry
|
||||
scrollable_frame.configure(width=app.winfo_width(), height=app.winfo_height())
|
||||
|
||||
# Calculate the number of columns based on the current width of the window #
|
||||
num_columns = app.winfo_width() // 201 # Adjust 100 as needed for button width
|
||||
|
||||
@@ -2,7 +2,7 @@ import PIL
|
||||
import tkinter
|
||||
import customtkinter
|
||||
import imagetools
|
||||
|
||||
import os
|
||||
|
||||
def show_large_picture(app, path):
|
||||
'''Show a full-window version of the clicked picture'''
|
||||
@@ -38,17 +38,26 @@ def create_details_page(app, software, backswitch_function):
|
||||
|
||||
img = PIL.ImageTk.PhotoImage(img)
|
||||
|
||||
# navbar & progress bar #
|
||||
# navbar #
|
||||
navbar = customtkinter.CTkFrame(app, fg_color="transparent")
|
||||
navbar.grid(column=0, row=0, padx=10, pady=5, sticky="ew")
|
||||
back_button = customtkinter.CTkButton(navbar, text="Back",
|
||||
command=backswitch_function)
|
||||
|
||||
# back button
|
||||
back_button = customtkinter.CTkButton(navbar, text="Back", command=backswitch_function)
|
||||
back_button.pack(anchor="nw", side="left")
|
||||
|
||||
# progress bar #
|
||||
progress_bar = software.progress_bar_wrapper.new(navbar)
|
||||
progress_bar.pack(anchor="nw", side="left", padx=20, pady=5)
|
||||
|
||||
# progress bar text #
|
||||
progress_text = software.progress_bar_wrapper.new_text(navbar)
|
||||
progress_text.pack(anchor="nw", side="left", padx=20, pady=5)
|
||||
|
||||
elements.append(navbar)
|
||||
elements.append(back_button)
|
||||
elements.append(progress_bar)
|
||||
elements.append(progress_text)
|
||||
|
||||
# thumbnail image #
|
||||
thumbnail_image = customtkinter.CTkButton(app, text="", image=img, width=500, height=700,
|
||||
@@ -118,7 +127,7 @@ def create_details_page(app, software, backswitch_function):
|
||||
remove_text = "Remove Manually"
|
||||
else:
|
||||
install_text = "Install"
|
||||
remove_text = "Remove"
|
||||
remove_text = "Remove (not implemented)" # FIXME: change text once implemented
|
||||
|
||||
install_button = customtkinter.CTkButton(button_frame, text=install_text,
|
||||
command=lambda: software.install())
|
||||
@@ -131,6 +140,9 @@ def create_details_page(app, software, backswitch_function):
|
||||
remove_button.configure(state=tkinter.DISABLED)
|
||||
remove_button.configure(fg_color="gray")
|
||||
|
||||
# FIXME: disable remove button until implemented
|
||||
remove_button.configure(state=tkinter.DISABLED)
|
||||
|
||||
remove_button.pack(padx=10, pady=15, anchor="sw", side="left")
|
||||
|
||||
|
||||
@@ -138,9 +150,13 @@ def create_details_page(app, software, backswitch_function):
|
||||
run_button = customtkinter.CTkButton(button_frame, text="Run",
|
||||
command=lambda: software.run())
|
||||
run_button.pack(padx=10, pady=15, anchor="sw", side="left")
|
||||
software.run_button = run_button
|
||||
|
||||
# install button #
|
||||
if not software.run_exe:
|
||||
print(software.run_exe)
|
||||
print(os.path.join(software.backend.install_dir, software.run_exe))
|
||||
if not software.run_exe or not (os.path.isfile(software.run_exe)
|
||||
or os.path.isfile(os.path.join(software.backend.install_dir, software.title, software.run_exe))):
|
||||
run_button.configure(state=tkinter.DISABLED)
|
||||
run_button.configure(fg_color="gray")
|
||||
|
||||
|
||||
@@ -184,13 +184,15 @@ class FTP(DataBackend):
|
||||
# print("Cachedir:", cache_dir, os.path.basename(path), local_file)
|
||||
|
||||
if not os.path.isfile(local_file):
|
||||
|
||||
ftp = self._connect(individual_connection=True)
|
||||
ftp.sendcmd('TYPE I')
|
||||
|
||||
# load the file on remote #
|
||||
if not new_connection:
|
||||
|
||||
total_size = ftp.size(fullpath)
|
||||
print(total_size)
|
||||
print("Total Size:", total_size)
|
||||
self.progress_bar_wrapper.get_pb()["maximum"] = total_size
|
||||
|
||||
print(local_file, "not in cache, retriving..")
|
||||
@@ -209,8 +211,10 @@ class FTP(DataBackend):
|
||||
if new_connection: # return if parralell
|
||||
return
|
||||
self.root.update_idletasks() # Update the GUI
|
||||
self.progress_bar_wrapper.get_pb().set(
|
||||
self.progress_bar_wrapper.get_pb().get() + len(data)/total_size)
|
||||
current_total = self.progress_bar_wrapper.get_pb().get() + len(data)/total_size
|
||||
self.progress_bar_wrapper.get_pb().set(current_total)
|
||||
self.progress_bar_wrapper.set_text(
|
||||
text="Downloading: {:.2f}%".format(current_total*100))
|
||||
cmd_progress_bar.update(len(data))
|
||||
|
||||
# run with callback #
|
||||
|
||||
26
pgwrapper.py
26
pgwrapper.py
@@ -6,16 +6,42 @@ class ProgressBarWrapper:
|
||||
in the DataBackend and Software Objects'''
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.progress_bar = None
|
||||
self.progress_text = None
|
||||
self.tk_parent = None
|
||||
|
||||
def update(self):
|
||||
|
||||
if self.tk_parent:
|
||||
self.tk_parent.update_idletasks()
|
||||
|
||||
def new(self, tk_parent):
|
||||
|
||||
self.tk_parent = tk_parent
|
||||
self.progress_bar = customtkinter.CTkProgressBar(tk_parent, height=20, width=200)
|
||||
self.progress_bar["maximum"] = 10000
|
||||
self.progress_bar.set(0)
|
||||
|
||||
return self.progress_bar
|
||||
|
||||
def new_text(self, tk_parent):
|
||||
|
||||
self.tk_parent = tk_parent
|
||||
self.progress_text = customtkinter.CTkLabel(tk_parent, height=20, width=130, text="")
|
||||
return self.progress_text
|
||||
|
||||
def get_pb(self):
|
||||
|
||||
if self.progress_bar:
|
||||
return self.progress_bar
|
||||
else:
|
||||
raise AssertionError("No progress bar in this wrapper created")
|
||||
|
||||
def set_text(self, text):
|
||||
|
||||
if self.progress_text:
|
||||
self.progress_text.configure(text=text)
|
||||
else:
|
||||
pass
|
||||
#FIXME raise AssertionError("No progress text in this wrapper created")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
pyuac
|
||||
Pillow
|
||||
Pillow>=10.0.3
|
||||
customtkinter
|
||||
tqdm
|
||||
Jinja2
|
||||
|
||||
30
software.py
30
software.py
@@ -1,4 +1,5 @@
|
||||
import yaml
|
||||
import tkinter
|
||||
import os
|
||||
import localaction
|
||||
import zipfile
|
||||
@@ -15,6 +16,7 @@ class Software:
|
||||
self.meta_file = meta_file
|
||||
self.directory = os.path.dirname(meta_file)
|
||||
self.backend = backend
|
||||
self.run_button = None
|
||||
print("Software Directory:", self.directory)
|
||||
|
||||
self.cache_dir = backend.cache_dir or os.path.join("cache", self.directory.lstrip("/").lstrip("\\"))
|
||||
@@ -48,7 +50,7 @@ class Software:
|
||||
|
||||
self.pictures = [ self.backend.get(pp, self.cache_dir, new_connection=True) for pp in
|
||||
self.backend.list(os.path.join(self.directory, "pictures"), fullpaths=True, new_connection=True) ]
|
||||
|
||||
|
||||
self.reg_files = self.backend.list(os.path.join(self.directory, "registry_files"), fullpaths=True, new_connection=True)
|
||||
|
||||
|
||||
@@ -59,7 +61,7 @@ class Software:
|
||||
return None
|
||||
|
||||
return self.pictures[0]
|
||||
|
||||
|
||||
def _extract_to_target(self, cache_src, target):
|
||||
'''Extract a cached, downloaded zip to the target location'''
|
||||
|
||||
@@ -69,7 +71,7 @@ class Software:
|
||||
os.makedirs(software_path, exist_ok=True)
|
||||
|
||||
with zipfile.ZipFile(cache_src, 'r') as zip_ref:
|
||||
|
||||
|
||||
total_count = zip_ref.infolist()
|
||||
count = 0
|
||||
for member in tqdm.tqdm(total_count, desc='Extracting '):
|
||||
@@ -78,10 +80,16 @@ class Software:
|
||||
count += 1
|
||||
self.progress_bar_wrapper.get_pb().set(count/len(total_count))
|
||||
self.progress_bar_wrapper.get_pb().update_idletasks()
|
||||
self.progress_bar_wrapper.set_text(
|
||||
text="Extracting: {:.2f}%".format(count/len(total_count)*100))
|
||||
except zipfile.error as e:
|
||||
pass # TODO ???
|
||||
#zip_ref.extractall(software_path)
|
||||
|
||||
self.progress_bar_wrapper.set_text(text="Loading..")
|
||||
self.progress_bar_wrapper.update()
|
||||
|
||||
|
||||
def install(self):
|
||||
'''Install this software from the backend'''
|
||||
|
||||
@@ -92,8 +100,10 @@ class Software:
|
||||
webbrowser.open(self.link_only)
|
||||
return
|
||||
|
||||
self.progress_bar_wrapper.set_text(text="Please wait..")
|
||||
self.progress_bar_wrapper.tk_parent.update_idletasks()
|
||||
path = os.path.join(self.directory, "main_dir")
|
||||
|
||||
|
||||
try:
|
||||
remote_file = self.backend.list(path, fullpaths=True)[0]
|
||||
except IndexError:
|
||||
@@ -109,7 +119,7 @@ class Software:
|
||||
localaction.run_exe(local_file)
|
||||
elif local_file.endswith(".zip"):
|
||||
self._extract_to_target(local_file, self.backend.install_dir)
|
||||
|
||||
|
||||
# download & install registry files #
|
||||
for rf in self.reg_files:
|
||||
path = self.backend.get(rf, cache_dir=self.cache_dir)
|
||||
@@ -145,7 +155,13 @@ class Software:
|
||||
dest_dir = os.path.expandvars(dest)
|
||||
os.makedirs(dest_dir, exist_ok=True)
|
||||
shutil.copy(tmp, dest_dir)
|
||||
|
||||
|
||||
self.progress_bar_wrapper.set_text(text="")
|
||||
if self.run_button:
|
||||
self.run_button.configure(state=tkinter.NORMAL)
|
||||
self.run_button.configure(fg_color="green")
|
||||
|
||||
|
||||
def run(self):
|
||||
'''Run the configured exe for this software'''
|
||||
|
||||
@@ -157,6 +173,6 @@ class Software:
|
||||
|
||||
if self.run_exe:
|
||||
if os.name == "nt" or not ".lnk" in self.run_exe:
|
||||
localaction.run_exe(os.path.join(self.backend.install_dir, self.title, self.run_exe))
|
||||
localaction.run_exe(os.path.join(self.backend.install_dir, self.title, self.run_exe))
|
||||
else:
|
||||
localaction.run_exe(self.run_exe)
|
||||
|
||||
Reference in New Issue
Block a user