Skip to content

Commit 73a7359

Browse files
author
Nick Selpa
committed
Updated valid_check_types and changed inspect_ce_project to return a dict
1 parent f3979d9 commit 73a7359

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

cloudendure/cloudendure.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -475,20 +475,21 @@ def get_machine_sync_details(self) -> Dict[Any]:
475475
# output to stdout for interactive usage
476476
return response_dict
477477

478-
def inspect_ce_project(self, check_type: str) -> List[Any]:
479-
if not check_type:
478+
def inspect_ce_project(self, check_type: str) -> Dict[str, Any]:
479+
valid_check_types: List[str] = ['not_synced', 'not_started', 'not_current']
480+
if check_type not in valid_check_types:
480481
print(
481-
f"ERROR: Unknown check_type of '{check_type}'; Please use 'not_synced', 'not_started', or 'not_current' ..."
482+
f'ERROR: Unknown check_type of "{check_type}"; Please use a valid check_type: [ {", ".join(valid_check_types)} ] ...'
482483
)
483484
return
484-
result: List[Any] = []
485-
sync_report: List[Any] = self.get_machine_sync_details()
485+
result: Dict[str, Any] = {}
486+
sync_report: Dict[str, Any] = self.get_machine_sync_details()
486487
print(f"INFO: Using check '{check_type}' on Project: ({self.project_name})")
487488
inspector = getattr(self, check_type)
488-
for item in sync_report:
489-
mcheck = inspector(machine=item)
489+
for item in sync_report.keys():
490+
mcheck = inspector(machine=sync_report[item])
490491
if mcheck:
491-
result.append(item)
492+
result[item] = sync_report[item]
492493
print(f"INFO: Check '{check_type}' completed; {len(result)} machines matched in Project: ({self.project_name})")
493494
return result
494495

@@ -506,7 +507,7 @@ def not_started(self, machine) -> bool:
506507

507508
def not_current(self, machine, delta_seconds: int = 86400) -> bool:
508509
if machine.get("last_seen_utc"):
509-
now: datetime = datetime.now(datetime.timezone.utc)
510+
now: datetime = datetime.datetime.now(datetime.timezone.utc)
510511
machine_last_seen: datetime = datetime.datetime.fromisoformat(machine["last_seen_utc"])
511512
last_seen_delta: datetime = now - machine_last_seen
512513
if int(last_seen_delta.total_seconds()) >= delta_seconds:

0 commit comments

Comments
 (0)