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

Support Python 3 #2874

Merged
merged 1 commit into from
Jan 7, 2019
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ jobs:
- stage: test
env: CHECK=mcache PYTHON3=true
- stage: test
env: CHECK=mesos_slave
env: CHECK=mesos_slave PYTHON3=true
- stage: test
env: CHECK=mesos_master
- stage: test
Expand Down
13 changes: 6 additions & 7 deletions mesos_slave/datadog_checks/mesos_slave/mesos_slave.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@

Collects metrics from mesos slave node.
"""
# stdlib
from urlparse import urlparse

# 3rd party
import requests

# project
from six import iteritems
from six.moves.urllib.parse import urlparse

from datadog_checks.checks import AgentCheck
from datadog_checks.errors import CheckException
from datadog_checks.config import _is_affirmative
Expand Down Expand Up @@ -153,7 +152,7 @@ def _get_constant_attributes(self, url, timeout, master_port, verify, tags):
if self.cluster_name is None:
state_metrics = self._get_state(url, timeout, verify, tags)
if state_metrics is not None:
self.version = map(int, state_metrics['version'].split('.'))
self.version = list(map(int, state_metrics['version'].split('.')))

if 'master_hostname' in state_metrics:
master_state = self._get_state(
Expand Down Expand Up @@ -204,7 +203,7 @@ def check(self, instance):
if task.lower() in t['name'].lower() and t['slave_id'] == state_metrics['id']:
task_tags = ['task_name:' + t['name']] + tags
self.service_check(t['name'] + '.ok', self.TASK_STATUS[t['state']], tags=task_tags)
for key_name, (metric_name, metric_func) in self.TASK_METRICS.iteritems():
for key_name, (metric_name, metric_func) in iteritems(self.TASK_METRICS):
metric_func(self, metric_name, t['resources'][key_name], tags=task_tags)

stats_metrics = self._get_stats(url, timeout, ssl_verify, instance_tags)
Expand All @@ -213,7 +212,7 @@ def check(self, instance):
metrics = [self.SLAVE_TASKS_METRICS, self.SYSTEM_METRICS, self.SLAVE_RESOURCE_METRICS,
self.SLAVE_EXECUTORS_METRICS, self.STATS_METRICS]
for m in metrics:
for key_name, (metric_name, metric_func) in m.iteritems():
for key_name, (metric_name, metric_func) in iteritems(m):
if key_name in stats_metrics:
metric_func(self, metric_name, stats_metrics[key_name], tags=tags)

Expand Down
6 changes: 4 additions & 2 deletions mesos_slave/tests/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import pytest
import json

from six import iteritems

from datadog_checks.mesos_slave import MesosSlave


Expand Down Expand Up @@ -43,9 +45,9 @@ def test_check(check, aggregator):
check.SLAVE_EXECUTORS_METRICS, check.STATS_METRICS):
metrics.update(d)

for _, v in check.TASK_METRICS.iteritems():
for _, v in iteritems(check.TASK_METRICS):
aggregator.assert_metric(v[0])
for _, v in metrics.iteritems():
for _, v in iteritems(metrics):
aggregator.assert_metric(v[0])

service_check_tags = ['instance:mytag1',
Expand Down
21 changes: 9 additions & 12 deletions mesos_slave/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@
minversion = 2.0
basepython = py27
envlist =
unit
{py27,py36}-unit
flake8

[testenv]
usedevelop = true
platform = linux|darwin|win32

[testenv:unit]
deps =
-e../datadog_checks_base[deps]
-rrequirements-dev.txt
unit: -e../datadog_checks_base[deps]
unit: -rrequirements-dev.txt
flake8: flake8
commands =
pip install -r requirements.in
pytest -v

[testenv:flake8]
skip_install = true
deps = flake8
commands = flake8 .
unit: pip install -r requirements.in
unit: pytest -v
flake8: flake8 .
skip_install =
flake8: true

[flake8]
exclude = .eggs,.tox
Expand Down