File: fix-info-output.patch

package info (click to toggle)
ripe-atlas-tools 2.3.0-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 1,020 kB
  • sloc: python: 7,531; makefile: 156; sh: 7
file content (81 lines) | stat: -rw-r--r-- 3,581 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
From: Apollon Oikonomopoulos <apoikos@debian.org>
Date: Thu, 14 Feb 2019 16:57:54 +0200
Subject: Fix *-{info,search} output with Python3

Forwarded: no
Last-Update: 2019-01-16

Upstream code uses print(str.encode("utf-8")) in a couple of places. While
this works fine with Python2 (being mostly a no-op), in Python 3 it prints the
representation of the string converted to bytes ("b'some string'"), which
messes up command output.
Fix the output by removing the calls to encode() for printed strings. This
does not affect Python 2.
---
 ripe/atlas/tools/commands/base.py               | 2 +-
 ripe/atlas/tools/commands/measurement_search.py | 2 +-
 ripe/atlas/tools/commands/probe_info.py         | 2 +-
 ripe/atlas/tools/commands/probe_search.py       | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ripe/atlas/tools/commands/base.py b/ripe/atlas/tools/commands/base.py
index 2f204e9..2278569 100644
--- a/ripe/atlas/tools/commands/base.py
+++ b/ripe/atlas/tools/commands/base.py
@@ -310,7 +310,7 @@ class MetaDataMixin(object):
         if six.PY2 and isinstance(value, six.string_types):
             value = unicode(value)
 
-        log = u"{}  {}".format(colourise("{:25}".format(header), "bold"), value).encode("utf-8")
+        log = u"{}  {}".format(colourise("{:25}".format(header), "bold"), value)
         print(log)
 
 
diff --git a/ripe/atlas/tools/commands/measurement_search.py b/ripe/atlas/tools/commands/measurement_search.py
index 8b6671b..928610c 100644
--- a/ripe/atlas/tools/commands/measurement_search.py
+++ b/ripe/atlas/tools/commands/measurement_search.py
@@ -149,7 +149,7 @@ class Command(TabularFieldsMixin, BaseCommand):
         for measurement in truncated_measurements:
             lformat = self._get_line_format().format(*self._get_line_items(measurement))
             lcolour = self._get_colour_from_status(measurement.status_id)
-            log = colourise(lformat, lcolour).encode("utf8")
+            log = colourise(lformat, lcolour)
             print(log)
 
         print(colourise(hr, "bold"))
diff --git a/ripe/atlas/tools/commands/probe_info.py b/ripe/atlas/tools/commands/probe_info.py
index 8c1fd45..76fb32c 100644
--- a/ripe/atlas/tools/commands/probe_info.py
+++ b/ripe/atlas/tools/commands/probe_info.py
@@ -73,7 +73,7 @@ class Command(MetaDataMixin, BaseCommand):
         print(colourise("Tags", "bold"))
         for tag in probe.tags:
             log_tag = "  {}".format(tag["slug"])
-            print(log_tag.encode("utf8"))
+            print(log_tag)
 
     @staticmethod
     def _prettify_coordinates(geometry):
diff --git a/ripe/atlas/tools/commands/probe_search.py b/ripe/atlas/tools/commands/probe_search.py
index 99f8832..f1ad67f 100644
--- a/ripe/atlas/tools/commands/probe_search.py
+++ b/ripe/atlas/tools/commands/probe_search.py
@@ -239,7 +239,7 @@ class Command(TabularFieldsMixin, BaseCommand):
         else:
 
             for probe in truncated_probes:
-                print(self._get_line(probe).encode("utf8"))
+                print(self._get_line(probe))
 
         print(colourise(hr, "bold"))
 
@@ -272,7 +272,7 @@ class Command(TabularFieldsMixin, BaseCommand):
         elif isinstance(aggregation_data, list):
 
             for index, probe in enumerate(aggregation_data):
-                print(" {}".format(self._get_line(probe)).encode("utf8"))
+                print(" {}".format(self._get_line(probe)))
                 if self.arguments.max_per_aggregation:
                     if index >= self.arguments.max_per_aggregation - 1:
                         break