]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/telegraf: drop python2 support
authorKefu Chai <kchai@redhat.com>
Mon, 22 Mar 2021 09:41:22 +0000 (17:41 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 22 Mar 2021 10:20:51 +0000 (18:20 +0800)
urlparse is offered by urllib.parse in python3, so no need to
catch the ImportError exception for python2.

and there is no need to add `u` prefix for unicode string in python3.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/telegraf/module.py
src/pybind/mgr/telegraf/protocol.py

index ca25fce7c73815677723f3f4422701971580df1d..d5041c88572bab229344bcd66f3a42cb07bd8517 100644 (file)
@@ -9,10 +9,7 @@ from telegraf.basesocket import BaseSocket
 from telegraf.protocol import Line
 from mgr_module import MgrModule, PG_STATES
 
-try:
-    from urllib.parse import urlparse
-except ImportError:
-    from urlparse import urlparse
+from urllib.parse import urlparse
 
 
 class Module(MgrModule):
index d243e0c1a02136e94b83c09aa36831a73558a235..80a25ff43ac9b3ae7dccccb193b7efa10a398107 100644 (file)
@@ -20,7 +20,7 @@ class Line(object):
         sorted_values = sorted(metric_values.items())
         sorted_values = [(k, v) for k, v in sorted_values if v is not None]
 
-        return u','.join(u'{0}={1}'.format(format_string(k), format_value(v)) for k, v in sorted_values)
+        return ','.join('{0}={1}'.format(format_string(k), format_value(v)) for k, v in sorted_values)
 
     def get_output_tags(self):
         if not self.tags:
@@ -28,7 +28,7 @@ class Line(object):
 
         sorted_tags = sorted(self.tags.items())
 
-        return u','.join(u'{0}={1}'.format(format_string(k), format_string(v)) for k, v in sorted_tags)
+        return ','.join('{0}={1}'.format(format_string(k), format_string(v)) for k, v in sorted_tags)
 
     def get_output_timestamp(self):
         return ' {0}'.format(self.timestamp) if self.timestamp else ''
@@ -36,7 +36,7 @@ class Line(object):
     def to_line_protocol(self):
         tags = self.get_output_tags()
 
-        return u'{0}{1} {2}{3}'.format(
+        return '{0}{1} {2}{3}'.format(
             self.get_output_measurement(),
             "," + tags if tags else '',
             self.get_output_values(),