[Yt-svn] yt-commit r1085 - in trunk/yt: fido lagos

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Wed Jan 7 17:18:15 PST 2009


Author: mturk
Date: Wed Jan  7 17:18:15 2009
New Revision: 1085
URL: http://yt.spacepope.org/changeset/1085

Log:
A fix -- now we try the CWD for the parameter file storage instead of home
directory if we can't access the home directory (YAY COMPUTE NODE LINUX) and
additionally we catch an exception if something screws up during
initialization.



Modified:
   trunk/yt/fido/ParameterFileStorage.py
   trunk/yt/lagos/OutputTypes.py

Modified: trunk/yt/fido/ParameterFileStorage.py
==============================================================================
--- trunk/yt/fido/ParameterFileStorage.py	(original)
+++ trunk/yt/fido/ParameterFileStorage.py	Wed Jan  7 17:18:15 2009
@@ -29,6 +29,9 @@
 import shelve
 import os.path
 
+class NoParameterShelf(Exception):
+    pass
+
 class ParameterFileStore(object):
 
     _shared_state = {}
@@ -43,6 +46,8 @@
         only_on_root(self.__init_shelf)
 
     def _get_db_name(self):
+        if not os.access(os.path.expanduser("~/"), os.W_OK):
+            return "parameter_files.db"
         return os.path.expanduser("~/.yt/parameter_files.db")
 
     def wipe_hash(self, hash):
@@ -103,7 +108,10 @@
     def __init_shelf(self):
         dbn = self._get_db_name()
         dbdir = os.path.dirname(dbn)
-        if not os.path.isdir(dbdir): os.mkdir(dbdir)
+        try:
+            if not os.path.isdir(dbdir): os.mkdir(dbdir)
+        except OSError:
+            raise NoParameterShelf()
         shelve.open(self._get_db_name(), 'c', protocol=-1)
 
     def __setitem__(self, key, val):

Modified: trunk/yt/lagos/OutputTypes.py
==============================================================================
--- trunk/yt/lagos/OutputTypes.py	(original)
+++ trunk/yt/lagos/OutputTypes.py	Wed Jan  7 17:18:15 2009
@@ -25,7 +25,7 @@
 """
 
 from yt.lagos import *
-from yt.fido import ParameterFileStore
+from yt.fido import ParameterFileStore, NoParameterShelf
 from yt.funcs import *
 import string, re, gc, time, os, os.path
 
@@ -49,7 +49,10 @@
             obj.__init__(filename, *args, **kwargs)
             _cached_pfs[apath] = obj
             if ytcfg.getboolean('lagos','serialize'):
-                _pf_store.check_pf(obj)
+                try:
+                    _pf_store.check_pf(obj)
+                except NoParameterShelf:
+                    pass
         return _cached_pfs[apath]
 
     def __init__(self, filename, data_style=None):



More information about the yt-svn mailing list