Skip to content

Commit

Permalink
remove pytz
Browse files Browse the repository at this point in the history
  • Loading branch information
steveny91 committed Oct 31, 2024
1 parent 8ae076c commit b4e15dd
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions ibm_mq/datadog_checks/ibm_mq/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import datetime as dt
import re

import pytz
from dateutil.tz import UTC
from dateutil import tz

from datadog_checks.base import AgentCheck, ConfigurationError, is_affirmative
from datadog_checks.base.constants import ServiceCheck
Expand Down Expand Up @@ -100,17 +99,21 @@ def __init__(self, instance, init_config):

self.convert_endianness = instance.get('convert_endianness', False) # type: bool
self.qm_timezone = instance.get('queue_manager_timezone', 'UTC') # type: str

try:
if self.qm_timezone != 'UTC':
self.qm_stats_tz = pytz.timezone(self.qm_timezone)
self.qm_stats_tz = tz.gettz(self.qm_timezone)
if self.qm_stats_tz is None:
raise ValueError(f"'{self.qm_timezone}' is not a recognized timezone.")
else:
self.qm_stats_tz = pytz.UTC
except pytz.UnknownTimeZoneError:
self.qm_stats_tz = tz.UTC
except ValueError as e:
self.log.error(
"Invalid timezone: %s. Defaulting to UTC. Please specify a valid time zone in IANA/Olson format.",
"Invalid timezone: %s. Defaulting to UTC. Please specify a valid time zone in IANA/Olson format. %s",
self.qm_timezone,
e,
)
self.qm_stats_tz = pytz.UTC
self.qm_stats_tz = tz.UTC

self.auto_discover_channels = instance.get('auto_discover_channels', True) # type: bool

Expand Down Expand Up @@ -181,7 +184,7 @@ def __init__(self, instance, init_config):
else:
self.queue_manager_process_pattern = None

self.instance_creation_datetime = dt.datetime.now(UTC)
self.instance_creation_datetime = dt.datetime.now(tz.UTC)

def add_queues(self, new_queues):
# add queues without duplication
Expand Down

0 comments on commit b4e15dd

Please sign in to comment.