tools: Switch some scripts exclusively to Python 3.

Convert asn2wrs.py to Python 3 via `2to3 --print-function --write` along
with additional tweaks.

Convert asn2deb and idl2deb using `2to3 --write`.

Work around what appears to be a Debian packaging bug:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=818609

Change-Id: I5cc246f7162c2d713673955c10c092e1b91adf82
Reviewed-on: https://code.wireshark.org/review/33504
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Gerald Combs 2019-06-05 13:06:02 -07:00 committed by Anders Broman
parent 14553ee358
commit 20568aa8b9
4 changed files with 20 additions and 16 deletions

2
debian/control vendored
View File

@ -84,7 +84,7 @@ Package: wireshark-dev
Architecture: any
Section: devel
Depends: ${misc:Depends}, omniidl (>= 4.0.1-2), libpcap0.8-dev, libtool,
libglib2.0-dev, ${python3:Depends}, python3-ply, snacc, debhelper,
libglib2.0-dev, python3:any, python3-ply, snacc, debhelper,
cdbs, libwireshark-dev, libwiretap-dev
Replaces: ethereal-dev (<< 1.0.0-3)
Conflicts: ethereal-dev (<< 1.0.0-3)

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# asn2deb - quick hack by W. Borgert <debacle@debian.org> to create
# Debian GNU/Linux packages from ASN.1 files for Wireshark.
@ -54,7 +54,7 @@ PREFIX=`pwd`/debian/wireshark-asn1-%s
binary-post-install/wireshark-asn1-%s::
rm -f $(PREFIX)/usr/lib/wireshark/plugins/%s/*.a
""" % (base, base, version), 0755)
""" % (base, base, version), 0o755)
create_file("debian/control", """Source: wireshark-asn1-%s
Section: net
@ -152,18 +152,18 @@ def process_opts(argv):
usage(argv[0])
sys.exit(0)
if options['version']:
print scriptinfo
print(scriptinfo)
sys.exit(0)
if not options['asn']:
print "mandatory ASN.1 file parameter missing"
print("mandatory ASN.1 file parameter missing")
sys.exit(1)
if not os.access(options['asn'], os.R_OK):
print "ASN.1 file not accessible"
print("ASN.1 file not accessible")
sys.exit(1)
def usage(name):
"""Print usage help."""
print "Usage: " + name + " <parameters>\n" + \
print("Usage: " + name + " <parameters>\n" + \
"Parameters are\n" + \
" --asn -a asn1file, ASN.1 file to use (mandatory)\n" + \
" --dbopts -d opts, options for dpkg-buildpackage\n" + \
@ -174,6 +174,6 @@ def usage(name):
" --version -v, print version and exit\n" + \
"Example:\n" + \
name + " -e me@foo.net -a bar.asn1 -n \"My Name\" " + \
"-d \"-rfakeroot -uc -us\""
"-d \"-rfakeroot -uc -us\"")
if __name__ == '__main__':
main()

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# asn2wrs.py
@ -2034,10 +2034,10 @@ class EthCtx:
for a in self.assign_ord:
v = ' '
if (self.assign[a]['virt']): v = '*'
print(v, a)
print('{} {}'.format(v, a))
print("\n# Value assignments")
for a in self.vassign_ord:
print(' ', a)
print(' {}'.format(a))
print("\n# Information object assignments")
for a in self.oassign_ord:
print(" %-12s (%s)" % (a, self.oassign[a].cls))
@ -8068,10 +8068,14 @@ def eth_main():
# Python compiler
def main():
if sys.version_info[0] < 3:
print("This requires Python 3")
sys.exit(2)
testfn = testyacc
if len (sys.argv) == 1:
while True:
s = input ('Query: ')
s = eval(input ('Query: '))
if len (s) == 0:
break
testfn (s, 'console', {})

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# idl2deb - quick hack by W. Martin Borgert <debacle@debian.org> to create
# Debian GNU/Linux packages from idl2wrs modules for Wireshark.
@ -46,7 +46,7 @@ PREFIX=`pwd`/debian/wireshark-giop-%s
binary-post-install/wireshark-giop-%s::
rm -f $(PREFIX)/usr/lib/wireshark/plugins/%s/*.a
""" % (base, base, version), 0755)
""" % (base, base, version), 0o755)
create_file(preserve, "debian/control", """Source: wireshark-giop-%s
Section: net
@ -130,10 +130,10 @@ def process_opts(argv):
help="do not overwrite files")
opts, args = parser.parse_args()
if not opts.idl:
print "mandatory IDL file parameter missing"
print("mandatory IDL file parameter missing")
sys.exit(1)
if not os.access(opts.idl, os.R_OK):
print "IDL file not accessible"
print("IDL file not accessible")
sys.exit(1)
return opts