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/02 15:47:38 UTC
[qpid-dispatch] branch master updated: 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 ed1deb5 DISPATCH-1324: replace deprecated cgi.escape usage
ed1deb5 is described below
commit ed1deb5fd203c4ba7e562835cb2e09eb1d66384b
Author: Chuck Rolke <ch...@apache.org>
AuthorDate: Thu May 2 11:45:02 2019 -0400
DISPATCH-1324: replace deprecated cgi.escape usage
This patch includes a private escape function and does not import
any new modules.
---
tools/scraper/common.py | 11 ++++++++++-
tools/scraper/log_splitter.py | 13 ++++++-------
tools/scraper/nicknamer.py | 17 ++++++++---------
tools/scraper/scraper.py | 3 +--
4 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/tools/scraper/common.py b/tools/scraper/common.py
index c9ca18d..c33af2f 100755
--- a/tools/scraper/common.py
+++ b/tools/scraper/common.py
@@ -159,4 +159,13 @@ global_colors = {
}
def color_of(obj_type):
- return global_colors.get(obj_type, "pink")
\ No newline at end of file
+ return global_colors.get(obj_type, "pink")
+
+html_escape_table = {
+ "&": "&",
+ ">": ">",
+ "<": "<",
+}
+
+def html_escape(text):
+ return "".join(html_escape_table.get(c,c) for c in text)
diff --git a/tools/scraper/log_splitter.py b/tools/scraper/log_splitter.py
index c321093..d537872 100755
--- a/tools/scraper/log_splitter.py
+++ b/tools/scraper/log_splitter.py
@@ -29,7 +29,6 @@ from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
-import cgi
from datetime import *
import os
import sys
@@ -412,7 +411,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),
- cgi.escape(rc.peer_open)))
+ common.html_escape(rc.peer_open)))
print("</table>")
print("<hr>")
@@ -424,7 +423,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),
- cgi.escape(rc.peer_open)))
+ common.html_escape(rc.peer_open)))
print("</table>")
print("<hr>")
@@ -443,7 +442,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, cgi.escape(self.errors[i].strip())))
+ print("<tr><td>%d</td> <td>%s</td></tr>" % (i, common.html_escape(self.errors[i].strip())))
print("</table>")
print("<hr>")
@@ -482,7 +481,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, cgi.escape(rc.peer_open)))
+ rc.peer_type, common.html_escape(rc.peer_open)))
n += 1
print("</table>")
print("<hr>")
@@ -496,7 +495,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, cgi.escape(rc.peer_open)))
+ rc.peer_type, common.html_escape(rc.peer_open)))
n += 1
print("</table>")
print("<hr>")
@@ -509,7 +508,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, cgi.escape(rc.peer_open)))
+ rc.peer_type, common.html_escape(rc.peer_open)))
n += 1
print("</table>")
print("<hr>")
diff --git a/tools/scraper/nicknamer.py b/tools/scraper/nicknamer.py
index df0f9a0..35eb367 100755
--- a/tools/scraper/nicknamer.py
+++ b/tools/scraper/nicknamer.py
@@ -21,7 +21,6 @@
from collections import defaultdict
import common
-import cgi
class ShortNames():
'''
@@ -63,7 +62,7 @@ class ShortNames():
if customer is not None:
self.customer_dict[sname].append(customer)
if show_popup:
- return "<span title=\"" + cgi.escape(lname) + "\">" + sname + "</span>"
+ return "<span title=\"" + common.html_escape(lname) + "\">" + sname + "</span>"
else:
return sname
@@ -89,21 +88,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=\"" + cgi.escape(lname) + sname + "</span>"
+ return "<span title=\"" + common.html_escape(lname) + sname + "</span>"
- def longname(self, idx, cgi_escape=False):
+ def longname(self, idx, html_escape=False):
'''
- Get the cgi.escape'd long name
+ Get the common.html_escape'd long name
:param idx:
- :param cgi_escape: true if caller wants the string for html display
+ :param html_escape: true if caller wants the string for html display
:return:
'''
- return cgi.escape(self.longnames[idx]) if cgi_escape else self.longnames[idx]
+ return common.html_escape(self.longnames[idx]) if html_escape else self.longnames[idx]
def htmlDump(self, with_link=False):
'''
Print the name table as an unnumbered list to stdout
- long names are cgi.escape'd
+ long names are common.html_escape'd
:param with_link: true if link name link name is hyperlinked targeting itself
:return: null
'''
@@ -115,7 +114,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 + " - " + cgi.escape(self.longnames[i]) + "</li>")
+ print ("<li> " + dump_anchor + name + " - " + common.html_escape(self.longnames[i]) + "</li>")
print ("</ul>")
def sort_customers(self):
diff --git a/tools/scraper/scraper.py b/tools/scraper/scraper.py
index 360ebd2..a36ed74 100755
--- a/tools/scraper/scraper.py
+++ b/tools/scraper/scraper.py
@@ -35,7 +35,6 @@ from __future__ import print_function
import argparse
import ast
-import cgi
import os
import sys
import traceback
@@ -658,7 +657,7 @@ def main_except(argv):
detailname)
for key in sorted(common.dict_iterkeys(l_dict)):
val = l_dict[key]
- print("%s : %s <br>" % (key, cgi.escape(str(val))))
+ print("%s : %s <br>" % (key, common.html_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