diff --git a/apps/crc_proposal_end.py b/apps/crc_proposal_end.py index 224fa86..2971e1a 100755 --- a/apps/crc_proposal_end.py +++ b/apps/crc_proposal_end.py @@ -41,8 +41,12 @@ def app_logic(self, args: Namespace) -> None: if not alloc_requests: print(f"\033[91m\033[1mNo active allocation information found in accounting system for '{args.account}'!\n") - print("Showing end date for most recently expired Resource Allocation Request:\033[0m") - alloc_requests = [get_most_recent_expired_request(keystone_session, team_id)] + print("Showing end date for most recently expired Resource Allocation Request:\033[0m \n") + try: + alloc_requests = [get_most_recent_expired_request(keystone_session, team_id)] + except IndexError: + print("\033[91m\033[1mNo allocation information found. Either the group does not have any allocations, or you do not have permissions to view them. If you believe this to be a mistake, please submit a help ticket to the CRCD team. \033[0m \n") + exit() for request in alloc_requests: print(f"'{request['title']}' ends on {request['expire']} ") diff --git a/apps/crc_sus.py b/apps/crc_sus.py index a25d478..2b95223 100755 --- a/apps/crc_sus.py +++ b/apps/crc_sus.py @@ -66,8 +66,12 @@ def app_logic(self, args: Namespace) -> None: if not alloc_requests: print(f"\033[91m\033[1mNo active allocation information found in accounting system for '{args.account}'!\n") - print("Showing remaining service unit amounts for most recently expired Resource Allocation Request:\033[0m") - alloc_requests = [get_most_recent_expired_request(keystone_session, group_id)] + print("Showing remaining service unit amounts for most recently expired Resource Allocation Request:\033[0m \n") + try: + alloc_requests = [get_most_recent_expired_request(keystone_session, group_id)] + except IndexError: + print("\033[91m\033[1mNo allocation information found. Either the group does not have any allocations, or you do not have permissions to view them. If you believe this to be a mistake, please submit a help ticket to the CRCD team. \033[0m \n") + exit() per_cluster_totals = get_per_cluster_totals(keystone_session, alloc_requests, get_enabled_cluster_ids(keystone_session)) diff --git a/apps/crc_usage.py b/apps/crc_usage.py index 0c37a30..e5dd9e4 100755 --- a/apps/crc_usage.py +++ b/apps/crc_usage.py @@ -98,7 +98,7 @@ def app_logic(self, args: Namespace) -> None: Slurm.check_slurm_account_exists(account_name=args.account) keystone_session = KeystoneClient(url=KEYSTONE_URL) - keystone_session.login(username=os.environ["USER"], password=getpass("Please enter your CRC login password:\n")) + keystone_session.login(username=os.environ["USER"], password=getpass("Please enter your CRCD login password:\n")) # Gather AllocationRequests from Keystone group_id = get_team_id(keystone_session, args.account) @@ -106,8 +106,12 @@ def app_logic(self, args: Namespace) -> None: if not alloc_requests: print(f"\033[91m\033[1mNo active allocation information found in accounting system for '{args.account}'!\n") - print("Showing usage information for most recently expired Resource Allocation Request: \033[0m") - alloc_requests = [get_most_recent_expired_request(keystone_session, group_id)] + print("Attempting to show the most recently expired Resource Allocation Request info: \033[0m \n") + try: + alloc_requests = [get_most_recent_expired_request(keystone_session, group_id)] + except IndexError: + print("\033[91m\033[1mNo allocation information found. Either the group does not have any allocations, or you do not have permissions to view them. If you believe this to be a mistake, please submit a help ticket to the CRCD team. \033[0m \n") + exit() clusters = get_enabled_cluster_ids(keystone_session)