mirror of
https://github.com/FAUSheppy/homelab_gamevault
synced 2025-12-06 06:51:36 +01:00
fix: remove pg bar and various output problems
This commit is contained in:
@@ -49,17 +49,17 @@ def create_details_page(app, software, backswitch_function):
|
|||||||
back_button.pack(anchor="nw", side="left")
|
back_button.pack(anchor="nw", side="left")
|
||||||
|
|
||||||
# progress bar #
|
# progress bar #
|
||||||
progress_bar = software.progress_bar_wrapper.new(navbar)
|
#progress_bar = software.progress_bar_wrapper.new(navbar)
|
||||||
progress_bar.pack(anchor="nw", side="left", padx=20, pady=5)
|
#progress_bar.pack(anchor="nw", side="left", padx=20, pady=5)
|
||||||
|
|
||||||
# progress bar text #
|
# progress bar text #
|
||||||
progress_text = software.progress_bar_wrapper.new_text(navbar)
|
#progress_text = software.progress_bar_wrapper.new_text(navbar)
|
||||||
progress_text.pack(anchor="nw", side="left", padx=20, pady=5)
|
#progress_text.pack(anchor="nw", side="left", padx=20, pady=5)
|
||||||
|
|
||||||
elements.append(navbar)
|
elements.append(navbar)
|
||||||
elements.append(back_button)
|
elements.append(back_button)
|
||||||
elements.append(progress_bar)
|
#elements.append(progress_bar)
|
||||||
elements.append(progress_text)
|
#elements.append(progress_text)
|
||||||
|
|
||||||
# thumbnail image #
|
# thumbnail image #
|
||||||
thumbnail_image = customtkinter.CTkButton(app, text="", image=img, width=500, height=700,
|
thumbnail_image = customtkinter.CTkButton(app, text="", image=img, width=500, height=700,
|
||||||
@@ -132,7 +132,7 @@ def create_details_page(app, software, backswitch_function):
|
|||||||
remove_text = "Remove (not implemented)" # FIXME: change text once implemented
|
remove_text = "Remove (not implemented)" # FIXME: change text once implemented
|
||||||
|
|
||||||
install_button = customtkinter.CTkButton(button_frame, text=install_text,
|
install_button = customtkinter.CTkButton(button_frame, text=install_text,
|
||||||
command=lambda: software.install())
|
command=lambda: software.install_async())
|
||||||
|
|
||||||
# add remove button #
|
# add remove button #
|
||||||
remove_button = customtkinter.CTkButton(button_frame, text=remove_text,
|
remove_button = customtkinter.CTkButton(button_frame, text=remove_text,
|
||||||
|
|||||||
@@ -138,15 +138,13 @@ class HTTP(DataBackend):
|
|||||||
# the content is needed for the UI now and not cached, it's needs to be downloaded synchroniously #
|
# the content is needed for the UI now and not cached, it's needs to be downloaded synchroniously #
|
||||||
# as there cannot be a meaningful UI-draw without it. #
|
# as there cannot be a meaningful UI-draw without it. #
|
||||||
r = requests.get(self._get_url(), params={ "path" : path, "as_string": True })
|
r = requests.get(self._get_url(), params={ "path" : path, "as_string": True })
|
||||||
print("Request Content:", r.text)
|
|
||||||
# cache the download imediatelly #
|
# cache the download imediatelly #
|
||||||
with open(local_file, encoding="utf-8", mode="w") as f:
|
with open(local_file, encoding="utf-8", mode="w") as f:
|
||||||
f.write( r.text)
|
f.write(r.text)
|
||||||
|
|
||||||
# return the content #
|
if return_content:
|
||||||
print("Content for", fullpath, ":", r.text)
|
print("Content for", fullpath, ":", r.text)
|
||||||
|
|
||||||
if return_content:
|
|
||||||
return r.text
|
return r.text
|
||||||
else:
|
else:
|
||||||
return local_file
|
return local_file
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ def unpack_software(software_cache_path, target_path):
|
|||||||
'''Unpack a downloaded software to the target location'''
|
'''Unpack a downloaded software to the target location'''
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def install_registry_file(registry_file, game_path=None):
|
def install_registry_file(registry_file):
|
||||||
'''Install a given registy file'''
|
'''Install a given registy file'''
|
||||||
|
|
||||||
# test path:
|
# test path:
|
||||||
@@ -27,13 +27,6 @@ def install_registry_file(registry_file, game_path=None):
|
|||||||
p = subprocess.Popen(["wine64", "start", "regedit", registry_file],
|
p = subprocess.Popen(["wine64", "start", "regedit", registry_file],
|
||||||
subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||||
print("Running regedit for wine..")
|
print("Running regedit for wine..")
|
||||||
else:
|
|
||||||
# windows sucky sucky #
|
|
||||||
if not os.path.isabs(registry_file):
|
|
||||||
registry_file = os.path.join(os.getcwd(), registry_file)
|
|
||||||
|
|
||||||
p = subprocess.Popen(["python", "regedit.py", registry_file],
|
|
||||||
subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
|
||||||
|
|
||||||
print(p.communicate())
|
print(p.communicate())
|
||||||
|
|
||||||
@@ -59,7 +52,7 @@ def run_exe(path, synchronous=False):
|
|||||||
paths = path
|
paths = path
|
||||||
|
|
||||||
# sanity check path is list #
|
# sanity check path is list #
|
||||||
if not type(path) == list:
|
if not type(paths) == list:
|
||||||
raise AssertionError("ERROR: run_exe could not build a list of paths")
|
raise AssertionError("ERROR: run_exe could not build a list of paths")
|
||||||
|
|
||||||
if os.name != "nt":
|
if os.name != "nt":
|
||||||
@@ -85,7 +78,10 @@ def run_exe(path, synchronous=False):
|
|||||||
p = subprocess.Popen(["powershell", "-ExecutionPolicy", "Bypass", "-File",
|
p = subprocess.Popen(["powershell", "-ExecutionPolicy", "Bypass", "-File",
|
||||||
"windows_run_as_admin.ps1", json.dumps(paths)],
|
"windows_run_as_admin.ps1", json.dumps(paths)],
|
||||||
subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||||
print(p.communicate())
|
try:
|
||||||
|
print(p.communicate())
|
||||||
|
except UnicodeDecodeError as e:
|
||||||
|
print("WARNING: cannot show you ERROR from exe because output contained illegal characters. This maybe because your refused the admin prompt.")
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|||||||
14
regedit.py
14
regedit.py
@@ -1,14 +0,0 @@
|
|||||||
from pyuac.main_decorator import main_requires_admin
|
|
||||||
import sys
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
@main_requires_admin(return_output=True)
|
|
||||||
def main(registry_file):
|
|
||||||
p = subprocess.Popen(["regedit", registry_file],
|
|
||||||
subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
|
||||||
stdout, stderr = p.communicate()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
registry_file = sys.argv[-1]
|
|
||||||
rv = main(registry_file)
|
|
||||||
print(rv)
|
|
||||||
38
software.py
38
software.py
@@ -8,6 +8,8 @@ import pathlib
|
|||||||
import tqdm
|
import tqdm
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import jinja_helper
|
import jinja_helper
|
||||||
|
import threading
|
||||||
|
import sys
|
||||||
|
|
||||||
class Software:
|
class Software:
|
||||||
|
|
||||||
@@ -30,10 +32,10 @@ class Software:
|
|||||||
raise e
|
raise e
|
||||||
self.invalid = True
|
self.invalid = True
|
||||||
|
|
||||||
if not progress_bar_wrapper:
|
# if not progress_bar_wrapper:
|
||||||
raise AssertionError()
|
# raise AssertionError()
|
||||||
|
|
||||||
self.progress_bar_wrapper = progress_bar_wrapper
|
# self.progress_bar_wrapper = progress_bar_wrapper
|
||||||
|
|
||||||
def _load_from_yaml(self):
|
def _load_from_yaml(self):
|
||||||
|
|
||||||
@@ -90,17 +92,21 @@ class Software:
|
|||||||
try:
|
try:
|
||||||
zip_ref.extract(member, software_path)
|
zip_ref.extract(member, software_path)
|
||||||
count += 1
|
count += 1
|
||||||
self.progress_bar_wrapper.get_pb().set(count/len(total_count))
|
#self.progress_bar_wrapper.get_pb().set(count/len(total_count))
|
||||||
self.progress_bar_wrapper.get_pb().update_idletasks()
|
#self.progress_bar_wrapper.get_pb().update_idletasks()
|
||||||
self.progress_bar_wrapper.set_text(
|
#self.progress_bar_wrapper.set_text(
|
||||||
text="Extracting: {:.2f}%".format(count/len(total_count)*100))
|
# text="Extracting: {:.2f}%".format(count/len(total_count)*100))
|
||||||
except zipfile.error as e:
|
except zipfile.error as e:
|
||||||
pass # TODO ???
|
pass # TODO ???
|
||||||
#zip_ref.extractall(software_path)
|
#zip_ref.extractall(software_path)
|
||||||
|
|
||||||
self.progress_bar_wrapper.set_text(text="Loading..")
|
#self.progress_bar_wrapper.set_text(text="Loading..")
|
||||||
self.progress_bar_wrapper.update()
|
#self.progress_bar_wrapper.update()
|
||||||
|
|
||||||
|
def install_async(self):
|
||||||
|
|
||||||
|
thread = threading.Thread(target=self.install)
|
||||||
|
thread.start()
|
||||||
|
|
||||||
def install(self):
|
def install(self):
|
||||||
'''Install this software from the backend'''
|
'''Install this software from the backend'''
|
||||||
@@ -115,8 +121,8 @@ class Software:
|
|||||||
webbrowser.open(self.link_only)
|
webbrowser.open(self.link_only)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.progress_bar_wrapper.set_text(text="Please wait..")
|
#self.progress_bar_wrapper.set_text(text="Please wait..")
|
||||||
self.progress_bar_wrapper.tk_parent.update_idletasks()
|
#self.progress_bar_wrapper.tk_parent.update_idletasks()
|
||||||
path = os.path.join(self.directory, "main_dir")
|
path = os.path.join(self.directory, "main_dir")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -124,7 +130,7 @@ class Software:
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
print("No main_dir:", path)
|
print("No main_dir:", path)
|
||||||
raise AssertionError("No main_dir for this software")
|
raise AssertionError("No main_dir for this software")
|
||||||
local_file = self.backend.get(remote_file, self.cache_dir)
|
local_file = self.backend.get(remote_file, self.cache_dir, wait=True)
|
||||||
|
|
||||||
# execute or unpack #
|
# execute or unpack #
|
||||||
if local_file.endswith(".exe"):
|
if local_file.endswith(".exe"):
|
||||||
@@ -143,8 +149,10 @@ class Software:
|
|||||||
print("Install dir Registry:", target_install_dir)
|
print("Install dir Registry:", target_install_dir)
|
||||||
path = jinja_helper.render_path(path, target_install_dir, self.directory)
|
path = jinja_helper.render_path(path, target_install_dir, self.directory)
|
||||||
|
|
||||||
admin_run_list.append(path)
|
if sys.platform == "win32":
|
||||||
# localaction.install_registry_file(path)
|
admin_run_list.append(path)
|
||||||
|
else:
|
||||||
|
localaction.install_registry_file(path)
|
||||||
|
|
||||||
# install dependencies #
|
# install dependencies #
|
||||||
if self.dependencies:
|
if self.dependencies:
|
||||||
@@ -179,7 +187,7 @@ class Software:
|
|||||||
os.makedirs(dest_dir, exist_ok=True)
|
os.makedirs(dest_dir, exist_ok=True)
|
||||||
shutil.copy(tmp, dest_dir)
|
shutil.copy(tmp, dest_dir)
|
||||||
|
|
||||||
self.progress_bar_wrapper.set_text(text="")
|
#self.progress_bar_wrapper.set_text(text="")
|
||||||
if self.run_button:
|
if self.run_button:
|
||||||
self.run_button.configure(state=tkinter.NORMAL)
|
self.run_button.configure(state=tkinter.NORMAL)
|
||||||
self.run_button.configure(fg_color="green")
|
self.run_button.configure(fg_color="green")
|
||||||
|
|||||||
Reference in New Issue
Block a user