Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fail earlier if archive download failed
Simplify debugging this traceback (which was just an intermittent network error): https://github.com/galaxyproject/galaxy/actions/runs/12374234876/job/34536295999 ``` ______________________ ERROR at setup of test_build_index ______________________ cls = <class 'tarfile.TarFile'>, name = None, mode = 'r' fileobj = <gzip on 0x7f349cee7d00>, compresslevel = 9, kwargs = {} GzipFile = <class 'gzip.GzipFile'> @classmethod def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if mode not in ("r", "w", "x"): raise ValueError("mode must be 'r', 'w' or 'x'") try: from gzip import GzipFile except ImportError: raise CompressionError("gzip module is not available") try: fileobj = GzipFile(name, mode + "b", compresslevel, fileobj) except OSError: if fileobj is not None and mode == 'r': raise ReadError("not a gzip file") raise try: > t = cls.taropen(name, mode, fileobj, **kwargs) /opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/tarfile.py:1854: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/tarfile.py:1831: in taropen return cls(name, mode, fileobj, **kwargs) /opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/tarfile.py:1694: in __init__ self.firstmember = self.next() /opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/tarfile.py:2578: in next tarinfo = self.tarinfo.fromtarfile(self) /opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/tarfile.py:1282: in fromtarfile buf = tarfile.fileobj.read(BLOCKSIZE) /opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/gzip.py:292: in read return self._buffer.read(size) /opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/_compression.py:68: in readinto data = self.read(len(byte_view)) /opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/gzip.py:479: in read if not self._read_gzip_header(): _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <gzip._GzipReader object at 0x7f349cee79a0> def _read_gzip_header(self): magic = self._fp.read(2) if magic == b'': return False if magic != b'\037\213': > raise BadGzipFile('Not a gzipped file (%r)' % magic) E gzip.BadGzipFile: Not a gzipped file (b'<!') /opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/gzip.py:427: BadGzipFile During handling of the above exception, another exception occurred: @pytest.fixture(scope="module") def community_file_dir(): extracted_archive_dir = tempfile.mkdtemp() b = BytesIO(requests.get(URL).content) > tarfile.open(fileobj=b, mode="r:gz").extractall(extracted_archive_dir) test/unit/tool_shed/test_shed_index.py:30: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/tarfile.py:1801: in open return func(name, filemode, fileobj, **kwargs) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ cls = <class 'tarfile.TarFile'>, name = None, mode = 'r' fileobj = <gzip on 0x7f349cee7d00>, compresslevel = 9, kwargs = {} GzipFile = <class 'gzip.GzipFile'> @classmethod def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if mode not in ("r", "w", "x"): raise ValueError("mode must be 'r', 'w' or 'x'") try: from gzip import GzipFile except ImportError: raise CompressionError("gzip module is not available") try: fileobj = GzipFile(name, mode + "b", compresslevel, fileobj) except OSError: if fileobj is not None and mode == 'r': raise ReadError("not a gzip file") raise try: t = cls.taropen(name, mode, fileobj, **kwargs) except OSError: fileobj.close() if mode == 'r': > raise ReadError("not a gzip file") E tarfile.ReadError: not a gzip file /opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/tarfile.py:1858: ReadError ------------------------------ Captured log setup ------------------------------ DEBUG urllib3.connectionpool:connectionpool.py:1022 Starting new HTTPS connection (1): github.com:443 DEBUG urllib3.connectionpool:connectionpool.py:475 https://github.com:443 "GET /mvdbeek/toolshed-test-data/blob/master/toolshed_community_files.tgz?raw=true HTTP/1.1" 503 54894 ```
- Loading branch information