]> git.phdru.name Git - sqlconvert.git/commitdiff
Upgrade ez_setup.py
authorOleg Broytman <phd@phdru.name>
Wed, 23 Nov 2016 17:01:07 +0000 (20:01 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 23 Nov 2016 17:01:07 +0000 (20:01 +0300)
ez_setup.py

index 4ef3ee0177c730d3ea5e19c1d8592a9d623ef6c6..950e120d2f1eac038342c9e5fd42c03ca1941851 100644 (file)
@@ -40,6 +40,8 @@ DEFAULT_VERSION = LATEST
 DEFAULT_URL = "https://pypi.io/packages/source/s/setuptools/"
 DEFAULT_SAVE_DIR = os.curdir
 
+MEANINGFUL_INVALID_ZIP_ERR_MSG = 'Maybe {0} is corrupted, delete it and try again.'
+
 
 def _python_cmd(*args):
     """
@@ -104,8 +106,16 @@ def archive_context(filename):
     old_wd = os.getcwd()
     try:
         os.chdir(tmpdir)
-        with ContextualZipFile(filename) as archive:
-            archive.extractall()
+        try:
+            with ContextualZipFile(filename) as archive:
+                archive.extractall()
+        except zipfile.BadZipfile as err:
+            if not err.args:
+                err.args = ('', )
+            err.args = err.args + (
+                MEANINGFUL_INVALID_ZIP_ERR_MSG.format(filename),
+            )
+            raise
 
         # going in the directory
         subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])