[Yt-svn] commit/yt: MatthewTurk: Adding access to the new Enzo run database.

Bitbucket commits-noreply at bitbucket.org
Fri May 20 22:06:22 PDT 2011


1 new changeset in yt:

http://bitbucket.org/yt_analysis/yt/changeset/2020d180788a/
changeset:   r4273:2020d180788a
branch:      yt
user:        MatthewTurk
date:        2011-05-21 07:05:31
summary:     Adding access to the new Enzo run database.
affected #:  4 files (1.2 KB)

--- a/yt/config.py	Thu May 19 09:20:44 2011 -0400
+++ b/yt/config.py	Sat May 21 01:05:31 2011 -0400
@@ -48,6 +48,7 @@
     parallel_traceback = 'False',
     pasteboard_repo = '',
     test_storage_dir = '/does/not/exist',
+    enzo_db = '',
     )
 # Here is the upgrade.  We're actually going to parse the file in its entirety
 # here.  Then, if it has any of the Forbidden Sections, it will be rewritten


--- a/yt/convenience.py	Thu May 19 09:20:44 2011 -0400
+++ b/yt/convenience.py	Sat May 21 01:05:31 2011 -0400
@@ -30,8 +30,10 @@
 
 # Named imports
 from yt.funcs import *
+from yt.config import ytcfg
 from yt.utilities.parameter_file_storage import \
-    output_type_registry
+    output_type_registry, \
+    EnzoRunDatabase
 
 def all_pfs(basedir='.',max_depth=1, name_spec="*.hierarchy", **kwargs):
     """
@@ -75,6 +77,15 @@
     if len(candidates) == 1:
         return output_type_registry[candidates[0]](*args, **kwargs)
     if len(candidates) == 0:
+        if ytcfg.get("yt", "enzo_db") != '' \
+           and len(args) == 1 \
+           and isinstance(args[0], types.StringTypes):
+            erdb = EnzoRunDatabase()
+            fn = erdb.find_uuid(args[0])
+            n = "EnzoStaticOutput"
+            if n in output_type_registry \
+               and output_type_registry[n]._is_valid(fn):
+                return output_type_registry[n](fn)
         mylog.error("Couldn't figure out output type for %s", args[0])
         return None
     mylog.error("Multiple output type candidates for %s:", args[0])


--- a/yt/utilities/command_line.py	Thu May 19 09:20:44 2011 -0400
+++ b/yt/utilities/command_line.py	Sat May 21 01:05:31 2011 -0400
@@ -485,6 +485,8 @@
     @add_cmd_options(["proj", "field", "weight"])
     @cmdln.option("-a", "--axis", action="store", type="int",
                    dest="axis", default=0, help="Axis (4 for all three)")
+    @cmdln.option("-o", "--host", action="store", type="string",
+                   dest="host", default=None, help="IP Address to bind on")
     @check_args
     def do_mapserver(self, subcmd, opts, arg):
         """
@@ -507,7 +509,10 @@
         mapper = PannableMapServer(p.data, opts.field)
         import yt.utilities.bottle as bottle
         bottle.debug(True)
-        bottle.run(server='rocket')
+        if opts.host is not None:
+            bottle.run(server='rocket', host=opts.host)
+        else:
+            bottle.run(server='rocket')
 
     def do_rpdb(self, subcmd, opts, task):
         """


--- a/yt/utilities/parameter_file_storage.py	Thu May 19 09:20:44 2011 -0400
+++ b/yt/utilities/parameter_file_storage.py	Sat May 21 01:05:31 2011 -0400
@@ -219,3 +219,22 @@
 
 class ObjectStorage(object):
     pass
+
+class EnzoRunDatabase(object):
+    conn = None
+
+    def __init__(self, path = None):
+        if path is None:
+            path = ytcfg.get("yt", "enzo_db")
+            if len(path) == 0: raise Runtime
+        import sqlite3
+        self.conn = sqlite3.connect(path)
+
+    def find_uuid(self, u):
+        cursor = self.conn.execute(
+            "select pf_path from enzo_outputs where dset_uuid = '%s'" % (
+                u))
+        # It's a 'unique key'
+        result = cursor.fetchone()
+        if result is None: return None
+        return result[0]

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list