mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-24 21:11:53 +00:00
fixed decorator to correctly handle args
This commit is contained in:
@@ -104,18 +104,22 @@ class AWSService:
|
||||
# Make the task disappear once completed
|
||||
# self.progress.remove_task(task_id)
|
||||
|
||||
def progress_decorator(self, func):
|
||||
@staticmethod
|
||||
def progress_decorator(func):
|
||||
"""Decorator to update the progress bar before and after a function call."""
|
||||
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
task_name = func.__name__.replace("_", " ").capitalize()
|
||||
def wrapper(self, *args, **kwargs):
|
||||
# Trim leading and trailing underscores from the call's name
|
||||
func_name = func.__name__.strip("_")
|
||||
# Add Capitalization
|
||||
func_name = " ".join([x.capitalize() for x in func_name.split("_")])
|
||||
task_id = self.task_progress_bar.add_task(
|
||||
f"- {task_name}...", total=1, task_type="Service"
|
||||
f"- {func_name}...", total=1, task_type="Service"
|
||||
)
|
||||
self.progress_tasks.append(task_id)
|
||||
|
||||
result = func(*args, **kwargs) # Execute the function
|
||||
result = func(self, *args, **kwargs) # Execute the function
|
||||
|
||||
self.task_progress_bar.update(task_id, advance=1)
|
||||
# self.task_progress_bar.remove_task(task_id) # Uncomment if you want to remove the task on completion
|
||||
|
||||
@@ -53,7 +53,6 @@ class CloudFront(AWSService):
|
||||
f"{region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
|
||||
@AWSService.progress_decorator
|
||||
def __get_distribution_config__(self, distribution_id, client, region) -> dict:
|
||||
try:
|
||||
distribution_config = client.get_distribution_config(Id=distribution_id)
|
||||
|
||||
Reference in New Issue
Block a user