diff options
author | Gerald Combs <gerald@wireshark.org> | 2013-08-02 02:09:11 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2013-08-02 02:09:11 +0000 |
commit | 9bf533c9dbf3610100044e4ef9b00cd4e494523f (patch) | |
tree | 14c411c723a875fdbf54ae3d399856e2f3f3f9ad /tools/make-usb.py | |
parent | c4e966b8805f8b681e272c00e2bbd955575c0bbf (diff) |
Make sure we're compatible with Python 2 + 3. Tested with Pythons 2.5,
2.6, 2.7, and 3.3.
svn path=/trunk/; revision=51113
Diffstat (limited to 'tools/make-usb.py')
-rwxr-xr-x | tools/make-usb.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/make-usb.py b/tools/make-usb.py index 28fc31d985..ccfd745c70 100755 --- a/tools/make-usb.py +++ b/tools/make-usb.py @@ -10,7 +10,12 @@ # It also uses the values culled out of libgphoto2 using usb-ptp-extract-models.pl import re -import urllib +import sys + +if sys.version_info[0] < 3: + import urllib +else: + import urllib.request, urllib.error, urllib.parse MODE_IDLE = 0 MODE_VENDOR_PRODUCT = 1 @@ -19,7 +24,10 @@ MODE_VENDOR_PRODUCT = 1 mode = MODE_IDLE # Grab from linux-usb.org -response = urllib.urlopen('http://www.linux-usb.org/usb.ids') +if sys.version_info[0] < 3: + response = urllib.urlopen('http://www.linux-usb.org/usb.ids') +else: + response = urllib.request.urlopen('http://www.linux-usb.org/usb.ids') lines = response.read().splitlines() vendors = dict() |