def configure(self, options):
            collection_name = None
            config_location = None
            config_key = None
            
            if "collection_name" in options:
                collection_name = options["collection_name"]
            if "db_info" in options:
                config_location = options["db_info"]["location"]    
                config_key      = options["db_info"]["key"]    
                config_location = options["db_info"]["location"]    

            mtret = compose_multi_table(config_location, config_key, just_one=True)
            mdbinfo = mtret["mdb_info"]
            
            print ksutil.dict2pretty("mdb_info", mdbinfo)
            self.host     = mdbinfo["host"]
            self.dbname   = mdbinfo["db"]
            self.user     = mdbinfo["user"]
            self.password = base64.b64decode(mdbinfo["password"])

            self.get_connection()
            if collection_name:
                self.collection_name = collection_name
                self.collection = self.db[collection_name]
 def __init__(self, reduceport):
     # get my client for the reduce commands
     print "starting xmlrpc client to port %d..." % reduceport,
     self.reducecmds = xmlrpclib.ServerProxy("http://localhost:%d/" \
                                             % reduceport, allow_none=True)
     print "started"
     try:
         self.reducecmds.prs_ready()
     except socketError:
         print "prs50: no reduce instances running"
     self.reducedict = {}
     # these members save command history so that tools have access, e.g.
     #   a display tool
     self.stackKeeper = StackKeeper(local=True)
     self.displayCmdHistory = TSCmdQueue()
     self.events_manager = EventsManager(persist="adcc_events.jsa")
     
     # publishers
     self.publishers = []
     pubret = compose_multi_table("*/adcc_settings", "publish_qametrics")
     print ks.dict2pretty("em37:publish_qametrics", pubret)
     if pubret and "publish_qametrics" in pubret:
         pubconfig = pubret["publish_qametrics"]
         for publer in pubconfig:
             module = publer["publisher"][0]
             classname = publer["publisher"][1]
             dbinfo = publer["db_info"]
             collection_name = publer["collection"]
             
             exec("import %s" % module)
             publisher = eval("%s.%s()" % (module,classname))
             publisher.configure({ "collection_name": collection_name,
                                   "db_info":dbinfo
                                  })
             self.publishers.append(publisher)
Beispiel #3
0
import os, re
from astrodata.Errors import Error
from astrodata.AstroDataType import get_classification_library
from astrodata.adutils import termcolor as tc
from astrodata.Lookups import compose_multi_table
cl = get_classification_library() 

class GD_OperationNotPermitted(Error):
    """ GeneralData related exceptions, raised if an operation is not permitted,
        like setting an output_filename property (it's constructed from the
        output_directory and the basename).
    """
    message  = "Operation Not Permitted"

filetypes = compose_multi_table("*/filetypes.py",
                                "data_object_precedence",
                                "data_object_classes")
_data_object_classes = filetypes["data_object_classes"]
_data_object_precedence = filetypes["data_object_precedence"]

_gen_classification_library = cl

class HDUnit(object):
    # abstracts the idea of a unit of data and it's metadata
    pass
    
class GeneralData(object):
    # filename is a property
    _filename = None
    # output_directory is a property
    _output_directory = None