Git Product home page Git Product logo

Comments (10)

cobalt2727 avatar cobalt2727 commented on September 25, 2024 1

Would just throwing an error message informing the user what's missing if it's not available be an acceptable workaround?

from lastversion.

dvershinin avatar dvershinin commented on September 25, 2024 1

@vogler unzip is just an alias to extract. While not solved the issue with zip files stripping, I realize, OS X bundles should not be stripped. You can check with latest master again.

from lastversion.

dvershinin avatar dvershinin commented on September 25, 2024 1

@vogler Fixed in lastversion v3.5.0

from lastversion.

dvershinin avatar dvershinin commented on September 25, 2024

This would require the py7zr library, which I'm hesitant to add because it's missing RPM packages in major distros..

from lastversion.

vogler avatar vogler commented on September 25, 2024

I have the same problem also with .zip files:

$ brew install pipx
$ pipx install lastversion
$ lastversion --assets download SamusAranX/MinimalMIDIPlayer
Downloaded MinimalMIDIPlayer-v1.13.zip: : 7368.0KB [00:00, 10763.89KB/s]
$ unzip MinimalMIDIPlayer-v1.13.zip
Archive:  MinimalMIDIPlayer-v1.13.zip
   creating: MinimalMIDIPlayer.app/
...
$ rm -rf MinimalMIDIPlayer*

$ lastversion --assets unzip SamusAranX/MinimalMIDIPlayer
MinimalMIDIPlayer-v1.13.zip: 7368.0KB [00:00, 10887.83KB/s]
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/[email protected]/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/tarfile.py", line 1876, in gzopen
    t = cls.taropen(name, mode, fileobj, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/tarfile.py", line 1853, in taropen
    return cls(name, mode, fileobj, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/tarfile.py", line 1711, in __init__
    self.firstmember = self.next()
                       ^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/tarfile.py", line 2635, in next
    raise e
  File "/opt/homebrew/Cellar/[email protected]/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/tarfile.py", line 2608, in next
    tarinfo = self.tarinfo.fromtarfile(self)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/tarfile.py", line 1293, in fromtarfile
    buf = tarfile.fileobj.read(BLOCKSIZE)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/gzip.py", line 324, in read
    return self._buffer.read(size)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/_compression.py", line 68, in readinto
    data = self.read(len(byte_view))
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/gzip.py", line 527, in read
    if not self._read_gzip_header():
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/gzip.py", line 496, in _read_gzip_header
    last_mtime = _read_gzip_header(self._fp)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/gzip.py", line 456, in _read_gzip_header
    raise BadGzipFile('Not a gzipped file (%r)' % magic)
gzip.BadGzipFile: Not a gzipped file (b'PK')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/voglerr/.local/bin/lastversion", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/voglerr/Library/Application Support/pipx/venvs/lastversion/lib/python3.12/site-packages/lastversion/lastversion.py", line 890, in main
    extract_file(url)
  File "/Users/voglerr/Library/Application Support/pipx/venvs/lastversion/lib/python3.12/site-packages/lastversion/utils.py", line 415, in extract_file
    extract_tar(buffer, mode)
  File "/Users/voglerr/Library/Application Support/pipx/venvs/lastversion/lib/python3.12/site-packages/lastversion/utils.py", line 358, in extract_tar
    with tarfile.open(fileobj=buffer, mode=mode) as tar_file:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/tarfile.py", line 1821, in open
    return func(name, filemode, fileobj, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/tarfile.py", line 1880, in gzopen
    raise ReadError("not a gzip file") from e
tarfile.ReadError: not a gzip file

from lastversion.

vogler avatar vogler commented on September 25, 2024

Also, what's the difference between extract and unzip?

from lastversion.

vogler avatar vogler commented on September 25, 2024

Still does not work for me with #141:

$ pipx uninstall lastversion
uninstalled lastversion! ✨ 🌟 ✨
$ pipx install git+https://github.com/dvershinin/lastversion
  installed package lastversion 3.4.6, installed using Python 3.12.1
  These apps are now globally available
    - lastversion
done! ✨ 🌟 ✨
$ lastversion --assets unzip SamusAranX/MinimalMIDIPlayer
MinimalMIDIPlayer-v1.13.zip: 7368.0KB [00:00, 44333.42KB/s]
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/lastversion/utils.py", line 378, in extract_tar_and_zip
    with tarfile.open(fileobj=buffer, mode="r") as file:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/tarfile.py", line 1811, in open
    raise ReadError(f"file could not be opened successfully:\n{error_msgs_summary}")
tarfile.ReadError: file could not be opened successfully:
- method gz: ReadError('not a gzip file')
- method bz2: ReadError('not a bzip2 file')
- method xz: ReadError('not an lzma file')
- method tar: ReadError('bad checksum')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/bin/lastversion", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/lastversion/lastversion.py", line 889, in main
    extract_file(url)
  File "/opt/homebrew/lib/python3.11/site-packages/lastversion/utils.py", line 437, in extract_file
    extract_tar_and_zip(buffer, to_dir=to_dir)
  File "/opt/homebrew/lib/python3.11/site-packages/lastversion/utils.py", line 384, in extract_tar_and_zip
    extract_archive(file)
  File "/opt/homebrew/lib/python3.11/site-packages/lastversion/utils.py", line 373, in extract_archive
    archive_file.extract(item, to_dir)
  File "/opt/homebrew/Cellar/[email protected]/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/zipfile.py", line 1664, in extract
    return self._extract_member(member, path, pwd)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/zipfile.py", line 1735, in _extract_member
    open(targetpath, "wb") as target:
    ^^^^^^^^^^^^^^^^^^^^^^
NotADirectoryError: [Errno 20] Not a directory: 'Contents/CodeResources'

from lastversion.

vogler avatar vogler commented on September 25, 2024

Thanks, works now 👍

$ lastversion --assets unzip SamusAranX/MinimalMIDIPlayer
MinimalMIDIPlayer-v1.13.zip: 7368.0KB [00:00, 30144.44KB/s]
$ ll | grep Mini
drwxr-xr-x     3 voglerr staff   96 Jan 26 20:46 MinimalMIDIPlayer.app

from lastversion.

vogler avatar vogler commented on September 25, 2024

Are you making a release for this? If not, I'll just keep pipx install git+https://github.com/dvershinin/lastversion in my dotfiles for now.

from lastversion.

vogler avatar vogler commented on September 25, 2024

lastversion --assets unzip still doesn't work for macOS apps:
image

$ open MinimalMIDIPlayer.app
The application cannot be opened for an unexpected reason, error=Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x6000020c4570 {Error Domain=NSPOSIXErrorDomain Code=111 "Unknown error: 111" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}

Whereas there's no problem with download + unzip:

$ lastversion --assets download SamusAranX/MinimalMIDIPlayer
Downloaded MinimalMIDIPlayer-v1.13.zip: : 7368.0KB [00:00, 30527.86KB/s]

$ unzip MinimalMIDIPlayer-v1.13.zip
Archive:  MinimalMIDIPlayer-v1.13.zip
   creating: MinimalMIDIPlayer.app/
   creating: MinimalMIDIPlayer.app/Contents/
  inflating: MinimalMIDIPlayer.app/Contents/CodeResources
...
  MinimalMIDIPlayer.app/Contents/Frameworks/Sparkle.framework/Versions/Current -> A

$ open MinimalMIDIPlayer.app

The contents and permissions seem to be the same.

from lastversion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.