Skip to content

Commit

Permalink
fixes after testing
Browse files Browse the repository at this point in the history
  • Loading branch information
lstillwe committed Nov 1, 2023
1 parent 3ed31fe commit a08063d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
7 changes: 2 additions & 5 deletions apsviz_db.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import os, sys
import base_db
from base_db import BASE_DB
import psycopg2
import json

from common.logging import LoggingUtil
from urllib.parse import urlparse

class APSVIZ_DB(base_db):
class APSVIZ_DB(BASE_DB):

# dbname looks like this: 'asgs_dashboard'
# instance_id looks like this: '2744-2021050618-namforecast'
Expand Down
8 changes: 4 additions & 4 deletions apsviz_gauges_db.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os, sys
import base_db
from base_db import BASE_DB
import csv

class APSVIZ_GAUGES_DB(base_db):
class APSVIZ_GAUGES_DB(BASE_DB):

# dbname looks like this: 'apsviz_gauges'
# instance_id looks like this: '2744-2021050618-namforecast'
Expand All @@ -12,7 +12,7 @@ def __init__(self, logger, instance_id):
pswd = os.getenv('APSVIZ_GAUGES_DB_PASSWORD', 'password').strip()
host = os.getenv('APSVIZ_GAUGES_DB_HOST', 'host').strip()
port = os.getenv('APSVIZ_GAUGES_DB_PORT', '5432').strip()
db_name = os.getenv('APSVIZ_GAUGES_DB_DATABASE', '5432').strip()
db_name = os.getenv('APSVIZ_GAUGES_DB_DATABASE', 'db').strip()

super().__init__(logger, user, pswd, db_name, host, port)

Expand Down Expand Up @@ -128,4 +128,4 @@ def valid_csv_row(header: list, row: list, optional=None) -> str:
no_data_col.append(header[index])

# return the failed cols
return ','.join(no_data_col)
return ','.join(no_data_col)
5 changes: 3 additions & 2 deletions asgs_db.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os, sys
import base_db
from base_db import BASE_DB

class ASGS_DB(base_db):
class ASGS_DB(BASE_DB):

# dbname looks like this: 'asgs_dashboard'
# instance_id looks like this: '2744-2021050618-namforecast'
Expand Down Expand Up @@ -89,3 +89,4 @@ def getRunMetadata(self):
metadata_dict['suite.project_code'] = 'asgs'
return metadata_dict


10 changes: 5 additions & 5 deletions base_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ def __init__(self, logger, user, pswd, db, host, port):
self.conn = None
self.logger = logger

self.user = user.strip()
self.pswd = pswd.strip()
self.dbname = db.strip()
self.host = host.strip()
self.port = port.strip()
self.user = user
self.pswd = pswd
self.dbname = db
self.host = host
self.port = port

try:
# connect to the database
Expand Down
12 changes: 6 additions & 6 deletions load-geoserver-images.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def update_layer_title(logger, geo, instance_id, worksp, layer_name, kalpana=Fal
run_date = ''
# first get metadata from this model run
db_name = os.getenv('ASGS_DB_DATABASE', 'asgs').strip()
asgsdb = ASGS_DB(logger, db_name, instance_id)
asgsdb = ASGS_DB(logger, instance_id)
meta_dict = asgsdb.getRunMetadata()
run_date = format_raw_date(meta_dict['currentdate'])
if (kalpana):
Expand Down Expand Up @@ -217,7 +217,7 @@ def add_imagemosaic_coveragestore(logger, geo, url, instance_id, worksp, imagemo
layer_url = f'{url}/{worksp}/wcs?service=WCS&version=1.1.1&request=DescribeCoverage&identifiers={worksp}:{layer_name}'
logger.debug(f"Adding coverage store to DB, instanceId: {instance_id} coveragestore url: {layer_url}")
db_name = os.getenv('ASGS_DB_DATABASE', 'asgs').strip()
asgsdb = ASGS_DB(logger, db_name, instance_id)
asgsdb = ASGS_DB(logger, instance_id)
asgsdb.saveImageURL(file, layer_url)

# add this layer to the wms layer group dict
Expand Down Expand Up @@ -270,7 +270,7 @@ def add_kalpana_coveragestore(logger, geo, url, instance_id, worksp, kalpana_pat
layer_url = f'{url}/{worksp}/wcs?service=WCS&version=1.1.1&request=DescribeCoverage&identifiers={worksp}:{layer_name}'
logger.debug(f"Adding coverage store to DB, instanceId: {instance_id} coveragestore url: {layer_url}")
db_name = os.getenv('ASGS_DB_DATABASE', 'asgs').strip()
asgsdb = ASGS_DB(logger, db_name, instance_id)
asgsdb = ASGS_DB(logger, instance_id)
asgsdb.saveImageURL(file, layer_url)

# add this layer to the wms layer group dict
Expand Down Expand Up @@ -319,7 +319,7 @@ def add_mbtiles_coveragestores(logger, geo, url, instance_id, worksp, mbtiles_pa
layer_url = f'{url}/{worksp}/wcs?service=WCS&version=1.1.1&request=DescribeCoverage&identifiers={worksp}:{layer_name}'
logger.debug(f"Adding coverage store to DB, instanceId: {instance_id} coveragestore url: {layer_url}")
db_name = os.getenv('ASGS_DB_DATABASE', 'asgs').strip()
asgsdb = ASGS_DB(logger, db_name, instance_id)
asgsdb = ASGS_DB(logger, instance_id)
asgsdb.saveImageURL(file, layer_url)

# add this layer to the wms layer group dict
Expand Down Expand Up @@ -361,7 +361,7 @@ def add_props_datastore(logger, geo, instance_id, worksp, final_path, geoserver_
return


def add_dbprops_datastore(logger, geo, instance_id, worksp, final_path, geoserver_host, layergrp):
def add_dbprops_datastore(logger, geo, instance_id, worksp, layergrp):
logger.info(f"Adding the station properties datastore for instance id: {instance_id}")
# set up datastore name
store_name = str(instance_id) + "_station_props"
Expand Down Expand Up @@ -425,7 +425,7 @@ def add_shapefile_datastores(logger, geo, instance_id, worksp, shp_path, layergr

# retrieve run.properties metadata fro this instance_id
db_name = os.getenv('ASGS_DB_DATABASE', 'asgs').strip()
asgsdb = ASGS_DB(logger, db_name, instance_id)
asgsdb = ASGS_DB(logger, instance_id)
meta_dict = asgsdb.getRunMetadata()

# now check to see if this is a tropical storm and only continue if it is
Expand Down

0 comments on commit a08063d

Please sign in to comment.