Closed dkirkby closed 9 years ago
Using the latest commit to #70, the example above now exits with:
The value --exposure 7 is outside the allowed range 0-6.
Use the --verbose option for details on the available exposures.
The handling of missing spCFrame files is still not great, but really a separate issue #34:
% bossplot --cframe --exposure 0 --plate 6641 --mjd 56383 --fiber 30
HTTP request returned error code 404 for http://dr12.sdss3.org/sas/dr12/boss/spectro/redux/v5_7_0/6641/spCFrame-r1-00158840.fits.
At least now you know that the problem is not an invalid exposure index.
The same problem occurs for an invalid plate / mjd, so we really need a better solution:
% bossplot --plate 10000
HTTP request returned error code 404 for http://dr12.sdss3.org/sas/dr12/boss/spectro/redux/v5_7_0/spectra/lite/10000/spec-10000-56383-0030.fits.
Add special handling for HTTP 404 errors. Now the message is:
There is no remote file /sas/dr12/boss/spectro/redux/v5_7_0/spectra/lite/100000/spec-100000-56383-0030.fits.
Invalid fibers throw a ValueError
which we are not catching:
% bossplot --fiber 0
Traceback (most recent call last):
File "/Users/david/anaconda/bin/bossplot", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/Users/david/Cosmo/LyAlpha/code/bossdata/bin/bossplot", line 481, in <module>
main()
File "/Users/david/Cosmo/LyAlpha/code/bossdata/bin/bossplot", line 231, in main
fiber=args.fiber, lite=lite)]
File "/Users/david/Cosmo/LyAlpha/code/bossdata/bossdata/path.py", line 241, in get_spec_path
fiber, get_num_fibers(plate), plate))
ValueError: Invalid fiber (0) must be 1-1000 for plate 6641.
Catch this to give:
% bossplot --fiber 0
Invalid fiber (0) must be 1-1000 for plate 6641.
Invalid mask bits also throw an un-caught ValueError
. Fix this:
% bossplot --allow-mask INVALID
Invalid bit name: INVALID.
Processing of the `--figsize X,Y`` option is quite fragile. Some combinations silently open plots in invisible windows that you cannot close, e.g.
bossplot --figsize 10,-1
bossplot --figsize 0,0
Other values throw un-caught exceptions, e.g.
bossplot --figsize 10,10,10
These are now handled reasonably:
% bossplot --figsize 0,0
Minimum --figsize is 1,1.
% bossplot --figsize 10,10,10
Invalid option --figsize 10,10,10 (expected WIDTH,HEIGHT in inches).
Providing a bad file name to --save-data
or --save-plot
raises an un-caught IOError
, e.g.
% bossplot --save-data /protected
...
IOError: [Errno 13] Permission denied: '/protected'
Now this exits with:
Unable to save data: [Errno 13] Permission denied: '/protected'.
Add similar logic for --save-plot
errors.
I am declaring this done for now (once #70 gets merged), but re-open if you find any more un-caught exceptions.
The platelist catalog could be used to check if the requested plate/mjd are valid.
The following should fail more gracefully:
This issue is to do a systematic review of possible errors due to invalid command-line parameters and handle each with a short message printed to stdout and returning with a non-zero exit code, e.g.