From 21641c5aebb7dd03bcd08bfd06030e9daaec1a91 Mon Sep 17 00:00:00 2001
From: Tim Kreuzer <t.kreuzer@fz-juelich.de>
Date: Sun, 25 May 2025 22:15:00 +0200
Subject: [PATCH] fix default system for r2d

---
 jsc_custom/handler/share_handler.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/jsc_custom/handler/share_handler.py b/jsc_custom/handler/share_handler.py
index a5912ed..e86129c 100644
--- a/jsc_custom/handler/share_handler.py
+++ b/jsc_custom/handler/share_handler.py
@@ -166,17 +166,20 @@ class R2DHandler(SpawnHandler):
         if len(arguments_dict_lower.get("system", [])) > 0:
             system = arguments_dict_lower.get("system")[0].decode("utf-8")
         elif len(auth_state.get("outpost_flavors", {}).keys()) > 0:
-            system = list(auth_state.get("outpost_flavors", {}).keys())[0]
-        else:
             try:
                 custom_config = get_custom_config()
-                if "deNBI-Cloud" in custom_config.get("systems", {}).keys():
+                if (
+                    "deNBI-Cloud" in custom_config.get("systems", {}).keys()
+                    and "deNBI-Cloud" in auth_state.get("outpost_flavors", {}).keys()
+                ):
                     system = "deNBI-Cloud"
                 else:
-                    system = "JSC-Cloud"
+                    system = list(auth_state.get("outpost_flavors", {}).keys())[0]
             except:
                 self.log.exception("Could not check for systems")
                 system = "JSC-Cloud"
+        else:
+            system = "JSC-Cloud"
         user_options["system"] = system
 
         # Get Flavor
-- 
GitLab