Added file_exists_in_mounts method to look for projects on connected network mounts

This commit is contained in:
Brett Williams
2023-06-07 19:03:44 -05:00
parent ff4ef41a39
commit f54d665714
2 changed files with 70 additions and 13 deletions

View File

@@ -11,7 +11,7 @@ from PIL import Image, ImageTk
from lib.client.new_job_window import NewJobWindow
from lib.server.server_proxy import RenderServerProxy
from lib.server.zeroconf_server import ZeroconfServer
from lib.utilities.misc_helper import launch_url
from lib.utilities.misc_helper import launch_url, file_exists_in_mounts
logger = logging.getLogger()
@@ -99,19 +99,23 @@ class DashboardWindow:
button_frame.pack(pady=5, fill=tk.BOTH, expand=True)
# Create buttons
logs_button = tk.Button(button_frame, text="Logs", command=self.open_logs)
finder_button = tk.Button(button_frame, text="Reveal in Finder", command=self.reveal_in_finder)
self.logs_button = tk.Button(button_frame, text="Logs", command=self.open_logs)
self.show_files_button = tk.Button(button_frame, text="Show Files", command=self.show_files)
self.stop_button = tk.Button(button_frame, text="Stop", command=self.stop_job)
delete_button = tk.Button(button_frame, text="Delete", command=self.delete_job)
self.delete_button = tk.Button(button_frame, text="Delete", command=self.delete_job)
add_job_button = tk.Button(button_frame, text="Add Job", command=self.show_new_job_window)
self.stop_button.config(state='disabled')
# Pack the buttons in the frame
self.stop_button.pack(side=tk.LEFT)
delete_button.pack(side=tk.LEFT)
finder_button.pack(side=tk.LEFT)
logs_button.pack(side=tk.LEFT)
self.stop_button.config(state='disabled')
self.delete_button.pack(side=tk.LEFT)
self.delete_button.config(state='disabled')
self.show_files_button.pack(side=tk.LEFT)
self.show_files_button.config(state='disabled')
self.logs_button.pack(side=tk.LEFT)
self.logs_button.config(state='disabled')
add_job_button.pack(side=tk.RIGHT)
# Start the Tkinter event loop
@@ -211,14 +215,25 @@ class DashboardWindow:
# update button status
job = next((d for d in self.job_cache if d.get('id') == job_id), None)
button_state = 'normal' if job and job['status'] == 'running' else 'disabled'
self.stop_button.config(state=button_state)
stop_button_state = 'normal' if job and job['status'] == 'running' else 'disabled'
self.stop_button.config(state=stop_button_state)
generic_button_state = 'normal' if job else 'disabled'
self.show_files_button.config(state=generic_button_state)
self.delete_button.config(state=generic_button_state)
self.logs_button.config(state=generic_button_state)
def reveal_in_finder(self):
def show_files(self):
output_path = None
if self.selected_job_ids():
job = next((d for d in self.job_cache if d.get('id') == self.selected_job_ids()[0]), None)
output_dir = os.path.dirname(job['output_path'])
launch_url(output_dir)
output_path = os.path.dirname(job['output_path']) # check local filesystem
if not os.path.exists(output_path):
output_path = file_exists_in_mounts(output_path) # check any attached network shares
if output_path:
launch_url(output_path)
else:
messagebox.showerror("File Not Found", "The file could not be found. Check your network mounts.")
def open_logs(self):
if self.selected_job_ids():