You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ch...@apache.org on 2019/05/01 16:01:24 UTC

[qpid-dispatch] branch master updated: Revert "DISPATCH-1324: Replace deprecated cgi.escape usage"

This is an automated email from the ASF dual-hosted git repository.

chug pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git


The following commit(s) were added to refs/heads/master by this push:
     new 2152c67  Revert "DISPATCH-1324: Replace deprecated cgi.escape usage"
2152c67 is described below

commit 2152c672928ec2bfdc60067772642b81e86972b9
Author: Chuck Rolke <ch...@apache.org>
AuthorDate: Wed May 1 11:47:21 2019 -0400

    Revert "DISPATCH-1324: Replace deprecated cgi.escape usage"
    
    This reverts commit b1b17b46fa4d8979c381897eb5f3f0636e22153f.
---
 tools/scraper/common.py       |  5 +++--
 tools/scraper/log_splitter.py | 35 +++++++++++++++++++++++------------
 tools/scraper/nicknamer.py    | 19 +++++++------------
 tools/scraper/scraper.py      |  9 ++-------
 4 files changed, 35 insertions(+), 33 deletions(-)

diff --git a/tools/scraper/common.py b/tools/scraper/common.py
index 47ae1c5..c9ca18d 100755
--- a/tools/scraper/common.py
+++ b/tools/scraper/common.py
@@ -21,12 +21,13 @@
 
 # Common data storage and utilities
 
-import six
 import sys
 
 import nicknamer
 
-if six.PY2:
+IS_PY2 = sys.version_info[0] == 2
+
+if IS_PY2:
     def dict_iteritems(d):
         return d.iteritems()
     def dict_iterkeys(d):
diff --git a/tools/scraper/log_splitter.py b/tools/scraper/log_splitter.py
index a2f45e3..c321093 100755
--- a/tools/scraper/log_splitter.py
+++ b/tools/scraper/log_splitter.py
@@ -29,9 +29,9 @@ from __future__ import division
 from __future__ import absolute_import
 from __future__ import print_function
 
+import cgi
 from datetime import *
 import os
-import six
 import sys
 import traceback
 from collections import defaultdict
@@ -39,11 +39,6 @@ from collections import defaultdict
 import common
 import text
 
-if six.PY2:
-    from cgi import escape as html_escape
-else:
-    from html import escape as html_escape
-
 class connection():
     def __init__(self, instance, conn_id, logfile):
         self.instance = instance
@@ -417,7 +412,7 @@ function show_node(node)
         for rc in self.router_connections:
             print("<tr><td><a href=\"%s/%s\">%s</a></td><td>%d</td><td>%d</td><td>%s</td></tr>" %
                   (rc.logfile.odir(), rc.path_name, rc.disp_name(), rc.transfers, len(rc.lines),
-                   html_escape(rc.peer_open)))
+                   cgi.escape(rc.peer_open)))
         print("</table>")
         print("<hr>")
 
@@ -429,7 +424,7 @@ function show_node(node)
         for rc in self.broker_connections:
             print("<tr><td><a href=\"%s/%s\">%s</a></td><td>%d</td><td>%d</td><td>%s</td></tr>" %
                   (rc.logfile.odir(), rc.path_name, rc.disp_name(), rc.transfers, len(rc.lines),
-                   html_escape(rc.peer_open)))
+                   cgi.escape(rc.peer_open)))
         print("</table>")
         print("<hr>")
 
@@ -448,7 +443,7 @@ function show_node(node)
         print("<table>")
         print("<tr><th>N</th> <th>AMQP error</th></tr>")
         for i in range(len(self.errors)):
-            print("<tr><td>%d</td> <td>%s</td></tr>" % (i, html_escape(self.errors[i].strip())))
+            print("<tr><td>%d</td> <td>%s</td></tr>" % (i, cgi.escape(self.errors[i].strip())))
         print("</table>")
         print("<hr>")
 
@@ -487,7 +482,7 @@ function show_node(node)
             if rc.transfers > 0:
                 print("<tr><td>%d</td><td><a href=\"%s/%s\">%s</a></td> <td>%d</td> <td>%d</td> <td>%s</td> <td>%s</td></tr>" %
                       (n, rc.logfile.odir(), rc.path_name, rc.disp_name(), rc.transfers, len(rc.lines),
-                       rc.peer_type, html_escape(rc.peer_open)))
+                       rc.peer_type, cgi.escape(rc.peer_open)))
                 n += 1
         print("</table>")
         print("<hr>")
@@ -501,7 +496,7 @@ function show_node(node)
             if rc.transfers == 0:
                 print("<tr><td>%d</td><td><a href=\"%s/%s\">%s</a></td> <td>%d</td> <td>%d</td> <td>%s</td> <td>%s</td></tr>" %
                       (n, rc.logfile.odir(), rc.path_name, rc.disp_name(), rc.transfers, len(rc.lines),
-                       rc.peer_type, html_escape(rc.peer_open)))
+                       rc.peer_type, cgi.escape(rc.peer_open)))
                 n += 1
         print("</table>")
         print("<hr>")
@@ -514,7 +509,7 @@ function show_node(node)
         for rc in self.conns_by_size_loglines:
             print("<tr><td>%d</td><td><a href=\"%s/%s\">%s</a></td> <td>%d</td> <td>%d</td> <td>%s</td> <td>%s</td></tr>" %
                   (n, rc.logfile.odir(), rc.path_name, rc.disp_name(), rc.transfers, len(rc.lines),
-                   rc.peer_type, html_escape(rc.peer_open)))
+                   rc.peer_type, cgi.escape(rc.peer_open)))
             n += 1
         print("</table>")
         print("<hr>")
@@ -611,6 +606,22 @@ function show_node(node)
             n += 1
 
 
+# py 2-3 compat
+
+IS_PY2 = sys.version_info[0] == 2
+
+if IS_PY2:
+    def dict_iteritems(d):
+        return d.iteritems()
+    def dict_iterkeys(d):
+        return d.iterkeys()
+else:
+    def dict_iteritems(d):
+        return iter(d.items())
+    def dict_iterkeys(d):
+        return iter(d.keys())
+
+
 #
 #
 def main_except(log_fn):
diff --git a/tools/scraper/nicknamer.py b/tools/scraper/nicknamer.py
index 8cb732d..df0f9a0 100755
--- a/tools/scraper/nicknamer.py
+++ b/tools/scraper/nicknamer.py
@@ -21,12 +21,7 @@
 
 from collections import defaultdict
 import common
-import six
-
-if six.PY2:
-    from cgi import escape as html_escape
-else:
-    from html import escape as html_escape
+import cgi
 
 class ShortNames():
     '''
@@ -68,7 +63,7 @@ class ShortNames():
         if customer is not None:
             self.customer_dict[sname].append(customer)
         if show_popup:
-            return "<span title=\"" + html_escape(lname) + "\">" + sname + "</span>"
+            return "<span title=\"" + cgi.escape(lname) + "\">" + sname + "</span>"
         else:
             return sname
 
@@ -94,21 +89,21 @@ class ShortNames():
             lname = self.longnames[ int(sname[ (len(self.prefix) + 1): ])]
         except:
             raise ValueError("Short name '%s' did not translate to a long name" % (sname))
-        return "<span title=\"" + html_escape(lname) + sname + "</span>"
+        return "<span title=\"" + cgi.escape(lname) + sname + "</span>"
 
     def longname(self, idx, cgi_escape=False):
         '''
-        Get the html_escape'd long name
+        Get the cgi.escape'd long name
         :param idx:
         :param cgi_escape: true if caller wants the string for html display
         :return:
         '''
-        return html_escape(self.longnames[idx]) if cgi_escape else self.longnames[idx]
+        return cgi.escape(self.longnames[idx]) if cgi_escape else self.longnames[idx]
 
     def htmlDump(self, with_link=False):
         '''
         Print the name table as an unnumbered list to stdout
-        long names are html_escape'd
+        long names are cgi.escape'd
         :param with_link: true if link name link name is hyperlinked targeting itself
         :return: null
         '''
@@ -120,7 +115,7 @@ class ShortNames():
                 dump_anchor = "<a name=\"%s_dump\"></a>" % (name)
                 if with_link:
                     name = "<a href=\"#%s\">%s</a>" % (name, name)
-                print ("<li> " + dump_anchor + name + " - " + html_escape(self.longnames[i]) + "</li>")
+                print ("<li> " + dump_anchor + name + " - " + cgi.escape(self.longnames[i]) + "</li>")
             print ("</ul>")
 
     def sort_customers(self):
diff --git a/tools/scraper/scraper.py b/tools/scraper/scraper.py
index 8073b1f..360ebd2 100755
--- a/tools/scraper/scraper.py
+++ b/tools/scraper/scraper.py
@@ -35,8 +35,8 @@ from __future__ import print_function
 
 import argparse
 import ast
+import cgi
 import os
-import six
 import sys
 import traceback
 
@@ -48,11 +48,6 @@ import parser
 import router
 import text
 
-if six.PY2:
-    from cgi import escape as html_escape
-else:
-    from html import escape as html_escape
-
 
 def time_offset(ttest, t0):
     """
@@ -663,7 +658,7 @@ def main_except(argv):
               detailname)
         for key in sorted(common.dict_iterkeys(l_dict)):
             val = l_dict[key]
-            print("%s : %s <br>" % (key, html_escape(str(val))))
+            print("%s : %s <br>" % (key, cgi.escape(str(val))))
         if plf.data.name == "transfer":
             print("Header and annotations : %s <br>" % plf.data.transfer_hdr_annos)
         print("</div>")


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org