Tools+test: Call python3 explicitly.

PEP 394[1] says,

"In cases where the script is expected to be executed outside virtual
 environments, developers will need to be aware of the following
 discrepancies across platforms and installation methods:

  * Older Linux distributions will provide a python command that refers
    to Python 2, and will likely not provide a python2 command.

  * Some newer Linux distributions will provide a python command that
    refers to Python 3.

  * Some Linux distributions will not provide a python command at all by
    default, but will provide a python3 command by default."

Debian has forced the issue by choosing the third option[2]:

"NOTE: Debian testing (bullseye) has removed the "python" package and
 the '/usr/bin/python' symlink due to the deprecation of Python 2."

Switch our shebang from "#!/usr/bin/env python" to "#!/usr/bin/env
python3" in some places. Remove some 2/3 version checks if we know we're
running under Python 3. Remove the "coding: utf-8" in a bunch of places
since that's the default in Python 3.

[1]https://www.python.org/dev/peps/pep-0394/#for-python-script-publishers
[2]https://wiki.debian.org/Python
This commit is contained in:
Gerald Combs 2020-11-03 11:22:14 -08:00 committed by Wireshark GitLab Utility
parent ebfa1f8a4b
commit 30c392f166
41 changed files with 20 additions and 84 deletions

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# #
# Copyright (c) 2018 Peter Wu <peter@lekensteyn.nl> # Copyright (c) 2018 Peter Wu <peter@lekensteyn.nl>

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Extends unittest with support for pytest-style fixtures. # Extends unittest with support for pytest-style fixtures.
# #
# Copyright (c) 2018 Peter Wu <peter@lekensteyn.nl> # Copyright (c) 2018 Peter Wu <peter@lekensteyn.nl>

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# #
# Copyright (c) 2018 Peter Wu <peter@lekensteyn.nl> # Copyright (c) 2018 Peter Wu <peter@lekensteyn.nl>

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# #
# Copyright (c) 2018 Peter Wu <peter@lekensteyn.nl> # Copyright (c) 2018 Peter Wu <peter@lekensteyn.nl>

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# By Gerald Combs <gerald@wireshark.org> # By Gerald Combs <gerald@wireshark.org>
# #

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# By Gerald Combs <gerald@wireshark.org> # By Gerald Combs <gerald@wireshark.org>
# #

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# By Gerald Combs <gerald@wireshark.org> # By Gerald Combs <gerald@wireshark.org>
# #

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# By Gerald Combs <gerald@wireshark.org> # By Gerald Combs <gerald@wireshark.org>
# #

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2013 by Gilbert Ramirez <gram@alumni.rice.edu> # Copyright (c) 2013 by Gilbert Ramirez <gram@alumni.rice.edu>
# -*- coding: utf-8 -*-
# #
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# By Gerald Combs <gerald@wireshark.org> # By Gerald Combs <gerald@wireshark.org>
# #

View File

@ -1,5 +1,3 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# #
# Wireshark dissector tests # Wireshark dissector tests
# By Atli Guðmundsson <atli@tern.is> # By Atli Guðmundsson <atli@tern.is>

View File

@ -1,5 +1,3 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# #
# Wireshark ASTERIX dissector tests # Wireshark ASTERIX dissector tests
# By Atli Guðmundsson <atli@tern.is> # By Atli Guðmundsson <atli@tern.is>

View File

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*- #
# Wireshark tests # Wireshark tests
# By Gerald Combs <gerald@wireshark.org> # By Gerald Combs <gerald@wireshark.org>
# #

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# By Gerald Combs <gerald@wireshark.org> # By Gerald Combs <gerald@wireshark.org>
# #

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# #
# Copyright (c) 2018 Peter Wu <peter@lekensteyn.nl> # Copyright (c) 2018 Peter Wu <peter@lekensteyn.nl>

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# By Gerald Combs <gerald@wireshark.org> # By Gerald Combs <gerald@wireshark.org>
# #

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# By Gerald Combs <gerald@wireshark.org> # By Gerald Combs <gerald@wireshark.org>
# #

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# By Gerald Combs <gerald@wireshark.org> # By Gerald Combs <gerald@wireshark.org>
# #

View File

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*- #
# Wireshark tests # Wireshark tests
# By Gerald Combs <gerald@wireshark.org> # By Gerald Combs <gerald@wireshark.org>
# #

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# #
# Copyright (c) 2019 Gerald Combs <gerald@wireshark.org> # Copyright (c) 2019 Gerald Combs <gerald@wireshark.org>

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# By Gerald Combs <gerald@wireshark.org> # By Gerald Combs <gerald@wireshark.org>
# #
@ -459,4 +458,4 @@ class case_sharkd(subprocesstest.SubprocessTestCase):
), ( ), (
{"err": 0}, {"err": 0},
MatchAny(), MatchAny(),
)) ))

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# By Gerald Combs <gerald@wireshark.org> # By Gerald Combs <gerald@wireshark.org>
# #

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# By # By
# Gerald Combs <gerald@wireshark.org> # Gerald Combs <gerald@wireshark.org>

View File

@ -1,5 +1,4 @@
# #
# -*- coding: utf-8 -*-
# Wireshark tests # Wireshark tests
# By Gerald Combs <gerald@wireshark.org> # By Gerald Combs <gerald@wireshark.org>
# #

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# #
# Wireshark tests # Wireshark tests
# By Gerald Combs <gerald@wireshark.org> # By Gerald Combs <gerald@wireshark.org>
@ -38,10 +37,6 @@ def find_test_ids(suite, all_ids):
all_ids.append(suite.id()) all_ids.append(suite.id())
def main(): def main():
if sys.version_info[0] < 3:
print("Unit tests require Python 3")
sys.exit(2)
parser = argparse.ArgumentParser(description='Wireshark unit tests') parser = argparse.ArgumentParser(description='Wireshark unit tests')
cap_group = parser.add_mutually_exclusive_group() cap_group = parser.add_mutually_exclusive_group()
cap_group.add_argument('-E', '--disable-capture', action='store_true', help='Disable capture tests') cap_group.add_argument('-E', '--disable-capture', action='store_true', help='Disable capture tests')

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (c) 2013 The Chromium Authors. All rights reserved. # Copyright (c) 2013 The Chromium Authors. All rights reserved.
# #
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
@ -186,9 +186,8 @@ def check_licenses(options, args):
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE) stderr=subprocess.PIPE)
stdout, stderr = licensecheck.communicate() stdout, stderr = licensecheck.communicate()
if sys.version_info[0] >= 3: stdout = stdout.decode('utf-8')
stdout = stdout.decode('utf-8') stderr = stderr.decode('utf-8')
stderr = stderr.decode('utf-8')
if options.verbose: if options.verbose:
print('----------- licensecheck stdout -----------') print('----------- licensecheck stdout -----------')
print(stdout) print(stdout)

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/python3
# Martin Mathieson # Martin Mathieson
# Look for and removes unnecessary includes in .cpp or .c files # Look for and removes unnecessary includes in .cpp or .c files

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# #
# Copyright 2019, Dario Lombardo <lomato@gmail.com> # Copyright 2019, Dario Lombardo <lomato@gmail.com>
# #

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Parses the nl80211.h interface and generate appropriate enums and fields # Parses the nl80211.h interface and generate appropriate enums and fields
# (value_string) for packet-netlink-nl80211.c # (value_string) for packet-netlink-nl80211.c
# #

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# #
# html2text.py - converts HTML to text # html2text.py - converts HTML to text
# #
@ -68,8 +67,7 @@ class TextHTMLParser(HTMLParser):
'initial_indent': initial_indent, 'initial_indent': initial_indent,
'subsequent_indent': indent 'subsequent_indent': indent
} }
if sys.version_info[0:2] >= (2, 6): kwargs['break_on_hyphens'] = False
kwargs['break_on_hyphens'] = False
wrapper = TextWrapper(**kwargs) wrapper = TextWrapper(**kwargs)
return '\n'.join(wrapper.wrap(text)) return '\n'.join(wrapper.wrap(text))

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# #
# Tool to index protocols that appears in the given capture files # Tool to index protocols that appears in the given capture files
# #
@ -29,8 +29,7 @@ def extract_protos_from_file_proces(tshark, file):
cmd = [tshark, "-Tfields", "-e", "frame.protocols", "-r", file] cmd = [tshark, "-Tfields", "-e", "frame.protocols", "-r", file]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate() (stdout, stderr) = p.communicate()
if sys.version_info[0] >= 3: stdout = stdout.decode('utf-8')
stdout = stdout.decode('utf-8')
if p.returncode != 0: if p.returncode != 0:
return (file, {}) return (file, {})

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# #
# Copyright 2020, Martin Kacer <kacer.martin[AT]gmail.com> and contributors # Copyright 2020, Martin Kacer <kacer.martin[AT]gmail.com> and contributors
@ -25,12 +24,6 @@ import re
from collections import OrderedDict from collections import OrderedDict
from scapy import all as scapy from scapy import all as scapy
try:
# Python 2 forward compatibility
range = xrange
except NameError:
pass
# Field anonymization class # Field anonymization class
class AnonymizedField: class AnonymizedField:
''' '''
@ -159,12 +152,6 @@ import subprocess
from collections import OrderedDict from collections import OrderedDict
from scapy import all as scapy from scapy import all as scapy
try:
# Python 2 forward compatibility
range = xrange
except NameError:
pass
# ***************************************************** # *****************************************************
# * PACKET PAYLOAD GENERATED FROM INPUT PCAP * # * PACKET PAYLOAD GENERATED FROM INPUT PCAP *
# * Modify this function to edit the packet * # * Modify this function to edit the packet *

View File

@ -179,10 +179,6 @@ def prefix_to_oui(prefix):
return '{}/{:d}'.format(oui, int(pfx_len)) return '{}/{:d}'.format(oui, int(pfx_len))
def main(): def main():
if sys.version_info[0] < 3:
print("This requires Python 3")
sys.exit(2)
this_dir = os.path.dirname(__file__) this_dir = os.path.dirname(__file__)
template_path = os.path.join(this_dir, '..', 'manuf.tmpl') template_path = os.path.join(this_dir, '..', 'manuf.tmpl')
manuf_path = os.path.join(this_dir, '..', 'manuf') manuf_path = os.path.join(this_dir, '..', 'manuf')

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# #
# Generate preferences for a "No Reassembly" profile. # Generate preferences for a "No Reassembly" profile.
# By Gerald Combs <gerald@wireshark.org> # By Gerald Combs <gerald@wireshark.org>
@ -15,10 +14,6 @@ import subprocess
import sys import sys
def main(): def main():
if sys.version_info[0] < 3:
print("This requires Python 3")
sys.exit(2)
parser = argparse.ArgumentParser(description='No reassembly profile generator') parser = argparse.ArgumentParser(description='No reassembly profile generator')
parser.add_argument('-p', '--program-path', default=os.path.curdir, help='Path to TShark.') parser.add_argument('-p', '--program-path', default=os.path.curdir, help='Path to TShark.')
parser.add_argument('-v', '--verbose', action='store_const', const=True, default=False, help='Verbose output.') parser.add_argument('-v', '--verbose', action='store_const', const=True, default=False, help='Verbose output.')

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# #
# Looks for registration routines in the plugins # Looks for registration routines in the plugins
# and assembles C code to call all the routines. # and assembles C code to call all the routines.

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# #
# Looks for registration routines in the source files # Looks for registration routines in the source files
# and assembles C code to call all the routines. # and assembles C code to call all the routines.

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# #
# make-usb - Creates a file containing vendor and product ids. # make-usb - Creates a file containing vendor and product ids.
# It use the databases from # It use the databases from
@ -19,10 +18,6 @@ MIN_PRODUCTS = 15000 # 15415 as of 2015-06-28
mode = MODE_IDLE mode = MODE_IDLE
if sys.version_info[0] < 3:
print("This requires Python 3")
sys.exit(2)
# Grab from linux-usb.org # Grab from linux-usb.org
req_headers = { 'User-Agent': 'Wireshark make-usb' } req_headers = { 'User-Agent': 'Wireshark make-usb' }
req = urllib.request.Request('https://usb-ids.gowdy.us/usb.ids', headers=req_headers) req = urllib.request.Request('https://usb-ids.gowdy.us/usb.ids', headers=req_headers)

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
""" """
Creates C code from a table of NCP type 0x2222 packet types. Creates C code from a table of NCP type 0x2222 packet types.

View File

@ -1,4 +1,4 @@
#!/bin/env python #!/bin/env python3
# #
# Wireshark - Network traffic analyzer # Wireshark - Network traffic analyzer
# By Gerald Combs <gerald@wireshark.org> # By Gerald Combs <gerald@wireshark.org>

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# #
# rdps.py # rdps.py
# #

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# #
# update-tools-help.py - Update the command line help output in docbook/wsug_src. # update-tools-help.py - Update the command line help output in docbook/wsug_src.
# #
@ -24,10 +23,6 @@ import subprocess
import sys import sys
def main(): def main():
if sys.version_info[0] < 3:
print("This requires Python 3")
sys.exit(2)
parser = argparse.ArgumentParser(description='Update Wireshark tools help') parser = argparse.ArgumentParser(description='Update Wireshark tools help')
parser.add_argument('-p', '--program-path', nargs=1, default=os.path.curdir, help='Path to Wireshark executables.') parser.add_argument('-p', '--program-path', nargs=1, default=os.path.curdir, help='Path to Wireshark executables.')
args = parser.parse_args() args = parser.parse_args()