Skip to content

Commit

Permalink
Merge pull request #119 from puremourning/drop-py2
Browse files Browse the repository at this point in the history
Drop python 2 support in installer
  • Loading branch information
mergify[bot] committed Feb 15, 2020
2 parents 79df51e + 6b735ce commit 86afe89
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions install_gadget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# vimspector - A multi-language debugging system for Vim
# Copyright 2019 Ben Jackson
Expand All @@ -15,11 +15,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

try:
import urllib.request as urllib2
except ImportError:
import urllib2
import sys

if sys.version_info.major < 3:
exit( "Sorry, you need to be running this script with python3 or later" )

from urllib import request
import argparse
import contextlib
import os
Expand All @@ -31,16 +32,11 @@
import traceback
import tarfile
import hashlib
import sys
import json
import functools
import time
import ssl

try:
from io import BytesIO # for Python 3
except ImportError:
from BytesIO import BytesIO
import io

# Include vimspector source, for utils
sys.path.insert( 1, os.path.join( os.path.dirname( __file__ ),
Expand Down Expand Up @@ -522,7 +518,7 @@ def wrapper( *args, **kwargs ):

@WithRetry
def UrlOpen( *args, **kwargs ):
return urllib2.urlopen( *args, **kwargs )
return request.urlopen( *args, **kwargs )


def DownloadFileTo( url,
Expand Down Expand Up @@ -550,7 +546,7 @@ def DownloadFileTo( url,
print( "Removing existing {}".format( file_path ) )
os.remove( file_path )

r = urllib2.Request( url, headers = { 'User-Agent': 'Vimspector' } )
r = request.Request( url, headers = { 'User-Agent': 'Vimspector' } )

print( "Downloading {} to {}/{}".format( url, destination, file_name ) )

Expand Down Expand Up @@ -627,7 +623,7 @@ def ExtractZipTo( file_path, destination, format ):
with gzip.open( file_path, 'rb' ) as f:
file_contents = f.read()

with ModePreservingZipFile( BytesIO( file_contents ) ) as f:
with ModePreservingZipFile( io.BytesIO( file_contents ) ) as f:
f.extractall( path = destination )

elif format == 'tar':
Expand Down

0 comments on commit 86afe89

Please sign in to comment.