Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tool UIs: Handle missing folder short name #662

Merged
merged 4 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/ayon_core/tools/common_models/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def from_data(cls, data):
def from_project_item(cls, folder_type_data):
return cls(
name=folder_type_data["name"],
short=folder_type_data["shortName"],
short=folder_type_data.get("shortName", ""),
icon=folder_type_data["icon"],
)

Expand Down
6 changes: 5 additions & 1 deletion client/ayon_core/tools/utils/folders_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ def _on_refresh_thread(self, thread_id):
or thread_id != self._current_refresh_thread.id
):
return
folder_items, folder_type_items = thread.get_result()
if thread.failed:
# TODO visualize that refresh failed
folder_items, folder_type_items = {}, {}
Comment on lines +195 to +197
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do anything to reproduce this particular issue when the thread would fail?

Copy link
Member Author

@iLLiCiTiT iLLiCiTiT Jun 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may wary, could be because server connection failed, or like reason of this PR, missing key in data.

else:
folder_items, folder_type_items = thread.get_result()
self._fill_items(folder_items, folder_type_items)
self._current_refresh_thread = None

Expand Down
21 changes: 18 additions & 3 deletions client/ayon_core/tools/utils/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import sys
import contextlib
import collections
import traceback
from functools import partial
from typing import Union, Any

from qtpy import QtWidgets, QtCore, QtGui
import qtawesome
Expand Down Expand Up @@ -425,26 +427,39 @@ def __init__(self, thread_id, func, *args, **kwargs):
self._id = thread_id
self._callback = partial(func, *args, **kwargs)
self._exception = None
self._traceback = None
self._result = None
self.finished.connect(self._on_finish_callback)

@property
def id(self):
def id(self) -> str:
return self._id

@property
def failed(self):
def failed(self) -> bool:
return self._exception is not None

def run(self):
try:
self._result = self._callback()
except Exception as exc:
exc_type, exc_value, exc_traceback = sys.exc_info()
err_traceback = "".join(traceback.format_exception(
exc_type, exc_value, exc_traceback
))
print(err_traceback)
self._traceback = err_traceback
self._exception = exc

def get_result(self):
def get_result(self) -> Any:
return self._result

def get_exception(self) -> Union[BaseException, None]:
return self._exception

def get_traceback(self) -> Union[str, None]:
return self._traceback

def _on_finish_callback(self):
"""Trigger custom signal with thread id.

Expand Down