Bug in 1.3.0b pyniopath_ncarg()

From: David Brodrick <david_at_nyahnyahspammersnyahnyah>
Date: Sat, 06 Dec 2008 17:46:20 +1100

Sincere apologies if this comes through more than once, I had some
delays subscribing to the list, so I am not sure if my earlier posts
were accepted:

I am upgrading from PyNGL 1.2 to PyNGL/NIO 1.3.0b. I encountered
problems when trying to open a GRIB2 file.

The new machinery for finding the codetables seems to do the wrong thing
on my machine. PyNIO is installed under
/usr/lib/python2.4/site-packages/ but pyniopath_ncarg() is incorrectly
selecting the empty directory /usr/local/lib/python2.4/site-packages/
instead, because it preceeds /usr/lib/ is sys.path.

I believe the following implementation of pyniopath_ncarg() fixes this
problem and also fixes the error where os.path.exists is called with a
None argument if NCARG_ROOT is not defined:

#####
def pyniopath_ncarg():
import sys
pynio_ncarg = None
for path in sys.path:
  trypath = os.path.join(path,"PyNIO","ncarg")
  if os.path.exists(trypath):
    pynio_ncarg = trypath
    break

if pynio_ncarg==None:
  ncarg_dir = os.environ.get("NCARG_ROOT")
  if ncarg_dir==None or not os.path.exists(ncarg_dir) \
     or not os.path.exists(os.path.join(ncarg_dir,"lib","ncarg")):
    print "No usable NCARG installation found"
    sys.exit()
  else:
    pynio_ncarg = os.path.join(ncarg_dir,"lib","ncarg")

return pynio_ncarg
#####

I still haven't got everything working yet but I thought I'd report this
issue for your consideration.

The libraries are awesome, thanks so much for all your great work!
Cheers,
David

_______________________________________________
pyngl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
Received on Fri Dec 05 2008 - 23:46:20 MST

This archive was generated by hypermail 2.2.0 : Thu Jan 01 2009 - 08:39:20 MST