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

Warn users about missing data or using WFIRSTImager #49

Merged
merged 5 commits into from
Feb 19, 2015

Conversation

josePhoenix
Copy link
Collaborator

Last two changes pre-release: add disclaimer to WFIRST classes, improve user experience in the absence of WEBBPSF_DATA cc @mperrin @cslocum

mperrin added a commit that referenced this pull request Feb 19, 2015
Warn users about missing data or using WFIRSTImager
@mperrin mperrin merged commit 3d24874 into mperrin:master Feb 19, 2015
@mperrin
Copy link
Owner

mperrin commented Feb 19, 2015

Hmm, so I went ahead and merged this. But now I see that it has the side effect of suppressing the exception in whatever program or module is trying to import webbpsf. Wouldn't it be better to pass the exception up higher so that the program that just tried the import knows it cannot continue?

I guess I don't understand entirely the motivation for calling traceback.print_exc() in this context instead of just letting the exception percolate upwards?

Example:

mperrin@peregrine ~ > unsetenv WEBBPSF_PATH
mperrin@peregrine ~ > ipython
Python 2.7.8 (default, Oct  7 2014, 15:36:11)
...

In [1]: try:
   ...:     import webbpsf
   ...:     print "OK"
   ...: except:
   ...:     print "Not OK :-("
   ...:
WebbPSF log messages of level INFO and above will be shown.
WebbPSF log outputs will be directed to the screen.
Traceback (most recent call last):
  File "/Users/mperrin/Dropbox (Personal)/Documents/software/webbpsf/webbpsf/__init__.py", line 93, in <module>
    utils.get_webbpsf_data_path()
  File "/Users/mperrin/Dropbox (Personal)/Documents/software/webbpsf/webbpsf/utils.py", line 143, in get_webbpsf_data_path
    raise EnvironmentError("Environment variable $WEBBPSF_PATH is not set!")
EnvironmentError: Environment variable $WEBBPSF_PATH is not set!

 *********  ERROR  ******  ERROR  ******  ERROR  ******  ERROR  *************
 *                                                                          *
 *  WebbPSF requires several data files to operate.                         *
 *  These files could not be located automatically at this                  *
 *  time. Please download them to a location of your                        *
 *  choosing and either                                                     *
 *   - set the environment variable $WEBBPSF_PATH to point there, or        *
 *   - set the WEBBPSF_PATH variable in your webbpsf.cfg config file        *
 *     (probably in ~/.astropy/config/ or similar location)                 *
 *                                                                          *
 *  See http://pythonhosted.org/webbpsf/installation.html, under            *
 *  "Installing the Required Data Files", for more details.                 *
 *  WebbPSF will not be able to function properly until this has been done. *
 *                                                                          *
 ****************************************************************************
OK

Note that the import case in the try was successful, as indicated by the print OK.

@josePhoenix
Copy link
Collaborator Author

Oh, whoops. I noticed Christine didn't read the notice and gravitated straight to the traceback, so I figured I'd reorder them. But, that has the unintended consequence you identified!

Better fix that.

On Feb 19, 2015, at 6:03 PM, Marshall Perrin notifications@github.com wrote:

Hmm, so I went ahead and merged this. But now I see that it has the side effect of suppressing the exception in whatever program or module is trying to import webbpsf. Wouldn't it be better to pass the exception up higher so that the program that just tried the import knows it cannot continue?

I guess I don't understand entirely the motivation for calling traceback.print_exc() in this context instead of just letting the exception percolate upwards?

Example:

mperrin@peregrine ~ > unsetenv WEBBPSF_PATH
mperrin@peregrine ~ > ipython
Python 2.7.8 (default, Oct 7 2014, 15:36:11)
...

In [1]: try:
...: import webbpsf
...: print "OK"
...: except:
...: print "Not OK :-("
...:
WebbPSF log messages of level INFO and above will be shown.
WebbPSF log outputs will be directed to the screen.
Traceback (most recent call last):
File "/Users/mperrin/Dropbox (Personal)/Documents/software/webbpsf/webbpsf/init.py", line 93, in
utils.get_webbpsf_data_path()
File "/Users/mperrin/Dropbox (Personal)/Documents/software/webbpsf/webbpsf/utils.py", line 143, in get_webbpsf_data_path
raise EnvironmentError("Environment variable $WEBBPSF_PATH is not set!")
EnvironmentError: Environment variable $WEBBPSF_PATH is not set!

********* ERROR ****** ERROR ****** ERROR ****** ERROR *************

  •                                                                      *
    
  • WebbPSF requires several data files to operate. *
  • These files could not be located automatically at this *
  • time. Please download them to a location of your *
  • choosing and either *
    • set the environment variable $WEBBPSF_PATH to point there, or *
    • set the WEBBPSF_PATH variable in your webbpsf.cfg config file *
  • (probably in ~/.astropy/config/ or similar location)                 *
    
  •                                                                      *
    
  • See http://pythonhosted.org/webbpsf/installation.html, under *
  • "Installing the Required Data Files", for more details. *
  • WebbPSF will not be able to function properly until this has been done. *
  •                                                                      *
    

    OK

Note that the import case in the try was successful, as indicated by the print OK.


Reply to this email directly or view it on GitHub.

@josePhoenix
Copy link
Collaborator Author

josePhoenix commented Feb 20, 2015 via email

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 this pull request may close these issues.

None yet

3 participants