When getADDEImage() hits on a missing image, image retrieving stops in an uncontrollable way within getADDEImage(). The traceback points to a failure at the code line
If getADDEImage is failing and you want to continue the script, you should be able to accomplish this with Python "try/except" statements. The simplest form is something like this:
try: # code that could potentially result in error getADDEImage(**parms) except Exception: # here, define whatever logic you want to handle getADDEImage failure # for now, just print a message and continue print 'Something went wrong in getADDEImage'
print 'This code should run even if getADDEImage failed'
More complete information on "try/except" can be found in the Python documentation, especially section "8.3 Errors and Exceptions": http://docs.python.org/2.5/tut/node10.html
Finally, could you post the full error message/traceback and McV version number/build date just to make sure I'm understanding the problem correctly?
I've got it working - many thanks for the hint. However, the code works only with a wildcard except: clause. Both 'AddeURLException' or 'Exception' fail to catch the exception. In the attached file you find the code (with wildcard except) and a traceback when the catch fails (McV 1.3beta1 build 2013-05-24 23:15, Win7 64bit).
BTW getADDEImage still prints the URL and some further data for each call. I have not found a way to suppress this printout (in the shell). It is certainly helpful when debugging, but it spoils useful output with working code.
Hi HP, Sorry about that, you're exactly right. I'm glad you got it working despite my example!
I don't think there's any need to change your code, but if you do want to explicitly catch only the VisADException thrown by getADDEImage, here's how it looks:
from visad import VisADException try: getADDEImage(**parms) except VisADException, exc: # define code to handle the exception print exc
(The problem with my original example is that exceptions resulting from Java code do not extend Jython's "Exception" class, so in our McV environment, the 'except Exception:' statement is not a valid way to catch all exceptions. I shouldn't post examples without testing them!!)