def __init__(self, config_file_path, database_uri=None): config = ConfigParser.RawConfigParser() config.read(config_file_path) if not database_uri: database_uri = config.get('Database', 'URI') self.engine = create_engine(database_uri, convert_unicode=True) #TODO: use pool_size for non-sqlite database self.db_session = scoped_session( sessionmaker(autocommit=False, autoflush=False, bind=self.engine)) cache.init_model(self.db_session) self.cbi_sos_client = cbi_sos_client.CbiSosClient( 'http://lighthouse.tamucc.edu/sos') if config.has_section('Contact'): self.contact_info = dict( name=config.get('Contact', 'Name'), phone=config.get('Contact', 'Phone'), email=config.get('Contact', 'Email'), organization=config.get('Contact', 'Organization'), link=config.get('Contact', 'Link'), description=config.get('Contact', 'Description'), address=config.get('Contact', 'Address'), city=config.get('Contact', 'City'), state=config.get('Contact', 'State'), zipcode=config.get('Contact', 'ZipCode'))
def __init__(self, config_file_path, database_uri=None): config = ConfigParser.RawConfigParser() config.read(config_file_path) if not database_uri: database_uri = config.get('Database', 'URI') self.engine = create_engine(database_uri, convert_unicode=True) #TODO: use pool_size for non-sqlite database self.db_session = scoped_session(sessionmaker( autocommit=False, autoflush=False, bind=self.engine)) cache.init_model(self.db_session) self.cbi_sos_client = cbi_sos_client.CbiSosClient( 'http://lighthouse.tamucc.edu/sos') if config.has_section('Contact'): self.contact_info = dict( # name=config.get('Contact', 'Name'), # phone=config.get('Contact', 'Phone'), email=config.get('Contact', 'Email'), organization=config.get('Contact', 'Organization'), link=config.get('Contact', 'Link'), description=config.get('Contact', 'Description'), address=config.get('Contact', 'Address'), city=config.get('Contact', 'City'), state=config.get('Contact', 'State'), zipcode=config.get('Contact', 'ZipCode') )
print "Fetching GCOOS parameter file from remote location." fetch_gcoos_parameter_file(GCOOS_ONTOLOGY_FILE_URL, LOCAL_PARAMETER_FILE_PATH) engine = create_engine(CBI_CACHE_DATABASE_URI, convert_unicode=True) if options.dropall: print "Dropping existing tables from cache." model.clear_model(engine) model.create_model(engine) db_session = scoped_session(sessionmaker( autocommit=False, autoflush=False, bind=engine)) model.init_model(db_session) print "Parsing IOOS site file." site_set = parse_site_file(LOCAL_SITE_FILE_PATH) print ("Extracting valid site codes from SOS capabilities " "file and removing non-matching sites from site cache.") capabilities_site_list = extract_sites_from_capabilities_doc( LOCAL_CAPABILITIES_FILE_PATH) valid_site_list = [s for s in site_set if s.code in capabilities_site_list] cache_sites = [model.Site(s.code, s.name, s.latitude, s.longitude) for s in valid_site_list]