diff --git a/client_details.py b/client_details.py index 353499b..b28e504 100644 --- a/client_details.py +++ b/client_details.py @@ -49,17 +49,17 @@ def create_details_page(app, software, 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 = 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) + #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) + #elements.append(progress_bar) + #elements.append(progress_text) # thumbnail image # 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 install_button = customtkinter.CTkButton(button_frame, text=install_text, - command=lambda: software.install()) + command=lambda: software.install_async()) # add remove button # remove_button = customtkinter.CTkButton(button_frame, text=remove_text, diff --git a/data_backend.py b/data_backend.py index 216b5fc..2f7d461 100644 --- a/data_backend.py +++ b/data_backend.py @@ -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 # # as there cannot be a meaningful UI-draw without it. # r = requests.get(self._get_url(), params={ "path" : path, "as_string": True }) - print("Request Content:", r.text) + # cache the download imediatelly # with open(local_file, encoding="utf-8", mode="w") as f: - f.write( r.text) + f.write(r.text) - # return the content # - print("Content for", fullpath, ":", r.text) - - if return_content: + if return_content: + print("Content for", fullpath, ":", r.text) return r.text else: return local_file diff --git a/localaction.py b/localaction.py index 8cf013d..ed51e5c 100644 --- a/localaction.py +++ b/localaction.py @@ -17,7 +17,7 @@ def unpack_software(software_cache_path, target_path): '''Unpack a downloaded software to the target location''' pass -def install_registry_file(registry_file, game_path=None): +def install_registry_file(registry_file): '''Install a given registy file''' # test path: @@ -27,13 +27,6 @@ def install_registry_file(registry_file, game_path=None): p = subprocess.Popen(["wine64", "start", "regedit", registry_file], subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) 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()) @@ -59,7 +52,7 @@ def run_exe(path, synchronous=False): paths = path # 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") if os.name != "nt": @@ -85,7 +78,10 @@ def run_exe(path, synchronous=False): p = subprocess.Popen(["powershell", "-ExecutionPolicy", "Bypass", "-File", "windows_run_as_admin.ps1", json.dumps(paths)], 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: raise e diff --git a/regedit.py b/regedit.py deleted file mode 100644 index aa1e560..0000000 --- a/regedit.py +++ /dev/null @@ -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) \ No newline at end of file diff --git a/software.py b/software.py index d741712..1dbc119 100644 --- a/software.py +++ b/software.py @@ -8,6 +8,8 @@ import pathlib import tqdm import webbrowser import jinja_helper +import threading +import sys class Software: @@ -30,10 +32,10 @@ class Software: raise e self.invalid = True - if not progress_bar_wrapper: - raise AssertionError() + # if not progress_bar_wrapper: + # raise AssertionError() - self.progress_bar_wrapper = progress_bar_wrapper + # self.progress_bar_wrapper = progress_bar_wrapper def _load_from_yaml(self): @@ -90,17 +92,21 @@ class Software: try: zip_ref.extract(member, software_path) 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)) + #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() + #self.progress_bar_wrapper.set_text(text="Loading..") + #self.progress_bar_wrapper.update() + def install_async(self): + + thread = threading.Thread(target=self.install) + thread.start() def install(self): '''Install this software from the backend''' @@ -115,8 +121,8 @@ 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() + #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: @@ -124,7 +130,7 @@ class Software: except IndexError: print("No main_dir:", path) 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 # if local_file.endswith(".exe"): @@ -143,8 +149,10 @@ class Software: print("Install dir Registry:", target_install_dir) path = jinja_helper.render_path(path, target_install_dir, self.directory) - admin_run_list.append(path) - # localaction.install_registry_file(path) + if sys.platform == "win32": + admin_run_list.append(path) + else: + localaction.install_registry_file(path) # install dependencies # if self.dependencies: @@ -179,7 +187,7 @@ class Software: os.makedirs(dest_dir, exist_ok=True) shutil.copy(tmp, dest_dir) - self.progress_bar_wrapper.set_text(text="") + #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")