diff options
author | cclauss <cclauss@me.com> | 2019-04-05 01:32:39 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2019-04-06 22:29:57 +0200 |
commit | aba1c515534197cab1588ab0f3a2343be1f0a8e5 (patch) | |
tree | 690eec7b2c4b0f5d4a770160f7e844467d318221 /tests/python_dependencies/impacket/uuid.py | |
parent | cd3edb08271a32a9c705f3c6e3364c1bdc8ac19f (diff) | |
download | curl-aba1c515534197cab1588ab0f3a2343be1f0a8e5.tar.gz |
tests: make Impacket (SMB server) Python 3 compatible
Closes #3731
Fixes #3289
Diffstat (limited to 'tests/python_dependencies/impacket/uuid.py')
-rw-r--r-- | tests/python_dependencies/impacket/uuid.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/tests/python_dependencies/impacket/uuid.py b/tests/python_dependencies/impacket/uuid.py index fb4d7b3a0..750eba459 100644 --- a/tests/python_dependencies/impacket/uuid.py +++ b/tests/python_dependencies/impacket/uuid.py @@ -17,9 +17,14 @@ import re from random import randrange from struct import pack, unpack +try: + long # Python 2 +except NameError: + long = int # Python 3 + def generate(): # UHm... crappy Python has an maximum integer of 2**31-1. - top = (1L<<31)-1 + top = (1<<31)-1 return pack("IIII", randrange(top), randrange(top), randrange(top), randrange(top)) def bin_to_string(uuid): @@ -49,16 +54,16 @@ def bin_to_uuidtup(bin): return uuidstr, "%d.%d" % (maj, min) #input: string -#output: tuple (uuid,version) +#output: tuple (uuid,version) #if version is not found in the input string "1.0" is returned -#example: -# "00000000-0000-0000-0000-000000000000 3.0" returns ('00000000-0000-0000-0000-000000000000','3.0') -# "10000000-2000-3000-4000-500000000000 version 3.0" returns ('00000000-0000-0000-0000-000000000000','3.0') -# "10000000-2000-3000-4000-500000000000 v 3.0" returns ('00000000-0000-0000-0000-000000000000','3.0') -# "10000000-2000-3000-4000-500000000000" returns ('00000000-0000-0000-0000-000000000000','1.0') +#example: +# "00000000-0000-0000-0000-000000000000 3.0" returns ('00000000-0000-0000-0000-000000000000','3.0') +# "10000000-2000-3000-4000-500000000000 version 3.0" returns ('00000000-0000-0000-0000-000000000000','3.0') +# "10000000-2000-3000-4000-500000000000 v 3.0" returns ('00000000-0000-0000-0000-000000000000','3.0') +# "10000000-2000-3000-4000-500000000000" returns ('00000000-0000-0000-0000-000000000000','1.0') def string_to_uuidtup(s): g = re.search("([A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}).*?([0-9]{1,5}\.[0-9]{1,5})",s+" 1.0") - if g: + if g: (u,v) = g.groups() return (u,v) return |