From de6d665c6ecaf7300aebd0025a832af990eec73b Mon Sep 17 00:00:00 2001 From: koooge Date: Sat, 25 Apr 2020 11:34:45 +0200 Subject: [PATCH] fix: Make sure boto installed (#4835) Signed-off-by: koooge --- redash/query_runner/cloudwatch.py | 10 +++++++++- redash/query_runner/cloudwatch_insights.py | 14 +++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/redash/query_runner/cloudwatch.py b/redash/query_runner/cloudwatch.py index 16f65e5e9a..c4640a537d 100644 --- a/redash/query_runner/cloudwatch.py +++ b/redash/query_runner/cloudwatch.py @@ -1,10 +1,14 @@ -import boto3 import yaml import datetime from redash.query_runner import BaseQueryRunner, register from redash.utils import json_dumps, parse_human_time +try: + import boto3 + enabled = True +except ImportError: + enabled = False def parse_response(results): columns = [ @@ -63,6 +67,10 @@ def configuration_schema(cls): "secret": ["aws_secret_key"], } + @classmethod + def enabled(cls): + return enabled + def __init__(self, configuration): super(CloudWatch, self).__init__(configuration) self.syntax = "yaml" diff --git a/redash/query_runner/cloudwatch_insights.py b/redash/query_runner/cloudwatch_insights.py index 9091d158cb..139d5b678a 100644 --- a/redash/query_runner/cloudwatch_insights.py +++ b/redash/query_runner/cloudwatch_insights.py @@ -1,13 +1,17 @@ -import boto3 import yaml import datetime import time -from botocore.exceptions import ParamValidationError - from redash.query_runner import BaseQueryRunner, register from redash.utils import json_dumps, parse_human_time +try: + import boto3 + from botocore.exceptions import ParamValidationError + enabled = True +except ImportError: + enabled = False + POLL_INTERVAL = 3 TIMEOUT = 180 @@ -81,6 +85,10 @@ def configuration_schema(cls): "secret": ["aws_secret_key"], } + @classmethod + def enabled(cls): + return enabled + def __init__(self, configuration): super(CloudWatchInsights, self).__init__(configuration) self.syntax = "yaml"