def load_discussions(identifiers): from anyway.models import DiscussionMarker from flask_sqlalchemy import SQLAlchemy from anyway.utilities import init_flask app = init_flask() db = SQLAlchemy(app) identifiers = identifiers or sys.stdin for identifier in identifiers: identifier = identifier.strip() m = re.match(r"\((\d+\.\d+),\s*(\d+\.\d+)\)", identifier) if not m: logging.error("Failed processing: " + identifier) continue (latitude, longitude) = m.group(1, 2) marker = DiscussionMarker.parse({ "latitude": latitude, "longitude": longitude, "title": identifier, "identifier": identifier, }) try: db.session.add(marker) db.session.commit() logging.info("Added: " + identifier) except Exception as e: db.session.rollback() logging.warn("Failed: " + identifier + ": " + e)
def load_discussions(identifiers): from anyway.models import DiscussionMarker from flask_sqlalchemy import SQLAlchemy from anyway.utilities import init_flask app = init_flask() db = SQLAlchemy(app) identifiers = identifiers or sys.stdin for identifier in identifiers: identifier = identifier.strip() m = re.match(r'\((\d+\.\d+),\s*(\d+\.\d+)\)', identifier) if not m: logging.error("Failed processing: " + identifier) continue (latitude, longitude) = m.group(1, 2) marker = DiscussionMarker.parse({ 'latitude': latitude, 'longitude': longitude, 'title': identifier, 'identifier': identifier }) try: db.session.add(marker) db.session.commit() logging.info("Added: " + identifier) except Exception as e: db.session.rollback() logging.warn("Failed: " + identifier + ": " + e)