Digital-Preservation-Finland / dpres-siptools

Pre-Ingest Tool for creating submission information packages
GNU Lesser General Public License v3.0
22 stars 8 forks source link

ValueError raised when non-existing file passed #8

Closed nemobis closed 2 years ago

nemobis commented 4 years ago

ValueError seen while looking into https://github.com/Digital-Preservation-Finland/dpres-siptools/issues/5 . The exception is slightly user-unfriendly, we should just fail earlier.

$ create-videomd
/opt/file-5.30/lib64/libmagic.so.1 not found, MS Office detection may not work properly if file command library is older.
/opt/file-5.30/lib64/libmagic.so.1 not found, MS Office detection may not work properly if file command library is older.
Usage: create-videomd [OPTIONS] FILENAME
Try 'create-videomd --help' for help.

Error: Missing argument u'FILENAME'.
(venv) $ create-videomd tests/data/video/valid_1.m1v.missing
/opt/file-5.30/lib64/libmagic.so.1 not found, MS Office detection may not work properly if file command library is older.
/opt/file-5.30/lib64/libmagic.so.1 not found, MS Office detection may not work properly if file command library is older.
Traceback (most recent call last):
  File "/home/federico/mw/dpres-siptools/venv/bin/create-videomd", line 8, in <module>
    sys.exit(main())
  File "/home/federico/mw/dpres-siptools/venv/lib/python2.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/federico/mw/dpres-siptools/venv/lib/python2.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/federico/mw/dpres-siptools/venv/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/federico/mw/dpres-siptools/venv/lib/python2.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/federico/mw/dpres-siptools/venv/lib/python2.7/site-packages/siptools/scripts/create_videomd.py", line 45, in main
    create_videomd(filename, workspace, base_path)
  File "/home/federico/mw/dpres-siptools/venv/lib/python2.7/site-packages/siptools/scripts/create_videomd.py", line 56, in create_videomd
    creator.add_videomd_md(filepath, filerel)
  File "/home/federico/mw/dpres-siptools/venv/lib/python2.7/site-packages/siptools/scripts/create_videomd.py", line 75, in add_videomd_md
    filepath, filerel, self.workspace
  File "/home/federico/mw/dpres-siptools/venv/lib/python2.7/site-packages/siptools/scripts/create_videomd.py", line 112, in create_videomd_metadata
    raise ValueError('Video stream info could not be constructed.')
ValueError: Video stream info could not be constructed.
nemobis commented 4 years ago

Better, I think:

(venv) $ create-videomd tests/data/video/valid_1.m1v.missing
/opt/file-5.30/lib64/libmagic.so.1 not found, MS Office detection may not work properly if file command library is older.
/opt/file-5.30/lib64/libmagic.so.1 not found, MS Office detection may not work properly if file command library is older.
Usage: create-videomd [OPTIONS] FILENAME
Try 'create-videomd --help' for help.

Error: Invalid value for u'FILENAME': Path 'tests/data/video/valid_1.m1v.missing' does not exist.

Ah right but needs to check for the relative path too. Hmm.

jukuisma commented 2 years ago

Your pull request https://github.com/Digital-Preservation-Finland/dpres-siptools/pull/9 has been reviewed, merged and released. Thank you for the issue and the pull request!

nemobis commented 2 years ago

Great to hear! A nice two-year anniversary for this issue. :)