Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: using -o with bad .zip file gives a terrible error messagae #2269

Closed
ctb opened this issue Sep 7, 2022 · 0 comments · Fixed by #2270
Closed

Bug: using -o with bad .zip file gives a terrible error messagae #2269

ctb opened this issue Sep 7, 2022 · 0 comments · Fixed by #2270

Comments

@ctb
Copy link
Contributor

ctb commented Sep 7, 2022

discover by @dkoslicki - the following commands work:

rm test.zip
sourmash sig cat tests/test-data/prot/protein.zip -o test.zip

but then this fails b/c test.zip is a badly formatted zip file:

rm test.zip; touch test.zip
sourmash sig cat tests/test-data/prot/protein.zip -o test.zip

and you get the error message:

== This is sourmash version 4.4.4.dev4+gceb590ce. ==
== Please cite Brown and Irber (2016), doi:10.21105/joss.00027. ==

Traceback (most recent call last):
  File "/Users/t/miniforge3/envs/py38/bin/sourmash", line 33, in <module>
    sys.exit(load_entry_point('sourmash', 'console_scripts', 'sourmash')())
  File "/Users/t/dev/sourmash/src/sourmash/__main__.py", line 13, in main
    return mainmethod(args)
  File "/Users/t/dev/sourmash/src/sourmash/cli/sig/cat.py", line 54, in main
    return sourmash.sig.__main__.cat(args)
  File "/Users/t/dev/sourmash/src/sourmash/sig/__main__.py", line 95, in cat
    save_sigs.open()
  File "/Users/t/dev/sourmash/src/sourmash/sourmash_args.py", line 1115, in open
    storage = ZipStorage(self.location, mode="w")
  File "/Users/t/dev/sourmash/src/sourmash/sbt_storage.py", line 103, in __init__
    self.__inner = _RwZipStorage(path)
  File "/Users/t/dev/sourmash/src/sourmash/sbt_storage.py", line 222, in __init__
    self.zipfile = zipfile.ZipFile(path, 'r')
  File "/Users/t/miniforge3/envs/py38/lib/python3.8/zipfile.py", line 1269, in __init__
    self._RealGetContents()
  File "/Users/t/miniforge3/envs/py38/lib/python3.8/zipfile.py", line 1336, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
Exception ignored in: <function _RwZipStorage.__del__ at 0x12d4fa0d0>
Traceback (most recent call last):
  File "/Users/t/dev/sourmash/src/sourmash/sbt_storage.py", line 400, in __del__
    self.close()
  File "/Users/t/dev/sourmash/src/sourmash/sbt_storage.py", line 326, in close
    if self.zipfile is not None or self.bufferzip is not None:
AttributeError: '_RwZipStorage' object has no attribute 'zipfile'

which is really not very helpful 😆 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant