Uncategorized

How to fix NameError: Java error in HecDSS Python Script


I’m working on reading and writing information in HecDSS. I had this script working fine last night except when I opened it this morning I began getting this error:

    ScriptEngine.execute:Error in script Traceback (innermost last):
      File "<string>", line 13, in ?
    NameError: java

The basic code I’m using now is:

    from hec.script import *
    from hec.hecmath import *
    from java import *


    try:  
      dssFile = DSS.open("C:/Documents and Settings/SWP/Desktop/MVCA.dss")
      outflow = dssFile.read("/MAITLAND VALLEY/BLYTH/PRECIP-INC/01DEC2011/30MIN/OBS/")
      newOutflow = outflow.add(10.)

      path = DSSPathname(newOutflow.getPath())
      fPart = path.fPart() + " Test"
      path.setFPart(fPart)
      newOutflow.setPathname(path.getPathname())

      dssFile.write(newOutflow)

    except java.lang.Exception, e :
       MessageBox.showError(e.getMessage(), "Error reading data")

I’m just trying to figure out why it doesn’t work all of a sudden. Thanks for any help!



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *