aboutsummaryrefslogtreecommitdiffstats
path: root/tools/make-services.py
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2019-04-22 10:10:02 -0700
committerGerald Combs <gerald@wireshark.org>2019-04-22 18:41:35 +0000
commit83b2f1bca578360712005ec22bf020ba523fd3b0 (patch)
tree045dcc8737b239da39e9336554c71d2570d37b86 /tools/make-services.py
parent6f31151f07e691553e93266af8d0f8c0a4c0c668 (diff)
Tools: Make a couple of scripts Python 3-only.
Remove Python 2 support from make-services.py and update-tools-help.py. Change-Id: I1304038ca07d1d7354795f7b7faacd3747313653 Reviewed-on: https://code.wireshark.org/review/32943 Reviewed-by: Guy Harris <guy@alum.mit.edu> Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'tools/make-services.py')
-rwxr-xr-xtools/make-services.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/tools/make-services.py b/tools/make-services.py
index 24562ffbd4..558f9bf6c4 100755
--- a/tools/make-services.py
+++ b/tools/make-services.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Parses the CSV version of the IANA Service Name and Transport Protocol Port Number Registry
# and generates a services(5) file.
@@ -24,12 +24,8 @@ import csv
import re
import collections
-python_version = sys.hexversion >> 16
-if python_version < 0x300:
- import urllib
-else:
- import urllib.request, urllib.error, urllib.parse
- import codecs
+import urllib.request, urllib.error, urllib.parse
+import codecs
services_file = 'services'
@@ -64,10 +60,7 @@ def parse_rows(svc_fd):
count = 0
# Header positions as of 2013-08-06
- if python_version < 0x206:
- headers = port_reader.next()
- else:
- headers = next(port_reader)
+ headers = next(port_reader)
try:
sn_pos = headers.index('Service Name')
@@ -97,7 +90,7 @@ def parse_rows(svc_fd):
if len(service) < 1 or not port or len(proto) < 1:
continue
-
+
if re.search('|'.join(exclude_services), service):
continue
@@ -160,6 +153,10 @@ def exit_msg(msg=None, status=1):
sys.exit(status)
def main(argv):
+ if sys.version_info[0] < 3:
+ print("This requires Python 3")
+ sys.exit(2)
+
try:
opts, args = getopt.getopt(argv, "h", ["help"])
except getopt.GetoptError:
@@ -176,8 +173,6 @@ def main(argv):
try:
if not svc_url.startswith('http'):
svc_fd = open(svc_url)
- elif python_version < 0x300:
- svc_fd = urllib.urlopen(svc_url)
else:
req = urllib.request.urlopen(svc_url)
svc_fd = codecs.getreader('utf8')(req)