From db26ed0f9858909bbf87ec9ce9a674cfd75e8841 Mon Sep 17 00:00:00 2001 From: Victorious Children Studios Date: Mon, 18 Dec 2023 21:55:11 +0200 Subject: [PATCH] Now you can remotely download shots!!! ( It is almost there ) --- network/http_client.py | 109 ++++++++++++++++++-------------- settings/languages/English.data | 4 +- settings/oscalls.py | 2 +- studio/studio_scriptLayer.py | 86 +++++++++++++++++++++++-- studio/studio_settingsLayer.py | 46 +++++++++++++- 5 files changed, 189 insertions(+), 58 deletions(-) diff --git a/network/http_client.py b/network/http_client.py index f6693f9..6c9539d 100644 --- a/network/http_client.py +++ b/network/http_client.py @@ -117,7 +117,10 @@ def download_missing_changed(win, cur): fdata = win.current["remote-folder-data"][cur][t][f] if fdata.get("to_download", True): print("Downloading", f) - down(win, website, f, fdata.get("filesize", 10000)) + try: + down(win, website, f, fdata.get("filesize", 10000)) + except Exception as e: + print(e) del win.current["remote-folder-data"][cur][t][f] except: pass @@ -196,16 +199,19 @@ def get_folder_info(win, folders, cur): nc = not_checked() while nc: - dp = go(win, website, "/blend"+nc) - - for f in dp.get("files", {}): - try: - sort_file(f, - dp.get("files", {}), - f[f.rfind("/")+1:]) - except Exception as e: - print(e) + try: + dp = go(win, website, "/blend"+nc) + for f in dp.get("files", {}): + try: + sort_file(f, + dp.get("files", {}), + f[f.rfind("/")+1:]) + except Exception as e: + print(e) + except Exception as e: + print(e) + win.current["remote-folder-data"][cur]["blend_checked"].append(nc) nc = not_checked() @@ -666,21 +672,23 @@ def prompt_layer(win, call): current_Y += 50 if win.current["remote-folder-data"][cur]["missing_active"]: - for f in win.current["remote-folder-data"][cur]["missing"]: + try: + for f in win.current["remote-folder-data"][cur]["missing"]: - fdata = win.current["remote-folder-data"][cur]["missing"][f] - - if fdata.get("finished"): - continue - - UI_color.set(layer, win, "text_normal") - layer.set_font_size(20) - layer.move_to(win.current["w"]/2-270, - current_Y + win.scroll["http-prompt"] + 135) - layer.show_text(f) + fdata = win.current["remote-folder-data"][cur]["missing"][f] - current_Y += 50 + if fdata.get("finished"): + continue + UI_color.set(layer, win, "text_normal") + layer.set_font_size(20) + layer.move_to(win.current["w"]/2-270, + current_Y + win.scroll["http-prompt"] + 135) + layer.show_text(f) + + current_Y += 50 + except: + pass # Updated files @@ -716,37 +724,40 @@ def prompt_layer(win, call): current_Y += 50 if win.current["remote-folder-data"][cur]["changed_active"]: - for f in win.current["remote-folder-data"][cur]["changed"]: - - fdata = win.current["remote-folder-data"][cur]["changed"][f] + try: + for f in win.current["remote-folder-data"][cur]["changed"]: - if fdata.get("finished"): - continue + fdata = win.current["remote-folder-data"][cur]["changed"][f] - icon = "unchecked" - if fdata["to_download"]: - icon = "checked" + if fdata.get("finished"): + continue - def do(): - fdata["to_download"] = not fdata["to_download"] - - UI_elements.roundrect(layer, win, - win.current["w"]/2-315, - 110 + current_Y + win.scroll["http-prompt"], - 660, - 40, - 10, - button=do, - icon=icon) - - - UI_color.set(layer, win, "text_normal") - layer.set_font_size(20) - layer.move_to(win.current["w"]/2-270, - current_Y + win.scroll["http-prompt"] + 135) - layer.show_text(f) + icon = "unchecked" + if fdata["to_download"]: + icon = "checked" - current_Y += 50 + def do(): + fdata["to_download"] = not fdata["to_download"] + + UI_elements.roundrect(layer, win, + win.current["w"]/2-315, + 110 + current_Y + win.scroll["http-prompt"], + 660, + 40, + 10, + button=do, + icon=icon) + + + UI_color.set(layer, win, "text_normal") + layer.set_font_size(20) + layer.move_to(win.current["w"]/2-270, + current_Y + win.scroll["http-prompt"] + 135) + layer.show_text(f) + + current_Y += 50 + except: + pass UI_elements.scroll_area(layer, win, "http-prompt", int(win.current["w"]/2-350), diff --git a/settings/languages/English.data b/settings/languages/English.data index 85fa116..dd20793 100644 --- a/settings/languages/English.data +++ b/settings/languages/English.data @@ -288,4 +288,6 @@ remote-server-url = [The hostname of the remote server.] MissingFiles = [Missing Files] ChangedFiles = [Changed Files] RemoteAssetUpdates = [Remote Asset Updates] -DownloadRemoteServer = [Download Files] \ No newline at end of file +RemoteShotUpdates = [Remote Shot Updates] +DownloadRemoteServer = [Download Files] +blender-bash = [Command To Start Blender] \ No newline at end of file diff --git a/settings/oscalls.py b/settings/oscalls.py index f81c27f..15a22af 100644 --- a/settings/oscalls.py +++ b/settings/oscalls.py @@ -215,4 +215,4 @@ def get_current_blender(win): ############################################################################ - return "blender" + return win.settings.get("blender-bash", "blender") diff --git a/studio/studio_scriptLayer.py b/studio/studio_scriptLayer.py index f45391a..ebb23ca 100644 --- a/studio/studio_scriptLayer.py +++ b/studio/studio_scriptLayer.py @@ -3,6 +3,7 @@ import os import datetime +import threading import re import json @@ -34,6 +35,30 @@ from studio import studio_dialogs from studio import schedule from studio import history +from network import http_client + +def select_shot(win): + + # For the http-server stuff + + # Remote Server Stuff + if win.analytics["from-remote-server"]: + + # Checking date [ FOLDER NAME ] [ FILES TO CHECK FOR ] + check_folders = {"/rnd"+win.cur : "*", + "/rnd"+win.cur+"/storyboard" : "*", + "/rnd"+win.cur+"/opengl" : "*", + "/rnd"+win.cur+"/test_rnd" : "*", + "/rnd"+win.cur+"/rendered" : "*", + "/rnd"+win.cur+"/extra" : "*" + } + + check_updates = threading.Thread(target=http_client.get_folder_info, + args=(win, check_folders, win.cur, )) + check_updates.setDaemon(True) + check_updates.start() + + def layer(win): @@ -1690,6 +1715,7 @@ def layer(win): # Selecting the shot if win.current["script_shot_higlight"] and win.previous["LMB"] and not win.current["LMB"]: win.cur = "/"+scene+"/"+win.current["script_shot_higlight"] + select_shot(win) win.current["shot_left_side_scroll_please_work_omg_wtf"] = True @@ -2489,6 +2515,55 @@ def layer(win): current_Y_shots = current_Y_shots + 50 + ifremote = 0 + if win.analytics["from-remote-server"]: + ifremote = 50 + + + if "remote-folder-data" not in win.current: + win.current["remote-folder-data"] = {} + + if win.cur not in win.current["remote-folder-data"]: + win.current["remote-folder-data"][win.cur] = {"missing":{}, + "changed":{}} + + + def do(): + def after(win, var): + UI_elements.reload_images(win) + win.current["remote-folder-data"]["prompt"] = win.cur + studio_dialogs.http_client_update_prompt(win, "http-client-prompt", after) + + UI_elements.roundrect(layer, win, + 10, + y+win.scroll["script_shots"]+current_Y_shots-10, + 40, + 40, + 10, + button=do, + icon="multiuser", + tip=talk.text("RemoteShotUpdates")) + + + if win.current["remote-folder-data"][win.cur]["missing"] or win.current["remote-folder-data"][win.cur]["changed"]: + count = str(len(win.current["remote-folder-data"][win.cur]["missing"])+len(win.current["remote-folder-data"][win.cur]["changed"])) + UI_color.set(layer, win, "progress_active") + UI_elements.roundrect(layer, win, + 10+25, + y+win.scroll["script_shots"]+current_Y_shots-10, + len(count)*12+6, + 25, + 5) + layer.fill() + UI_color.set(layer, win, "text_normal") + layer.set_font_size(20) + layer.move_to(10+28, + y+win.scroll["script_shots"]+current_Y_shots-10+20) + layer.show_text(count) + + + + # The user might want to add the subfolders if they do not # exist already. @@ -2512,9 +2587,9 @@ def layer(win): except: pass UI_elements.roundrect(layer, win, - 10, + ifremote+10, y+win.scroll["script_shots"]+current_Y_shots-10, - width-30, + width-30-ifremote, 40, 10, button=do, @@ -2522,9 +2597,10 @@ def layer(win): tip=talk.text("GenerateSubfoldersTip")) UI_color.set(layer, win, "text_normal") - layer.move_to(60, y+win.scroll["script_shots"]+current_Y_shots+15) + layer.move_to(ifremote+60, y+win.scroll["script_shots"]+current_Y_shots+15) layer.show_text(talk.text("GenerateSubfolders")) - + + if at_least_one_missing or win.analytics["from-remote-server"]: current_Y_shots = current_Y_shots + 50 @@ -3146,7 +3222,7 @@ def layer(win): def do(): win.cur = surl - + select_shot(win) win.current["scroll_shot_to_in_script"] = True win.current["shot_left_side_scroll_please_work_omg_wtf"] = True diff --git a/studio/studio_settingsLayer.py b/studio/studio_settingsLayer.py index f414ffe..baeac8d 100644 --- a/studio/studio_settingsLayer.py +++ b/studio/studio_settingsLayer.py @@ -679,9 +679,51 @@ def layer(win): ) - current_Y += 50 + current_Y += 100 - current_Y += 50 + # WHICH BLENDER TO USE + + if "blender-bash" not in win.settings: + win.settings["blender-bash"] = "blender" + + UI_elements.image(layer, win, "settings/themes/"\ + +win.settings["Theme"]+"/icons/blender.png", + win.current["w"]/2-240, + 110 + current_Y + win.scroll["studio_settings"], + 40, + 40) + + UI_elements.text(layer, win, "blender-bash", + win.current["w"]/2-190, + 110 + current_Y + win.scroll["studio_settings"], + 420, + 40, + set_text=win.settings["blender-bash"], + tip=talk.text("blender-bash")) + + if win.text["blender-bash"]["text"] != win.settings["blender-bash"]: + def do(): + win.settings["blender-bash"] = win.text["blender-bash"]["text"] + settings.write("blender-bash", win.settings["blender-bash"]) + + UI_elements.roundrect(layer, win, + win.current["w"]/2-240+430, + 110 + current_Y + win.scroll["studio_settings"], + 40, + 40, + 10, + button=do, + icon="ok", + tip=talk.text("checked")) + + + + + current_Y += 100 + + + + # REMOTE SERVER rserv_ok = "unchecked"