Skip to content

Commit

Permalink
Merge pull request #82 from ynput/enhancement/show-username-in-dev-mode
Browse files Browse the repository at this point in the history
Missing dev bundle enhancements
  • Loading branch information
iLLiCiTiT committed Jan 15, 2024
2 parents 61f268a + e6d594b commit 97e926d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
23 changes: 21 additions & 2 deletions common/ayon_common/distribution/ui/missing_bundle_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(
self,
url=None,
bundle_name=None,
username=None,
use_staging=None,
use_dev=None,
parent=None
Expand All @@ -31,6 +32,7 @@ def __init__(

self._url = url
self._bundle_name = bundle_name
self._username = username
self._use_staging = use_staging
self._use_dev = use_dev
self._first_show = True
Expand Down Expand Up @@ -70,6 +72,12 @@ def set_bundle_name(self, bundle_name):
self._bundle_name = bundle_name
self._update_label()

def set_username(self, username):
if username == self._username:
return
self._username = username
self._update_label()

def set_use_staging(self, use_staging):
if self._use_staging == use_staging:
return
Expand Down Expand Up @@ -123,7 +131,10 @@ def _get_label(self):
if self._use_staging:
mode = "staging"
elif self._use_dev:
mode = "dev for your user"
if self._username:
mode = f"dev for user <b>{self._username}</b>"
else:
mode = "dev for your user"
return (
f"No release bundle is set as {mode} on the AYON"
f" server{url_part} so there is nothing to launch."
Expand All @@ -144,6 +155,7 @@ def main():

url = None
bundle_name = None
username = None
if "--url" in sys.argv:
url_index = sys.argv.index("--url") + 1
if url_index < len(sys.argv):
Expand All @@ -154,10 +166,17 @@ def main():
if bundle_index < len(sys.argv):
bundle_name = sys.argv[bundle_index]

if "--user" in sys.argv:
user_index = sys.argv.index("--user") + 1
if user_index < len(sys.argv):
username = sys.argv[user_index]

use_staging = is_staging_enabled()
use_dev = is_dev_mode_enabled()
app = get_qt_app()
window = MissingBundleWindow(url, bundle_name, use_staging, use_dev)
window = MissingBundleWindow(
url, bundle_name, username, use_staging, use_dev
)
window.show()
app.exec_()

Expand Down
6 changes: 5 additions & 1 deletion common/ayon_common/distribution/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_dependencies_dir():
return dependencies_dir


def show_missing_bundle_information(url, bundle_name=None):
def show_missing_bundle_information(url, bundle_name=None, username=None):
"""Show missing bundle information window.
This function should be called when server does not have set bundle for
Expand All @@ -82,13 +82,17 @@ def show_missing_bundle_information(url, bundle_name=None):
Args:
url (str): Server url where bundle is not set.
bundle_name (Optional[str]): Name of bundle that was not found.
username (Optional[str]): Username. Is used only when dev mode is
enabled.
"""

ui_dir = os.path.join(os.path.dirname(__file__), "ui")
script_path = os.path.join(ui_dir, "missing_bundle_window.py")
args = get_ayon_launch_args(script_path, "--skip-bootstrap", "--url", url)
if bundle_name:
args.extend(["--bundle", bundle_name])
if username:
args.extend(["--user", username])
subprocess.call(args)


Expand Down
13 changes: 8 additions & 5 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,8 @@ def _start_distribution():

if bundle is None:
url = get_base_url()
if not HEADLESS_MODE_ENABLED:
show_missing_bundle_information(url, bundle_name)

elif bundle_name:
username = distribution.active_user
if bundle_name:
_print((
f"!!! Requested release bundle '{bundle_name}'"
" is not available on server."
Expand All @@ -562,7 +560,7 @@ def _start_distribution():
else:
mode = "production"
if distribution.use_dev:
mode = "dev"
mode = f"dev for user '{username}'"
elif distribution.use_staging:
mode = "staging"

Expand All @@ -573,6 +571,11 @@ def _start_distribution():
"!!! Make sure there is a release bundle set"
f" as \"{mode}\" on the AYON server '{url}'."
)


if not HEADLESS_MODE_ENABLED:
show_missing_bundle_information(url, bundle_name, username)

sys.exit(1)

# With known bundle and states we can define default settings variant
Expand Down

0 comments on commit 97e926d

Please sign in to comment.