Skip to content

Commit

Permalink
add error messages to crc-sus and crc-proposal-end
Browse files Browse the repository at this point in the history
:
  • Loading branch information
Comeani committed Nov 11, 2024
1 parent e32a9d9 commit fb19bac
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
8 changes: 6 additions & 2 deletions apps/crc_proposal_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Check notice on line 48 in apps/crc_proposal_end.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

apps/crc_proposal_end.py#L48

Line too long (259/120)
exit()

for request in alloc_requests:
print(f"'{request['title']}' ends on {request['expire']} ")
8 changes: 6 additions & 2 deletions apps/crc_sus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Check notice on line 73 in apps/crc_sus.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

apps/crc_sus.py#L73

Line too long (259/120)
exit()

per_cluster_totals = get_per_cluster_totals(keystone_session, alloc_requests,
get_enabled_cluster_ids(keystone_session))
Expand Down
10 changes: 7 additions & 3 deletions apps/crc_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,20 @@ 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"))

Check notice on line 101 in apps/crc_usage.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

apps/crc_usage.py#L101

Line too long (121/120)

# Gather AllocationRequests from Keystone
group_id = get_team_id(keystone_session, args.account)
alloc_requests = get_active_requests(keystone_session, group_id)

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")

Check notice on line 113 in apps/crc_usage.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

apps/crc_usage.py#L113

Line too long (259/120)
exit()

clusters = get_enabled_cluster_ids(keystone_session)

Expand Down

0 comments on commit fb19bac

Please sign in to comment.