build: remove explicit PY2/PY3 references. (#10664)

Now that we are Python 3 everywhere, remove explicit python_versions. I haven't made this change yet
to the Thrift extension, as it has explicit PY2/PY3 overrides that I'm guessing relate to external
libs.

Risk level: Low (tooling only)
Testing: bazel.api

Signed-off-by: Harvey Tuch <htuch@google.com>

Mirrored from https://github.com/envoyproxy/envoy @ 197f6b1cebbd49a591b916ece168d7e984c87a15
master-ci-test
data-plane-api(CircleCI) 5 years ago
parent 9b99c017bd
commit 1b5c43b848
  1. 2
      tools/BUILD
  2. 8
      tools/tap2pcap.py
  3. 2
      tools/tap2pcap_test.py

@ -4,7 +4,6 @@ py_binary(
name = "tap2pcap", name = "tap2pcap",
srcs = ["tap2pcap.py"], srcs = ["tap2pcap.py"],
licenses = ["notice"], # Apache 2 licenses = ["notice"], # Apache 2
python_version = "PY2",
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = ["//envoy/data/tap/v2alpha:pkg_py_proto"], deps = ["//envoy/data/tap/v2alpha:pkg_py_proto"],
) )
@ -16,7 +15,6 @@ py_test(
"data/tap2pcap_h2_ipv4.pb_text", "data/tap2pcap_h2_ipv4.pb_text",
"data/tap2pcap_h2_ipv4.txt", "data/tap2pcap_h2_ipv4.txt",
], ],
python_version = "PY2",
# Don't run this by default, since we don't want to force local dependency on Wireshark/tshark, # Don't run this by default, since we don't want to force local dependency on Wireshark/tshark,
# will explicitly invoke in CI. # will explicitly invoke in CI.
tags = ["manual"], tags = ["manual"],

@ -20,8 +20,8 @@ TODO(htuch):
from __future__ import print_function from __future__ import print_function
import datetime import datetime
import io
import socket import socket
import StringIO
import subprocess as sp import subprocess as sp
import sys import sys
import time import time
@ -32,14 +32,14 @@ from envoy.data.tap.v2alpha import wrapper_pb2
def DumpEvent(direction, timestamp, data): def DumpEvent(direction, timestamp, data):
dump = StringIO.StringIO() dump = io.StringIO()
dump.write('%s\n' % direction) dump.write('%s\n' % direction)
# Adjust to local timezone # Adjust to local timezone
adjusted_dt = timestamp.ToDatetime() - datetime.timedelta(seconds=time.altzone) adjusted_dt = timestamp.ToDatetime() - datetime.timedelta(seconds=time.altzone)
dump.write('%s\n' % adjusted_dt) dump.write('%s\n' % adjusted_dt)
od = sp.Popen(['od', '-Ax', '-tx1', '-v'], stdout=sp.PIPE, stdin=sp.PIPE, stderr=sp.PIPE) od = sp.Popen(['od', '-Ax', '-tx1', '-v'], stdout=sp.PIPE, stdin=sp.PIPE, stderr=sp.PIPE)
packet_dump = od.communicate(data)[0] packet_dump = od.communicate(data)[0]
dump.write(packet_dump) dump.write(packet_dump.decode())
return dump.getvalue() return dump.getvalue()
@ -78,7 +78,7 @@ def Tap2Pcap(tap_path, pcap_path):
'%d,%d' % (remote_port, local_port), '-', pcap_path '%d,%d' % (remote_port, local_port), '-', pcap_path
] ]
text2pcap = sp.Popen(text2pcap_args, stdout=sp.PIPE, stdin=sp.PIPE) text2pcap = sp.Popen(text2pcap_args, stdout=sp.PIPE, stdin=sp.PIPE)
text2pcap.communicate('\n'.join(dumps)) text2pcap.communicate('\n'.join(dumps).encode())
if __name__ == '__main__': if __name__ == '__main__':

@ -18,7 +18,7 @@ if __name__ == '__main__':
tap2pcap.Tap2Pcap(tap_path, pcap_path) tap2pcap.Tap2Pcap(tap_path, pcap_path)
actual_output = sp.check_output(['tshark', '-r', pcap_path, '-d', 'tcp.port==10000,http2', '-P']) actual_output = sp.check_output(['tshark', '-r', pcap_path, '-d', 'tcp.port==10000,http2', '-P'])
with open(expected_path, 'r') as f: with open(expected_path, 'rb') as f:
expected_output = f.read() expected_output = f.read()
if actual_output != expected_output: if actual_output != expected_output:
print('Mismatch') print('Mismatch')

Loading…
Cancel
Save