Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Agent 5 conditional imports #5322

Merged
merged 3 commits into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions datadog_checks_base/datadog_checks/base/checks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)

try:
# Agent5 compatibility layer
from checks import AgentCheck
from checks.network_checks import NetworkCheck, Status, EventType
except ImportError:
from .base import AgentCheck
from .network import NetworkCheck, Status, EventType
from .base import AgentCheck
from .network import EventType, NetworkCheck, Status

__all__ = ['AgentCheck', 'NetworkCheck', 'Status', 'EventType']
5 changes: 0 additions & 5 deletions datadog_checks_base/datadog_checks/base/checks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ class except the :py:meth:`check` method but sometimes it might be useful for a
the Agent might create several different Check instances and the method would be
called as many times.

Agent 5 signature:

AgentCheck(name, init_config, agentConfig, instances=None)
AgentCheck.check(instance)

Agent 6,7 signature:

AgentCheck(name, init_config, instances) # instances contain only 1 instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)

try:
# Agent5 compatibility layer
from checks import UnknownFormatError, PrometheusFormat, PrometheusCheck
except ImportError:
from .mixins import PrometheusFormat, UnknownFormatError
from .prometheus_base import PrometheusCheck
from .base_check import GenericPrometheusCheck

from .base_check import PrometheusScraper
from .base_check import GenericPrometheusCheck, PrometheusScraper
from .mixins import PrometheusFormat, UnknownFormatError
from .prometheus_base import PrometheusCheck

__all__ = ['PrometheusFormat', 'UnknownFormatError', 'PrometheusCheck', 'GenericPrometheusCheck', 'PrometheusScraper']
10 changes: 2 additions & 8 deletions datadog_checks_base/datadog_checks/base/checks/win/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)

try:
# Agent5 compatibility layer
from checks.libs.win.pdhbasecheck import PDHBaseCheck
from checks.libs.win.winpdh import WinPDHCounter
except ImportError:
from .winpdh_base import PDHBaseCheck
from .winpdh import WinPDHCounter

from .winpdh import WinPDHCounter
from .winpdh_base import PDHBaseCheck

__all__ = ['PDHBaseCheck', 'WinPDHCounter']
2 changes: 1 addition & 1 deletion datadog_checks_base/datadog_checks/base/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ def is_affirmative(value):
return not not value


# Compatibility layer for Agent5
# Deprecated compatibility layer for Agent 5, will be removed in Agent 8
_is_affirmative = is_affirmative
mgarabed marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,12 @@
from .. import ensure_unicode

try:
# Agent6
from _util import get_subprocess_output as subprocess_output
from _util import SubprocessOutputEmptyError # noqa
except ImportError:
try:
# Agent5 (these paths may also exist in Agent6, so import them only if Agent6-specific ones aren't found)
from utils.subprocess_output import subprocess_output
from utils.subprocess_output import SubprocessOutputEmptyError # noqa
except ImportError:
# No agent
from ..stubs._util import subprocess_output
from ..stubs._util import SubprocessOutputEmptyError # noqa
# No agent
from ..stubs._util import subprocess_output
from ..stubs._util import SubprocessOutputEmptyError # noqa


log = logging.getLogger(__name__)
Expand Down