-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 the use of the deprecated pkg_resources
package
#13842
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ futures,PyPI,PSF,Copyright (c) 2015 Brian Quinlan | |
gearman,PyPI,Apache-2.0,Copyright 2010 Yelp <[email protected]> | ||
gssapi,PyPI,ISC,"Copyright (c) 2014, The Python GSSAPI Team" | ||
immutables,PyPI,Apache-2.0,Copyright 2018-present Contributors to the immutables project. | ||
importlib-metadata,PyPI,Apache-2.0,Copyright Jason R. Coombs | ||
in-toto,PyPI,Apache-2.0,Copyright 2018 New York University | ||
ipaddress,PyPI,PSF,Copyright (c) 2013 Philipp Hagemeister | ||
jellyfish,PyPI,BSD-3-Clause,"Copyright (c) 2015, James Turk" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
# (C) Datadog, Inc. 2019-present | ||
# All rights reserved | ||
# Licensed under a 3-clause BSD style license (see LICENSE) | ||
import sys | ||
|
||
import pkg_resources | ||
if sys.version_info >= (3, 8): | ||
from importlib.metadata import distributions | ||
else: | ||
from importlib_metadata import distributions | ||
|
||
DATADOG_CHECK_PREFIX = "datadog-" | ||
DATADOG_CHECK_PREFIX = 'datadog-' | ||
|
||
|
||
def get_datadog_wheels(): | ||
packages = [] | ||
dist = list(pkg_resources.working_set) | ||
for package in dist: | ||
if package.project_name.startswith(DATADOG_CHECK_PREFIX): | ||
name = package.project_name[len(DATADOG_CHECK_PREFIX) :].replace('-', '_') | ||
for package in distributions(): | ||
project_name = package.metadata['Name'] | ||
if project_name.startswith(DATADOG_CHECK_PREFIX): | ||
name = project_name[len(DATADOG_CHECK_PREFIX) :].replace('-', '_') | ||
packages.append(name) | ||
|
||
return sorted(packages)[::-1] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
from __future__ import division | ||
|
||
import bmemcached | ||
import pkg_resources | ||
from six import iteritems, itervalues | ||
|
||
from datadog_checks.base import AgentCheck, ConfigurationError | ||
|
@@ -105,10 +104,6 @@ class Memcache(AgentCheck): | |
|
||
SERVICE_CHECK = 'memcache.can_connect' | ||
|
||
@classmethod | ||
def get_library_versions(cls): | ||
return {"memcache": pkg_resources.get_distribution("python-binary-memcached").version} | ||
Comment on lines
-109
to
-110
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is entirely removed, is there no alternative to using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was not being used by anything so I simply removed it |
||
|
||
def _process_response(self, response): | ||
""" | ||
Examine the response and raise an error is something is off | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ofek have you checked that this function does the same thing? I assume you have, but just double-checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For our use case, yes