read json configuration from file for firebase

This commit is contained in:
Dan Funk 2020-09-21 16:18:26 -04:00
parent ca910c02f2
commit dd07f2ecf0
3 changed files with 11 additions and 4 deletions

View File

@ -33,7 +33,7 @@ after_success:
deploy:
provider: script
script: bash deploy.sh sartography/testing-communicator
script: bash deploy.sh sartography/uva-covid19-testing-communicator
skip_cleanup: true
on:
all_branches: true

View File

@ -1,7 +1,9 @@
import json
import os
from google.auth.credentials import Credentials
from google.cloud import firestore
from google.oauth2 import service_account
from communicator import app
from communicator.models.sample import Sample
@ -11,8 +13,11 @@ class FirebaseService(object):
"""Connects to the Google's Firecloud service to retrieve any records added by the tablets. """
def __init__(self):
resource_path = os.path.join(app.instance_path, 'firestore_service_key.json')
self.db = firestore.Client.from_service_account_json(resource_path)
json_config = json.loads(app.config['FIRESTORE_JSON'])
credentials = service_account.Credentials.from_service_account_info(json_config)
self.db = firestore.Client(project="uva-covid19-testing-kiosk",
credentials= credentials)
def get_samples(self):
# Then query for documents

View File

@ -23,6 +23,8 @@ SQLALCHEMY_DATABASE_URI = environ.get(
)
ADMIN_UIDS = ['dhf8r']
print('### USING TESTING CONFIG: ###')
print('SQLALCHEMY_DATABASE_URI = ', SQLALCHEMY_DATABASE_URI)
print('TESTING = ', TESTING)