Skip to content

Commit

Permalink
populate db ... and mv cached feed if load fails
Browse files Browse the repository at this point in the history
  • Loading branch information
fpurcell committed Aug 24, 2016
1 parent a0a0b49 commit 206744e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion config/app.ini
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ right : -121.50

[db]
url = postgresql+psycopg2://127.0.0.1:5432/ott
user = geoserve
is_geospatial = true


Expand Down
8 changes: 4 additions & 4 deletions ott/loader/gtfsdb/gtfsdb_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from ott.utils import object_utils
from ott.utils import db_utils
from ott.utils import file_utils
from ott.utils.cache_base import CacheBase
from ott.loader.gtfs.gtfs_cache import GtfsCache
from gtfsdb.api import database_load
Expand All @@ -20,8 +21,7 @@ def __init__(self):
super(GtfsdbLoader, self).__init__(section='gtfs')

self.feeds = self.config.get_json('feeds', section='gtfs')
self.db_url = self.config.get('url', section='db', def_val='postgresql+psycopg2://127.0.0.1:5432/ott')
self.db_user = self.config.get('user', section='db')
self.db_url = self.config.get('url', section='db', def_val='postgresql+psycopg2://[email protected]:5432/ott')
self.is_geospatial = self.config.get_bool('is_geospatial', section='db')

def check_db(self, force_update=False):
Expand All @@ -33,8 +33,7 @@ def check_db(self, force_update=False):

if reload:
# step 1: check the database
db_utils.check_create_db(self.db_url, self.db_user, self.is_geospatial)

db_utils.check_create_db(self.db_url, self.is_geospatial)
self.load_feeds()

def load_feeds(self):
Expand All @@ -57,6 +56,7 @@ def load_feeds(self):
try:
database_load(feed_path, **kwargs)
except Exception, e:
file_utils.mv(feed_path, feed_path + "-error_loading")
log.error("DATABASE ERROR : {}".format(e))

@classmethod
Expand Down

0 comments on commit 206744e

Please sign in to comment.